Update auto-generated bindings
[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 DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
11 #define MALLOC(a, _) malloc(a)
12 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
13 #define CHECK_ACCESS(p)
14 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
15 #define DO_ASSERT(a) (void)(a)
16 #define CHECK(a)
17
18 static jmethodID ordinal_meth = NULL;
19 static jmethodID slicedef_meth = NULL;
20 static jclass slicedef_cls = NULL;
21 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
22         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
23         CHECK(ordinal_meth != NULL);
24         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
25         CHECK(slicedef_meth != NULL);
26         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
27         CHECK(slicedef_cls != NULL);
28 }
29
30 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
31         return *((bool*)ptr);
32 }
33 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
34         return *((long*)ptr);
35 }
36 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
37         FREE((void*)ptr);
38 }
39 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
40         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
41         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
42         return ret_arr;
43 }
44 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
45         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
46         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
47         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
48         return ret_arr;
49 }
50 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
51         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
52         vec->datalen = (*env)->GetArrayLength(env, bytes);
53         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
54         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
55         return (uint64_t)vec;
56 }
57 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
58         LDKTransaction *txdata = (LDKTransaction*)ptr;
59         LDKu8slice slice;
60         slice.data = txdata->data;
61         slice.datalen = txdata->datalen;
62         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
63 }
64 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
65         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
66         txdata->datalen = (*env)->GetArrayLength(env, bytes);
67         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
68         txdata->data_is_owned = false;
69         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
70         return (uint64_t)txdata;
71 }
72 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
73         LDKTransaction *tx = (LDKTransaction*)ptr;
74         tx->data_is_owned = true;
75         Transaction_free(*tx);
76         FREE((void*)ptr);
77 }
78 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
79         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
80         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
81         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
82         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
83         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
84         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
85         return (uint64_t)vec->datalen;
86 }
87 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
88         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
89         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
90         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
91         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
92         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
93         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
94         vec->data = NULL;
95         vec->datalen = 0;
96         return (uint64_t)vec;
97 }
98
99 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
100 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
101 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
102 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
103
104 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
105 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
106 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
107
108 typedef jlongArray int64_tArray;
109 typedef jbyteArray int8_tArray;
110
111 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
112         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
113         char* conv_buf = MALLOC(len + 1, "str conv buf");
114         memcpy(conv_buf, chars, len);
115         conv_buf[len] = 0;
116         jstring ret = (*env)->NewStringUTF(env, conv_buf);
117         FREE(conv_buf);
118         return ret;
119 }
120 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
121         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
122         char* newchars = MALLOC(str_len + 1, "String chars");
123         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
124         memcpy(newchars, jchars, str_len);
125         newchars[str_len] = 0;
126         (*env)->ReleaseStringUTFChars(env, str, jchars);
127         LDKStr res = {
128                 .chars = newchars,
129                 .len = str_len,
130                 .chars_is_owned = true
131         };
132         return res;
133 }
134
135 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
136         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
137 }
138 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
139         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
140 }
141 #include "version.c"
142 static jclass arr_of_B_clz = NULL;
143 static jclass arr_of_J_clz = NULL;
144 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
145         arr_of_B_clz = (*env)->FindClass(env, "[B");
146         CHECK(arr_of_B_clz != NULL);
147         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
148         arr_of_J_clz = (*env)->FindClass(env, "[J");
149         CHECK(arr_of_J_clz != NULL);
150         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
151 }
152 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
153 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
154         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
155                 case 0: return LDKAccessError_UnknownChain;
156                 case 1: return LDKAccessError_UnknownTx;
157         }
158         abort();
159 }
160 static jclass AccessError_class = NULL;
161 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
162 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
163 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
164         AccessError_class = (*env)->NewGlobalRef(env, clz);
165         CHECK(AccessError_class != NULL);
166         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
167         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
168         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
169         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
170 }
171 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
172         switch (val) {
173                 case LDKAccessError_UnknownChain:
174                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
175                 case LDKAccessError_UnknownTx:
176                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
177                 default: abort();
178         }
179 }
180
181 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
182         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
183                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
184                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
185         }
186         abort();
187 }
188 static jclass ChannelMonitorUpdateErr_class = NULL;
189 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
190 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
191 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
192         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
193         CHECK(ChannelMonitorUpdateErr_class != NULL);
194         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
195         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
196         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
197         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
198 }
199 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
200         switch (val) {
201                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
202                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
203                 case LDKChannelMonitorUpdateErr_PermanentFailure:
204                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
205                 default: abort();
206         }
207 }
208
209 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
210         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
211                 case 0: return LDKConfirmationTarget_Background;
212                 case 1: return LDKConfirmationTarget_Normal;
213                 case 2: return LDKConfirmationTarget_HighPriority;
214         }
215         abort();
216 }
217 static jclass ConfirmationTarget_class = NULL;
218 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
219 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
220 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
221 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
222         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
223         CHECK(ConfirmationTarget_class != NULL);
224         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
225         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
226         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
227         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
228         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
229         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
230 }
231 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
232         switch (val) {
233                 case LDKConfirmationTarget_Background:
234                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
235                 case LDKConfirmationTarget_Normal:
236                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
237                 case LDKConfirmationTarget_HighPriority:
238                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
239                 default: abort();
240         }
241 }
242
243 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
244         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
245                 case 0: return LDKCreationError_DescriptionTooLong;
246                 case 1: return LDKCreationError_RouteTooLong;
247                 case 2: return LDKCreationError_TimestampOutOfBounds;
248                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
249         }
250         abort();
251 }
252 static jclass CreationError_class = NULL;
253 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
254 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
255 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
256 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
257 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
258         CreationError_class = (*env)->NewGlobalRef(env, clz);
259         CHECK(CreationError_class != NULL);
260         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
261         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
262         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
263         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
264         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
265         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
266         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
267         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
268 }
269 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
270         switch (val) {
271                 case LDKCreationError_DescriptionTooLong:
272                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
273                 case LDKCreationError_RouteTooLong:
274                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
275                 case LDKCreationError_TimestampOutOfBounds:
276                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
277                 case LDKCreationError_ExpiryTimeOutOfBounds:
278                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
279                 default: abort();
280         }
281 }
282
283 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
284         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
285                 case 0: return LDKCurrency_Bitcoin;
286                 case 1: return LDKCurrency_BitcoinTestnet;
287                 case 2: return LDKCurrency_Regtest;
288                 case 3: return LDKCurrency_Simnet;
289                 case 4: return LDKCurrency_Signet;
290         }
291         abort();
292 }
293 static jclass Currency_class = NULL;
294 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
295 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
296 static jfieldID Currency_LDKCurrency_Regtest = NULL;
297 static jfieldID Currency_LDKCurrency_Simnet = NULL;
298 static jfieldID Currency_LDKCurrency_Signet = NULL;
299 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
300         Currency_class = (*env)->NewGlobalRef(env, clz);
301         CHECK(Currency_class != NULL);
302         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
303         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
304         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
305         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
306         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
307         CHECK(Currency_LDKCurrency_Regtest != NULL);
308         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
309         CHECK(Currency_LDKCurrency_Simnet != NULL);
310         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
311         CHECK(Currency_LDKCurrency_Signet != NULL);
312 }
313 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
314         switch (val) {
315                 case LDKCurrency_Bitcoin:
316                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
317                 case LDKCurrency_BitcoinTestnet:
318                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
319                 case LDKCurrency_Regtest:
320                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
321                 case LDKCurrency_Simnet:
322                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
323                 case LDKCurrency_Signet:
324                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
325                 default: abort();
326         }
327 }
328
329 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
330         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
331                 case 0: return LDKIOError_NotFound;
332                 case 1: return LDKIOError_PermissionDenied;
333                 case 2: return LDKIOError_ConnectionRefused;
334                 case 3: return LDKIOError_ConnectionReset;
335                 case 4: return LDKIOError_ConnectionAborted;
336                 case 5: return LDKIOError_NotConnected;
337                 case 6: return LDKIOError_AddrInUse;
338                 case 7: return LDKIOError_AddrNotAvailable;
339                 case 8: return LDKIOError_BrokenPipe;
340                 case 9: return LDKIOError_AlreadyExists;
341                 case 10: return LDKIOError_WouldBlock;
342                 case 11: return LDKIOError_InvalidInput;
343                 case 12: return LDKIOError_InvalidData;
344                 case 13: return LDKIOError_TimedOut;
345                 case 14: return LDKIOError_WriteZero;
346                 case 15: return LDKIOError_Interrupted;
347                 case 16: return LDKIOError_Other;
348                 case 17: return LDKIOError_UnexpectedEof;
349         }
350         abort();
351 }
352 static jclass IOError_class = NULL;
353 static jfieldID IOError_LDKIOError_NotFound = NULL;
354 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
355 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
356 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
357 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
358 static jfieldID IOError_LDKIOError_NotConnected = NULL;
359 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
360 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
361 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
362 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
363 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
364 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
365 static jfieldID IOError_LDKIOError_InvalidData = NULL;
366 static jfieldID IOError_LDKIOError_TimedOut = NULL;
367 static jfieldID IOError_LDKIOError_WriteZero = NULL;
368 static jfieldID IOError_LDKIOError_Interrupted = NULL;
369 static jfieldID IOError_LDKIOError_Other = NULL;
370 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
371 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
372         IOError_class = (*env)->NewGlobalRef(env, clz);
373         CHECK(IOError_class != NULL);
374         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
375         CHECK(IOError_LDKIOError_NotFound != NULL);
376         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
377         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
378         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
379         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
380         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
381         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
382         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
383         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
384         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
385         CHECK(IOError_LDKIOError_NotConnected != NULL);
386         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
387         CHECK(IOError_LDKIOError_AddrInUse != NULL);
388         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
389         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
390         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
391         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
392         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
393         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
394         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
395         CHECK(IOError_LDKIOError_WouldBlock != NULL);
396         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
397         CHECK(IOError_LDKIOError_InvalidInput != NULL);
398         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
399         CHECK(IOError_LDKIOError_InvalidData != NULL);
400         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
401         CHECK(IOError_LDKIOError_TimedOut != NULL);
402         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
403         CHECK(IOError_LDKIOError_WriteZero != NULL);
404         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
405         CHECK(IOError_LDKIOError_Interrupted != NULL);
406         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
407         CHECK(IOError_LDKIOError_Other != NULL);
408         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
409         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
410 }
411 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
412         switch (val) {
413                 case LDKIOError_NotFound:
414                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
415                 case LDKIOError_PermissionDenied:
416                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
417                 case LDKIOError_ConnectionRefused:
418                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
419                 case LDKIOError_ConnectionReset:
420                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
421                 case LDKIOError_ConnectionAborted:
422                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
423                 case LDKIOError_NotConnected:
424                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
425                 case LDKIOError_AddrInUse:
426                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
427                 case LDKIOError_AddrNotAvailable:
428                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
429                 case LDKIOError_BrokenPipe:
430                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
431                 case LDKIOError_AlreadyExists:
432                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
433                 case LDKIOError_WouldBlock:
434                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
435                 case LDKIOError_InvalidInput:
436                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
437                 case LDKIOError_InvalidData:
438                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
439                 case LDKIOError_TimedOut:
440                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
441                 case LDKIOError_WriteZero:
442                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
443                 case LDKIOError_Interrupted:
444                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
445                 case LDKIOError_Other:
446                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
447                 case LDKIOError_UnexpectedEof:
448                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
449                 default: abort();
450         }
451 }
452
453 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
454         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
455                 case 0: return LDKLevel_Trace;
456                 case 1: return LDKLevel_Debug;
457                 case 2: return LDKLevel_Info;
458                 case 3: return LDKLevel_Warn;
459                 case 4: return LDKLevel_Error;
460         }
461         abort();
462 }
463 static jclass Level_class = NULL;
464 static jfieldID Level_LDKLevel_Trace = NULL;
465 static jfieldID Level_LDKLevel_Debug = NULL;
466 static jfieldID Level_LDKLevel_Info = NULL;
467 static jfieldID Level_LDKLevel_Warn = NULL;
468 static jfieldID Level_LDKLevel_Error = NULL;
469 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
470         Level_class = (*env)->NewGlobalRef(env, clz);
471         CHECK(Level_class != NULL);
472         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
473         CHECK(Level_LDKLevel_Trace != NULL);
474         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
475         CHECK(Level_LDKLevel_Debug != NULL);
476         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
477         CHECK(Level_LDKLevel_Info != NULL);
478         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
479         CHECK(Level_LDKLevel_Warn != NULL);
480         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
481         CHECK(Level_LDKLevel_Error != NULL);
482 }
483 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
484         switch (val) {
485                 case LDKLevel_Trace:
486                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
487                 case LDKLevel_Debug:
488                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
489                 case LDKLevel_Info:
490                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
491                 case LDKLevel_Warn:
492                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
493                 case LDKLevel_Error:
494                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
495                 default: abort();
496         }
497 }
498
499 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
500         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
501                 case 0: return LDKNetwork_Bitcoin;
502                 case 1: return LDKNetwork_Testnet;
503                 case 2: return LDKNetwork_Regtest;
504                 case 3: return LDKNetwork_Signet;
505         }
506         abort();
507 }
508 static jclass Network_class = NULL;
509 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
510 static jfieldID Network_LDKNetwork_Testnet = NULL;
511 static jfieldID Network_LDKNetwork_Regtest = NULL;
512 static jfieldID Network_LDKNetwork_Signet = NULL;
513 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
514         Network_class = (*env)->NewGlobalRef(env, clz);
515         CHECK(Network_class != NULL);
516         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
517         CHECK(Network_LDKNetwork_Bitcoin != NULL);
518         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
519         CHECK(Network_LDKNetwork_Testnet != NULL);
520         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
521         CHECK(Network_LDKNetwork_Regtest != NULL);
522         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
523         CHECK(Network_LDKNetwork_Signet != NULL);
524 }
525 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
526         switch (val) {
527                 case LDKNetwork_Bitcoin:
528                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
529                 case LDKNetwork_Testnet:
530                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
531                 case LDKNetwork_Regtest:
532                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
533                 case LDKNetwork_Signet:
534                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
535                 default: abort();
536         }
537 }
538
539 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
540         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
541                 case 0: return LDKSecp256k1Error_IncorrectSignature;
542                 case 1: return LDKSecp256k1Error_InvalidMessage;
543                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
544                 case 3: return LDKSecp256k1Error_InvalidSignature;
545                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
546                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
547                 case 6: return LDKSecp256k1Error_InvalidTweak;
548                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
549                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
550         }
551         abort();
552 }
553 static jclass Secp256k1Error_class = NULL;
554 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
555 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
556 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
563 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
564         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
565         CHECK(Secp256k1Error_class != NULL);
566         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
567         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
568         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
569         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
570         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
571         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
572         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
573         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
574         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
575         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
576         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
577         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
578         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
579         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
580         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
581         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
582         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
583         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
584 }
585 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
586         switch (val) {
587                 case LDKSecp256k1Error_IncorrectSignature:
588                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
589                 case LDKSecp256k1Error_InvalidMessage:
590                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
591                 case LDKSecp256k1Error_InvalidPublicKey:
592                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
593                 case LDKSecp256k1Error_InvalidSignature:
594                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
595                 case LDKSecp256k1Error_InvalidSecretKey:
596                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
597                 case LDKSecp256k1Error_InvalidRecoveryId:
598                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
599                 case LDKSecp256k1Error_InvalidTweak:
600                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
601                 case LDKSecp256k1Error_TweakCheckFailed:
602                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
603                 case LDKSecp256k1Error_NotEnoughMemory:
604                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
605                 default: abort();
606         }
607 }
608
609 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
610         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
611                 case 0: return LDKSemanticError_NoPaymentHash;
612                 case 1: return LDKSemanticError_MultiplePaymentHashes;
613                 case 2: return LDKSemanticError_NoDescription;
614                 case 3: return LDKSemanticError_MultipleDescriptions;
615                 case 4: return LDKSemanticError_NoPaymentSecret;
616                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
617                 case 6: return LDKSemanticError_InvalidFeatures;
618                 case 7: return LDKSemanticError_InvalidRecoveryId;
619                 case 8: return LDKSemanticError_InvalidSignature;
620                 case 9: return LDKSemanticError_ImpreciseAmount;
621         }
622         abort();
623 }
624 static jclass SemanticError_class = NULL;
625 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
626 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
627 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
628 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
629 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
630 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
631 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
632 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
633 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
634 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
635 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
636         SemanticError_class = (*env)->NewGlobalRef(env, clz);
637         CHECK(SemanticError_class != NULL);
638         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
639         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
640         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
641         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
642         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
643         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
644         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
645         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
646         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
647         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
648         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
649         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
650         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
651         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
652         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
653         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
654         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
655         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
656         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
657         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
658 }
659 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
660         switch (val) {
661                 case LDKSemanticError_NoPaymentHash:
662                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
663                 case LDKSemanticError_MultiplePaymentHashes:
664                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
665                 case LDKSemanticError_NoDescription:
666                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
667                 case LDKSemanticError_MultipleDescriptions:
668                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
669                 case LDKSemanticError_NoPaymentSecret:
670                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
671                 case LDKSemanticError_MultiplePaymentSecrets:
672                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
673                 case LDKSemanticError_InvalidFeatures:
674                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
675                 case LDKSemanticError_InvalidRecoveryId:
676                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
677                 case LDKSemanticError_InvalidSignature:
678                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
679                 case LDKSemanticError_ImpreciseAmount:
680                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
681                 default: abort();
682         }
683 }
684
685 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
686         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
687                 case 0: return LDKSiPrefix_Milli;
688                 case 1: return LDKSiPrefix_Micro;
689                 case 2: return LDKSiPrefix_Nano;
690                 case 3: return LDKSiPrefix_Pico;
691         }
692         abort();
693 }
694 static jclass SiPrefix_class = NULL;
695 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
696 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
697 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
698 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
699 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
700         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
701         CHECK(SiPrefix_class != NULL);
702         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
703         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
704         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
705         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
706         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
707         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
708         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
709         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
710 }
711 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
712         switch (val) {
713                 case LDKSiPrefix_Milli:
714                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
715                 case LDKSiPrefix_Micro:
716                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
717                 case LDKSiPrefix_Nano:
718                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
719                 case LDKSiPrefix_Pico:
720                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
721                 default: abort();
722         }
723 }
724
725 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
726         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
727         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
728         return ret;
729 }
730 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) {
731         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
732         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
735         CVec_u8Z_free(ret_var);
736         return ret_arr;
737 }
738
739 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) {
740         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
741         int64_t ret_val = TxOut_get_value(thing_conv);
742         return ret_val;
743 }
744
745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
746         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
747         CHECK(val->result_ok);
748         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
749         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
750         return res_arr;
751 }
752 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
753         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
754         CHECK(!val->result_ok);
755         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
756         return err_conv;
757 }
758 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
759         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
760         CHECK(val->result_ok);
761         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
762         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
763         return res_arr;
764 }
765 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
766         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
767         CHECK(!val->result_ok);
768         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
769         return err_conv;
770 }
771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
772         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
773         CHECK(val->result_ok);
774         LDKTxCreationKeys res_var = (*val->contents.result);
775         uint64_t res_ref = 0;
776         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
777         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
778         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
779         res_ref = (uint64_t)res_var.inner & ~1;
780         return res_ref;
781 }
782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
783         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
784         CHECK(!val->result_ok);
785         LDKDecodeError err_var = (*val->contents.err);
786         uint64_t err_ref = 0;
787         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
788         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
789         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
790         err_ref = (uint64_t)err_var.inner & ~1;
791         return err_ref;
792 }
793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
794         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
795         CHECK(val->result_ok);
796         LDKChannelPublicKeys res_var = (*val->contents.result);
797         uint64_t res_ref = 0;
798         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
799         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
800         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
801         res_ref = (uint64_t)res_var.inner & ~1;
802         return res_ref;
803 }
804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
805         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
806         CHECK(!val->result_ok);
807         LDKDecodeError err_var = (*val->contents.err);
808         uint64_t err_ref = 0;
809         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
810         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
811         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
812         err_ref = (uint64_t)err_var.inner & ~1;
813         return err_ref;
814 }
815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
816         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
817         CHECK(val->result_ok);
818         LDKTxCreationKeys res_var = (*val->contents.result);
819         uint64_t res_ref = 0;
820         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
821         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
822         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
823         res_ref = (uint64_t)res_var.inner & ~1;
824         return res_ref;
825 }
826 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
827         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
828         CHECK(!val->result_ok);
829         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
830         return err_conv;
831 }
832 static jclass LDKCOption_u32Z_Some_class = NULL;
833 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
834 static jclass LDKCOption_u32Z_None_class = NULL;
835 static jmethodID LDKCOption_u32Z_None_meth = NULL;
836 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
837         LDKCOption_u32Z_Some_class =
838                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
839         CHECK(LDKCOption_u32Z_Some_class != NULL);
840         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
841         CHECK(LDKCOption_u32Z_Some_meth != NULL);
842         LDKCOption_u32Z_None_class =
843                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
844         CHECK(LDKCOption_u32Z_None_class != NULL);
845         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
846         CHECK(LDKCOption_u32Z_None_meth != NULL);
847 }
848 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
849         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
850         switch(obj->tag) {
851                 case LDKCOption_u32Z_Some: {
852                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
853                 }
854                 case LDKCOption_u32Z_None: {
855                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
856                 }
857                 default: abort();
858         }
859 }
860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
861         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
862         CHECK(val->result_ok);
863         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
864         uint64_t res_ref = 0;
865         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
866         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
867         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
868         res_ref = (uint64_t)res_var.inner & ~1;
869         return res_ref;
870 }
871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
872         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
873         CHECK(!val->result_ok);
874         LDKDecodeError err_var = (*val->contents.err);
875         uint64_t err_ref = 0;
876         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
877         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
878         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
879         err_ref = (uint64_t)err_var.inner & ~1;
880         return err_ref;
881 }
882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
883         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
884         CHECK(val->result_ok);
885         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
886         uint64_t res_ref = 0;
887         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
888         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
889         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
890         res_ref = (uint64_t)res_var.inner & ~1;
891         return res_ref;
892 }
893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
894         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
895         CHECK(!val->result_ok);
896         LDKDecodeError err_var = (*val->contents.err);
897         uint64_t err_ref = 0;
898         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
899         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
900         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
901         err_ref = (uint64_t)err_var.inner & ~1;
902         return err_ref;
903 }
904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
905         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
906         CHECK(val->result_ok);
907         LDKChannelTransactionParameters res_var = (*val->contents.result);
908         uint64_t res_ref = 0;
909         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
910         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
911         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
912         res_ref = (uint64_t)res_var.inner & ~1;
913         return res_ref;
914 }
915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
916         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
917         CHECK(!val->result_ok);
918         LDKDecodeError err_var = (*val->contents.err);
919         uint64_t err_ref = 0;
920         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
921         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
922         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
923         err_ref = (uint64_t)err_var.inner & ~1;
924         return err_ref;
925 }
926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
927         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
928         CHECK(val->result_ok);
929         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
930         uint64_t res_ref = 0;
931         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
932         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
933         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
934         res_ref = (uint64_t)res_var.inner & ~1;
935         return res_ref;
936 }
937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
938         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
939         CHECK(!val->result_ok);
940         LDKDecodeError err_var = (*val->contents.err);
941         uint64_t err_ref = 0;
942         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
943         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
944         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
945         err_ref = (uint64_t)err_var.inner & ~1;
946         return err_ref;
947 }
948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
949         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
950         CHECK(val->result_ok);
951         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
952         uint64_t res_ref = 0;
953         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
954         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
955         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
956         res_ref = (uint64_t)res_var.inner & ~1;
957         return res_ref;
958 }
959 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
960         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
961         CHECK(!val->result_ok);
962         LDKDecodeError err_var = (*val->contents.err);
963         uint64_t err_ref = 0;
964         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
965         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
966         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
967         err_ref = (uint64_t)err_var.inner & ~1;
968         return err_ref;
969 }
970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
971         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
972         CHECK(val->result_ok);
973         LDKTrustedClosingTransaction res_var = (*val->contents.result);
974         uint64_t res_ref = 0;
975         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
976         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
977         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
978         res_ref = (uint64_t)res_var.inner & ~1;
979         return res_ref;
980 }
981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
982         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
983         CHECK(!val->result_ok);
984         return *val->contents.err;
985 }
986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
987         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
988         CHECK(val->result_ok);
989         LDKCommitmentTransaction res_var = (*val->contents.result);
990         uint64_t res_ref = 0;
991         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
992         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
993         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
994         res_ref = (uint64_t)res_var.inner & ~1;
995         return res_ref;
996 }
997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
998         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
999         CHECK(!val->result_ok);
1000         LDKDecodeError err_var = (*val->contents.err);
1001         uint64_t err_ref = 0;
1002         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1003         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1004         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1005         err_ref = (uint64_t)err_var.inner & ~1;
1006         return err_ref;
1007 }
1008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1009         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1010         CHECK(val->result_ok);
1011         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1012         uint64_t res_ref = 0;
1013         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1014         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1015         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1016         res_ref = (uint64_t)res_var.inner & ~1;
1017         return res_ref;
1018 }
1019 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1020         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1021         CHECK(!val->result_ok);
1022         return *val->contents.err;
1023 }
1024 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1025         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1026         CHECK(val->result_ok);
1027         LDKCVec_SignatureZ res_var = (*val->contents.result);
1028         jobjectArray res_arr = NULL;
1029         res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1030         ;
1031         for (size_t i = 0; i < res_var.datalen; i++) {
1032                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1033                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1034                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1035         }
1036         
1037         return res_arr;
1038 }
1039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1040         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1041         CHECK(!val->result_ok);
1042         return *val->contents.err;
1043 }
1044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1045         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1046         CHECK(val->result_ok);
1047         LDKShutdownScript res_var = (*val->contents.result);
1048         uint64_t res_ref = 0;
1049         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1050         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1051         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1052         res_ref = (uint64_t)res_var.inner & ~1;
1053         return res_ref;
1054 }
1055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1056         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1057         CHECK(!val->result_ok);
1058         LDKDecodeError err_var = (*val->contents.err);
1059         uint64_t err_ref = 0;
1060         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1061         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1062         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1063         err_ref = (uint64_t)err_var.inner & ~1;
1064         return err_ref;
1065 }
1066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1067         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1068         CHECK(val->result_ok);
1069         LDKShutdownScript res_var = (*val->contents.result);
1070         uint64_t res_ref = 0;
1071         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1072         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1073         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1074         res_ref = (uint64_t)res_var.inner & ~1;
1075         return res_ref;
1076 }
1077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1078         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1079         CHECK(!val->result_ok);
1080         LDKInvalidShutdownScript err_var = (*val->contents.err);
1081         uint64_t err_ref = 0;
1082         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1083         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1084         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1085         err_ref = (uint64_t)err_var.inner & ~1;
1086         return err_ref;
1087 }
1088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1089         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1090         CHECK(val->result_ok);
1091         return *val->contents.result;
1092 }
1093 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1094         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1095         CHECK(!val->result_ok);
1096         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1097         return err_conv;
1098 }
1099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1100         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1101         CHECK(val->result_ok);
1102         LDKRouteHop res_var = (*val->contents.result);
1103         uint64_t res_ref = 0;
1104         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1105         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1106         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1107         res_ref = (uint64_t)res_var.inner & ~1;
1108         return res_ref;
1109 }
1110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1111         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1112         CHECK(!val->result_ok);
1113         LDKDecodeError err_var = (*val->contents.err);
1114         uint64_t err_ref = 0;
1115         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1116         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1117         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1118         err_ref = (uint64_t)err_var.inner & ~1;
1119         return err_ref;
1120 }
1121 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1122         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1123         for (size_t i = 0; i < ret.datalen; i++) {
1124                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1125         }
1126         return ret;
1127 }
1128 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1129         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1130         for (size_t i = 0; i < ret.datalen; i++) {
1131                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1132         }
1133         return ret;
1134 }
1135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1136         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1137         CHECK(val->result_ok);
1138         LDKRoute res_var = (*val->contents.result);
1139         uint64_t res_ref = 0;
1140         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1141         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1142         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1143         res_ref = (uint64_t)res_var.inner & ~1;
1144         return res_ref;
1145 }
1146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1147         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1148         CHECK(!val->result_ok);
1149         LDKDecodeError err_var = (*val->contents.err);
1150         uint64_t err_ref = 0;
1151         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1152         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1153         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1154         err_ref = (uint64_t)err_var.inner & ~1;
1155         return err_ref;
1156 }
1157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1158         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
1159         CHECK(val->result_ok);
1160         LDKRouteParameters res_var = (*val->contents.result);
1161         uint64_t res_ref = 0;
1162         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1163         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1164         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1165         res_ref = (uint64_t)res_var.inner & ~1;
1166         return res_ref;
1167 }
1168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1169         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
1170         CHECK(!val->result_ok);
1171         LDKDecodeError err_var = (*val->contents.err);
1172         uint64_t err_ref = 0;
1173         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1174         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1175         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1176         err_ref = (uint64_t)err_var.inner & ~1;
1177         return err_ref;
1178 }
1179 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1180         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1181         for (size_t i = 0; i < ret.datalen; i++) {
1182                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1183         }
1184         return ret;
1185 }
1186 static jclass LDKCOption_u64Z_Some_class = NULL;
1187 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1188 static jclass LDKCOption_u64Z_None_class = NULL;
1189 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1191         LDKCOption_u64Z_Some_class =
1192                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1193         CHECK(LDKCOption_u64Z_Some_class != NULL);
1194         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1195         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1196         LDKCOption_u64Z_None_class =
1197                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1198         CHECK(LDKCOption_u64Z_None_class != NULL);
1199         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1200         CHECK(LDKCOption_u64Z_None_meth != NULL);
1201 }
1202 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1203         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1204         switch(obj->tag) {
1205                 case LDKCOption_u64Z_Some: {
1206                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1207                 }
1208                 case LDKCOption_u64Z_None: {
1209                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1210                 }
1211                 default: abort();
1212         }
1213 }
1214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1215         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
1216         CHECK(val->result_ok);
1217         LDKPayee res_var = (*val->contents.result);
1218         uint64_t res_ref = 0;
1219         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1220         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1221         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1222         res_ref = (uint64_t)res_var.inner & ~1;
1223         return res_ref;
1224 }
1225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1226         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
1227         CHECK(!val->result_ok);
1228         LDKDecodeError err_var = (*val->contents.err);
1229         uint64_t err_ref = 0;
1230         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1231         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1232         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1233         err_ref = (uint64_t)err_var.inner & ~1;
1234         return err_ref;
1235 }
1236 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1237         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1238         for (size_t i = 0; i < ret.datalen; i++) {
1239                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1240         }
1241         return ret;
1242 }
1243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1244         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
1245         CHECK(val->result_ok);
1246         LDKRouteHint res_var = (*val->contents.result);
1247         uint64_t res_ref = 0;
1248         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1249         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1250         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1251         res_ref = (uint64_t)res_var.inner & ~1;
1252         return res_ref;
1253 }
1254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1255         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
1256         CHECK(!val->result_ok);
1257         LDKDecodeError err_var = (*val->contents.err);
1258         uint64_t err_ref = 0;
1259         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1260         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1261         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1262         err_ref = (uint64_t)err_var.inner & ~1;
1263         return err_ref;
1264 }
1265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1266         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
1267         CHECK(val->result_ok);
1268         LDKRouteHintHop res_var = (*val->contents.result);
1269         uint64_t res_ref = 0;
1270         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1271         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1272         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1273         res_ref = (uint64_t)res_var.inner & ~1;
1274         return res_ref;
1275 }
1276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1277         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
1278         CHECK(!val->result_ok);
1279         LDKDecodeError err_var = (*val->contents.err);
1280         uint64_t err_ref = 0;
1281         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1282         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1283         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1284         err_ref = (uint64_t)err_var.inner & ~1;
1285         return err_ref;
1286 }
1287 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1288         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1289         for (size_t i = 0; i < ret.datalen; i++) {
1290                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1291         }
1292         return ret;
1293 }
1294 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1295         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1296         CHECK(val->result_ok);
1297         LDKRoute res_var = (*val->contents.result);
1298         uint64_t res_ref = 0;
1299         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1300         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1301         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1302         res_ref = (uint64_t)res_var.inner & ~1;
1303         return res_ref;
1304 }
1305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1306         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1307         CHECK(!val->result_ok);
1308         LDKLightningError err_var = (*val->contents.err);
1309         uint64_t err_ref = 0;
1310         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1311         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1312         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1313         err_ref = (uint64_t)err_var.inner & ~1;
1314         return err_ref;
1315 }
1316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1317         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1318         CHECK(val->result_ok);
1319         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1320         return (uint64_t)res_ref;
1321 }
1322 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1323         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1324         CHECK(!val->result_ok);
1325         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1326         return err_conv;
1327 }
1328 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1329         return tuple->a;
1330 }
1331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
1332         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1333         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
1334         return ret_val;
1335 }
1336
1337 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1338         return tuple->b;
1339 }
1340 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
1341         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1342         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
1343         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1344         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1345         Transaction_free(ret_var);
1346         return ret_arr;
1347 }
1348
1349 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1350         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1351         for (size_t i = 0; i < ret.datalen; i++) {
1352                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1353         }
1354         return ret;
1355 }
1356 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1357         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1358         for (size_t i = 0; i < ret.datalen; i++) {
1359                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1360         }
1361         return ret;
1362 }
1363 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1364         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1365         CHECK(val->result_ok);
1366         return *val->contents.result;
1367 }
1368 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1369         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1370         CHECK(!val->result_ok);
1371         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1372         return err_conv;
1373 }
1374 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1375 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1376 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1377 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1378 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1379 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1380 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1381 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1382 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1383         LDKMonitorEvent_HTLCEvent_class =
1384                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1385         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1386         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1387         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1388         LDKMonitorEvent_CommitmentTxConfirmed_class =
1389                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed;"));
1390         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1391         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1392         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1393         LDKMonitorEvent_UpdateCompleted_class =
1394                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted;"));
1395         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1396         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1397         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1398         LDKMonitorEvent_UpdateFailed_class =
1399                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed;"));
1400         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1401         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
1402         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
1403 }
1404 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1405         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1406         switch(obj->tag) {
1407                 case LDKMonitorEvent_HTLCEvent: {
1408                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1409                         uint64_t htlc_event_ref = 0;
1410                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1411                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1412                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1413                         htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1414                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1415                 }
1416                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1417                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1418                         uint64_t commitment_tx_confirmed_ref = 0;
1419                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1420                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1421                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1422                         commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
1423                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1424                 }
1425                 case LDKMonitorEvent_UpdateCompleted: {
1426                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1427                         uint64_t funding_txo_ref = 0;
1428                         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1429                         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1430                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1431                         funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
1432                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
1433                 }
1434                 case LDKMonitorEvent_UpdateFailed: {
1435                         LDKOutPoint update_failed_var = obj->update_failed;
1436                         uint64_t update_failed_ref = 0;
1437                         CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1438                         CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1439                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1440                         update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
1441                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
1442                 }
1443                 default: abort();
1444         }
1445 }
1446 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1447         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1448         for (size_t i = 0; i < ret.datalen; i++) {
1449                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1450         }
1451         return ret;
1452 }
1453 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1454 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1455 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1456 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1458         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1459                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1460         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1461         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1462         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1463         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1464                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1465         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1466         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1467         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1468 }
1469 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1470         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1471         switch(obj->tag) {
1472                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1473                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1474                         *some_conv = obj->some;
1475                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1476                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((uint64_t)some_conv));
1477                 }
1478                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1479                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1480                 }
1481                 default: abort();
1482         }
1483 }
1484 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1485 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1486 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1487 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1488 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1489 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1490 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1491 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1492 static jclass LDKClosureReason_ProcessingError_class = NULL;
1493 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1494 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1495 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1496 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1497 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1499         LDKClosureReason_CounterpartyForceClosed_class =
1500                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;"));
1501         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1502         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
1503         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
1504         LDKClosureReason_HolderForceClosed_class =
1505                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;"));
1506         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
1507         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
1508         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
1509         LDKClosureReason_CooperativeClosure_class =
1510                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;"));
1511         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
1512         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
1513         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
1514         LDKClosureReason_CommitmentTxConfirmed_class =
1515                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;"));
1516         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
1517         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
1518         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
1519         LDKClosureReason_ProcessingError_class =
1520                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;"));
1521         CHECK(LDKClosureReason_ProcessingError_class != NULL);
1522         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
1523         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
1524         LDKClosureReason_DisconnectedPeer_class =
1525                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;"));
1526         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
1527         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
1528         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
1529         LDKClosureReason_OutdatedChannelManager_class =
1530                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;"));
1531         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
1532         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
1533         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
1534 }
1535 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1536         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1537         switch(obj->tag) {
1538                 case LDKClosureReason_CounterpartyForceClosed: {
1539                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1540                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
1541                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
1542                 }
1543                 case LDKClosureReason_HolderForceClosed: {
1544                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
1545                 }
1546                 case LDKClosureReason_CooperativeClosure: {
1547                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
1548                 }
1549                 case LDKClosureReason_CommitmentTxConfirmed: {
1550                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
1551                 }
1552                 case LDKClosureReason_ProcessingError: {
1553                         LDKStr err_str = obj->processing_error.err;
1554                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1555                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
1556                 }
1557                 case LDKClosureReason_DisconnectedPeer: {
1558                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
1559                 }
1560                 case LDKClosureReason_OutdatedChannelManager: {
1561                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
1562                 }
1563                 default: abort();
1564         }
1565 }
1566 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
1567 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
1568 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
1569 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
1570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
1571         LDKCOption_ClosureReasonZ_Some_class =
1572                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some;"));
1573         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
1574         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
1575         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
1576         LDKCOption_ClosureReasonZ_None_class =
1577                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None;"));
1578         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
1579         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
1580         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
1581 }
1582 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1583         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1584         switch(obj->tag) {
1585                 case LDKCOption_ClosureReasonZ_Some: {
1586                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1587                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
1588                 }
1589                 case LDKCOption_ClosureReasonZ_None: {
1590                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
1591                 }
1592                 default: abort();
1593         }
1594 }
1595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1596         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1597         CHECK(val->result_ok);
1598         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1599         return res_ref;
1600 }
1601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1602         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1603         CHECK(!val->result_ok);
1604         LDKDecodeError err_var = (*val->contents.err);
1605         uint64_t err_ref = 0;
1606         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1607         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1608         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1609         err_ref = (uint64_t)err_var.inner & ~1;
1610         return err_ref;
1611 }
1612 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
1613 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
1614 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
1615 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
1616 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
1617 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
1618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
1619         LDKNetworkUpdate_ChannelUpdateMessage_class =
1620                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage;"));
1621         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
1622         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1623         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
1624         LDKNetworkUpdate_ChannelClosed_class =
1625                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed;"));
1626         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
1627         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1628         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
1629         LDKNetworkUpdate_NodeFailure_class =
1630                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure;"));
1631         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
1632         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
1633         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
1634 }
1635 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1636         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1637         switch(obj->tag) {
1638                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1639                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1640                         uint64_t msg_ref = 0;
1641                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1642                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1643                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1644                         msg_ref = (uint64_t)msg_var.inner & ~1;
1645                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
1646                 }
1647                 case LDKNetworkUpdate_ChannelClosed: {
1648                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1649                 }
1650                 case LDKNetworkUpdate_NodeFailure: {
1651                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1652                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1653                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1654                 }
1655                 default: abort();
1656         }
1657 }
1658 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
1659 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
1660 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
1661 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
1662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
1663         LDKCOption_NetworkUpdateZ_Some_class =
1664                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some;"));
1665         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
1666         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
1667         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
1668         LDKCOption_NetworkUpdateZ_None_class =
1669                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None;"));
1670         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
1671         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
1672         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
1673 }
1674 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1675         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1676         switch(obj->tag) {
1677                 case LDKCOption_NetworkUpdateZ_Some: {
1678                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1679                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
1680                 }
1681                 case LDKCOption_NetworkUpdateZ_None: {
1682                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
1683                 }
1684                 default: abort();
1685         }
1686 }
1687 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1688 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1689 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1690 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1691 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1692 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1694         LDKSpendableOutputDescriptor_StaticOutput_class =
1695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1696         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1697         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1698         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1699         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1700                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1701         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1702         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1703         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1704         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1705                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1706         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1707         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1708         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1709 }
1710 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1711         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1712         switch(obj->tag) {
1713                 case LDKSpendableOutputDescriptor_StaticOutput: {
1714                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1715                         uint64_t outpoint_ref = 0;
1716                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1717                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1718                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1719                         outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1720                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1721                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1722                 }
1723                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1724                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1725                         uint64_t delayed_payment_output_ref = 0;
1726                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1727                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1728                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1729                         delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1730                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1731                 }
1732                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1733                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1734                         uint64_t static_payment_output_ref = 0;
1735                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1736                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1737                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1738                         static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1739                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1740                 }
1741                 default: abort();
1742         }
1743 }
1744 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1745         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1746         for (size_t i = 0; i < ret.datalen; i++) {
1747                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1748         }
1749         return ret;
1750 }
1751 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1752 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1753 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1754 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1756         LDKPaymentPurpose_InvoicePayment_class =
1757                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
1758         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1759         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
1760         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1761         LDKPaymentPurpose_SpontaneousPayment_class =
1762                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
1763         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1764         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1765         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1766 }
1767 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1768         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1769         switch(obj->tag) {
1770                 case LDKPaymentPurpose_InvoicePayment: {
1771                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1772                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1773                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1774                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1775                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
1776                 }
1777                 case LDKPaymentPurpose_SpontaneousPayment: {
1778                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1779                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1780                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1781                 }
1782                 default: abort();
1783         }
1784 }
1785 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1786 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1787 static jclass LDKEvent_PaymentReceived_class = NULL;
1788 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1789 static jclass LDKEvent_PaymentSent_class = NULL;
1790 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1791 static jclass LDKEvent_PaymentPathFailed_class = NULL;
1792 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
1793 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1794 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1795 static jclass LDKEvent_SpendableOutputs_class = NULL;
1796 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1797 static jclass LDKEvent_PaymentForwarded_class = NULL;
1798 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
1799 static jclass LDKEvent_ChannelClosed_class = NULL;
1800 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
1801 static jclass LDKEvent_DiscardFunding_class = NULL;
1802 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
1803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1804         LDKEvent_FundingGenerationReady_class =
1805                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
1806         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1807         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1808         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1809         LDKEvent_PaymentReceived_class =
1810                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
1811         CHECK(LDKEvent_PaymentReceived_class != NULL);
1812         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
1813         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1814         LDKEvent_PaymentSent_class =
1815                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
1816         CHECK(LDKEvent_PaymentSent_class != NULL);
1817         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
1818         CHECK(LDKEvent_PaymentSent_meth != NULL);
1819         LDKEvent_PaymentPathFailed_class =
1820                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;"));
1821         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
1822         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
1823         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
1824         LDKEvent_PendingHTLCsForwardable_class =
1825                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
1826         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1827         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1828         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1829         LDKEvent_SpendableOutputs_class =
1830                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
1831         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1832         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1833         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1834         LDKEvent_PaymentForwarded_class =
1835                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
1836         CHECK(LDKEvent_PaymentForwarded_class != NULL);
1837         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
1838         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
1839         LDKEvent_ChannelClosed_class =
1840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;"));
1841         CHECK(LDKEvent_ChannelClosed_class != NULL);
1842         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
1843         CHECK(LDKEvent_ChannelClosed_meth != NULL);
1844         LDKEvent_DiscardFunding_class =
1845                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$DiscardFunding;"));
1846         CHECK(LDKEvent_DiscardFunding_class != NULL);
1847         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
1848         CHECK(LDKEvent_DiscardFunding_meth != NULL);
1849 }
1850 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1851         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1852         switch(obj->tag) {
1853                 case LDKEvent_FundingGenerationReady: {
1854                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1855                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1856                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1857                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1858                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
1859                         return (*env)->NewObject(env, LDKEvent_FundingGenerationReady_class, LDKEvent_FundingGenerationReady_meth, temporary_channel_id_arr, obj->funding_generation_ready.channel_value_satoshis, output_script_arr, obj->funding_generation_ready.user_channel_id);
1860                 }
1861                 case LDKEvent_PaymentReceived: {
1862                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1863                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
1864                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
1865                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
1866                 }
1867                 case LDKEvent_PaymentSent: {
1868                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
1869                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
1870                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1871                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
1872                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1873                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
1874                         uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
1875                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
1876                 }
1877                 case LDKEvent_PaymentPathFailed: {
1878                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
1879                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
1880                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1881                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
1882                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
1883                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1884                         int64_tArray path_arr = NULL;
1885                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1886                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1887                         for (size_t k = 0; k < path_var.datalen; k++) {
1888                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1889                                 uint64_t path_conv_10_ref = 0;
1890                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1891                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1892                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1893                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
1894                                 path_arr_ptr[k] = path_conv_10_ref;
1895                         }
1896                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1897                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
1898                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1899                         uint64_t retry_ref = 0;
1900                         if ((uint64_t)retry_var.inner > 4096) {
1901                                 CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1902                                 CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1903                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1904                                 retry_ref = (uint64_t)retry_var.inner & ~1;
1905                         }
1906                         return (*env)->NewObject(env, LDKEvent_PaymentPathFailed_class, LDKEvent_PaymentPathFailed_meth, payment_id_arr, payment_hash_arr, obj->payment_path_failed.rejected_by_dest, network_update_ref, obj->payment_path_failed.all_paths_failed, path_arr, short_channel_id_ref, retry_ref);
1907                 }
1908                 case LDKEvent_PendingHTLCsForwardable: {
1909                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
1910                 }
1911                 case LDKEvent_SpendableOutputs: {
1912                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1913                         int64_tArray outputs_arr = NULL;
1914                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
1915                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
1916                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1917                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
1918                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1919                         }
1920                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
1921                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
1922                 }
1923                 case LDKEvent_PaymentForwarded: {
1924                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1925                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
1926                 }
1927                 case LDKEvent_ChannelClosed: {
1928                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
1929                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
1930                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
1931                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
1932                 }
1933                 case LDKEvent_DiscardFunding: {
1934                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
1935                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
1936                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1937                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
1938                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
1939                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
1940                 }
1941                 default: abort();
1942         }
1943 }
1944 static jclass LDKCOption_EventZ_Some_class = NULL;
1945 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
1946 static jclass LDKCOption_EventZ_None_class = NULL;
1947 static jmethodID LDKCOption_EventZ_None_meth = NULL;
1948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
1949         LDKCOption_EventZ_Some_class =
1950                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_EventZ$Some;"));
1951         CHECK(LDKCOption_EventZ_Some_class != NULL);
1952         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
1953         CHECK(LDKCOption_EventZ_Some_meth != NULL);
1954         LDKCOption_EventZ_None_class =
1955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_EventZ$None;"));
1956         CHECK(LDKCOption_EventZ_None_class != NULL);
1957         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
1958         CHECK(LDKCOption_EventZ_None_meth != NULL);
1959 }
1960 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1961         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1962         switch(obj->tag) {
1963                 case LDKCOption_EventZ_Some: {
1964                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1965                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
1966                 }
1967                 case LDKCOption_EventZ_None: {
1968                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
1969                 }
1970                 default: abort();
1971         }
1972 }
1973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1974         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
1975         CHECK(val->result_ok);
1976         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1977         return res_ref;
1978 }
1979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1980         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
1981         CHECK(!val->result_ok);
1982         LDKDecodeError err_var = (*val->contents.err);
1983         uint64_t err_ref = 0;
1984         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1985         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1986         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1987         err_ref = (uint64_t)err_var.inner & ~1;
1988         return err_ref;
1989 }
1990 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1991 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1992 static jclass LDKErrorAction_IgnoreError_class = NULL;
1993 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1994 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1995 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1996 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1997 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
1998 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
1999         LDKErrorAction_DisconnectPeer_class =
2000                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
2001         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2002         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2003         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2004         LDKErrorAction_IgnoreError_class =
2005                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
2006         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2007         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2008         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2009         LDKErrorAction_IgnoreAndLog_class =
2010                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
2011         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2012         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2013         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2014         LDKErrorAction_SendErrorMessage_class =
2015                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
2016         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2017         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2018         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2019 }
2020 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2021         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2022         switch(obj->tag) {
2023                 case LDKErrorAction_DisconnectPeer: {
2024                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2025                         uint64_t msg_ref = 0;
2026                         if ((uint64_t)msg_var.inner > 4096) {
2027                                 CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2028                                 CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2029                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2030                                 msg_ref = (uint64_t)msg_var.inner & ~1;
2031                         }
2032                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2033                 }
2034                 case LDKErrorAction_IgnoreError: {
2035                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2036                 }
2037                 case LDKErrorAction_IgnoreAndLog: {
2038                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2039                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2040                 }
2041                 case LDKErrorAction_SendErrorMessage: {
2042                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2043                         uint64_t msg_ref = 0;
2044                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2045                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2046                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2047                         msg_ref = (uint64_t)msg_var.inner & ~1;
2048                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2049                 }
2050                 default: abort();
2051         }
2052 }
2053 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2054 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2055 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2056 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2057 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2058 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2059 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2060 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2061 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2062 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2063 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2064 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2065 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2066 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2067 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2068 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2069 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2070 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2071 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2072 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2073 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2074 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2075 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2076 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2077 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2078 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2079 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2080 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2081 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2082 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2083 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2084 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2085 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2086 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2087 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2088 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2089 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2090 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2092         LDKMessageSendEvent_SendAcceptChannel_class =
2093                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
2094         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2095         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2096         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2097         LDKMessageSendEvent_SendOpenChannel_class =
2098                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
2099         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2100         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2101         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2102         LDKMessageSendEvent_SendFundingCreated_class =
2103                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
2104         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2105         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2106         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2107         LDKMessageSendEvent_SendFundingSigned_class =
2108                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
2109         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2110         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2111         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2112         LDKMessageSendEvent_SendFundingLocked_class =
2113                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
2114         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2115         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2116         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2117         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2118                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
2119         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2120         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2121         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2122         LDKMessageSendEvent_UpdateHTLCs_class =
2123                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
2124         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2125         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2126         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2127         LDKMessageSendEvent_SendRevokeAndACK_class =
2128                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
2129         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2130         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2131         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2132         LDKMessageSendEvent_SendClosingSigned_class =
2133                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
2134         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2135         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2136         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2137         LDKMessageSendEvent_SendShutdown_class =
2138                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
2139         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2140         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2141         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2142         LDKMessageSendEvent_SendChannelReestablish_class =
2143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
2144         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2145         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2146         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2147         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
2149         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2150         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2151         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2152         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2153                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
2154         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2155         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2156         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2157         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2158                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
2159         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2160         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2161         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2162         LDKMessageSendEvent_SendChannelUpdate_class =
2163                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
2164         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2165         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2166         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2167         LDKMessageSendEvent_HandleError_class =
2168                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
2169         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2170         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2171         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2172         LDKMessageSendEvent_SendChannelRangeQuery_class =
2173                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
2174         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2175         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2176         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2177         LDKMessageSendEvent_SendShortIdsQuery_class =
2178                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
2179         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2180         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2181         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2182         LDKMessageSendEvent_SendReplyChannelRange_class =
2183                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
2184         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2185         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2186         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2187 }
2188 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2189         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2190         switch(obj->tag) {
2191                 case LDKMessageSendEvent_SendAcceptChannel: {
2192                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2193                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2194                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2195                         uint64_t msg_ref = 0;
2196                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2197                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2198                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2199                         msg_ref = (uint64_t)msg_var.inner & ~1;
2200                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2201                 }
2202                 case LDKMessageSendEvent_SendOpenChannel: {
2203                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2204                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2205                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2206                         uint64_t msg_ref = 0;
2207                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2208                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2209                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2210                         msg_ref = (uint64_t)msg_var.inner & ~1;
2211                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2212                 }
2213                 case LDKMessageSendEvent_SendFundingCreated: {
2214                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2215                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2216                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2217                         uint64_t msg_ref = 0;
2218                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2219                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2220                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2221                         msg_ref = (uint64_t)msg_var.inner & ~1;
2222                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2223                 }
2224                 case LDKMessageSendEvent_SendFundingSigned: {
2225                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2226                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2227                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2228                         uint64_t msg_ref = 0;
2229                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2230                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2231                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2232                         msg_ref = (uint64_t)msg_var.inner & ~1;
2233                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2234                 }
2235                 case LDKMessageSendEvent_SendFundingLocked: {
2236                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2237                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2238                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2239                         uint64_t msg_ref = 0;
2240                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2241                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2242                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2243                         msg_ref = (uint64_t)msg_var.inner & ~1;
2244                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2245                 }
2246                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2247                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2248                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2249                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2250                         uint64_t msg_ref = 0;
2251                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2252                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2253                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2254                         msg_ref = (uint64_t)msg_var.inner & ~1;
2255                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2256                 }
2257                 case LDKMessageSendEvent_UpdateHTLCs: {
2258                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2259                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2260                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2261                         uint64_t updates_ref = 0;
2262                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2263                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2264                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2265                         updates_ref = (uint64_t)updates_var.inner & ~1;
2266                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2267                 }
2268                 case LDKMessageSendEvent_SendRevokeAndACK: {
2269                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2270                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2271                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2272                         uint64_t msg_ref = 0;
2273                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2274                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2275                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2276                         msg_ref = (uint64_t)msg_var.inner & ~1;
2277                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2278                 }
2279                 case LDKMessageSendEvent_SendClosingSigned: {
2280                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2281                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2282                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2283                         uint64_t msg_ref = 0;
2284                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2285                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2286                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2287                         msg_ref = (uint64_t)msg_var.inner & ~1;
2288                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2289                 }
2290                 case LDKMessageSendEvent_SendShutdown: {
2291                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2292                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2293                         LDKShutdown msg_var = obj->send_shutdown.msg;
2294                         uint64_t msg_ref = 0;
2295                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2296                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2297                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2298                         msg_ref = (uint64_t)msg_var.inner & ~1;
2299                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2300                 }
2301                 case LDKMessageSendEvent_SendChannelReestablish: {
2302                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2303                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2304                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2305                         uint64_t msg_ref = 0;
2306                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2307                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2308                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2309                         msg_ref = (uint64_t)msg_var.inner & ~1;
2310                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2311                 }
2312                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2313                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2314                         uint64_t msg_ref = 0;
2315                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2316                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2317                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2318                         msg_ref = (uint64_t)msg_var.inner & ~1;
2319                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2320                         uint64_t update_msg_ref = 0;
2321                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2322                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2323                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2324                         update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
2325                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2326                 }
2327                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2328                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2329                         uint64_t msg_ref = 0;
2330                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2331                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2332                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2333                         msg_ref = (uint64_t)msg_var.inner & ~1;
2334                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2335                 }
2336                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2337                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2338                         uint64_t msg_ref = 0;
2339                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2340                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2341                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2342                         msg_ref = (uint64_t)msg_var.inner & ~1;
2343                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2344                 }
2345                 case LDKMessageSendEvent_SendChannelUpdate: {
2346                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2347                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2348                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2349                         uint64_t msg_ref = 0;
2350                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2351                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2352                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2353                         msg_ref = (uint64_t)msg_var.inner & ~1;
2354                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2355                 }
2356                 case LDKMessageSendEvent_HandleError: {
2357                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2358                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2359                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
2360                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2361                 }
2362                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2363                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2364                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2365                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2366                         uint64_t msg_ref = 0;
2367                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2368                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2369                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2370                         msg_ref = (uint64_t)msg_var.inner & ~1;
2371                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2372                 }
2373                 case LDKMessageSendEvent_SendShortIdsQuery: {
2374                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2375                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2376                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2377                         uint64_t msg_ref = 0;
2378                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2379                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2380                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2381                         msg_ref = (uint64_t)msg_var.inner & ~1;
2382                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
2383                 }
2384                 case LDKMessageSendEvent_SendReplyChannelRange: {
2385                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2386                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
2387                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2388                         uint64_t msg_ref = 0;
2389                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2390                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2391                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2392                         msg_ref = (uint64_t)msg_var.inner & ~1;
2393                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2394                 }
2395                 default: abort();
2396         }
2397 }
2398 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2399         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2400         for (size_t i = 0; i < ret.datalen; i++) {
2401                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2402         }
2403         return ret;
2404 }
2405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2406         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2407         CHECK(val->result_ok);
2408         LDKInitFeatures res_var = (*val->contents.result);
2409         uint64_t res_ref = 0;
2410         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2411         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2412         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2413         res_ref = (uint64_t)res_var.inner & ~1;
2414         return res_ref;
2415 }
2416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2417         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2418         CHECK(!val->result_ok);
2419         LDKDecodeError err_var = (*val->contents.err);
2420         uint64_t err_ref = 0;
2421         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2422         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2423         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2424         err_ref = (uint64_t)err_var.inner & ~1;
2425         return err_ref;
2426 }
2427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2428         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2429         CHECK(val->result_ok);
2430         LDKNodeFeatures res_var = (*val->contents.result);
2431         uint64_t res_ref = 0;
2432         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2433         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2434         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2435         res_ref = (uint64_t)res_var.inner & ~1;
2436         return res_ref;
2437 }
2438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2439         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2440         CHECK(!val->result_ok);
2441         LDKDecodeError err_var = (*val->contents.err);
2442         uint64_t err_ref = 0;
2443         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2444         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2445         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2446         err_ref = (uint64_t)err_var.inner & ~1;
2447         return err_ref;
2448 }
2449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2450         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2451         CHECK(val->result_ok);
2452         LDKChannelFeatures res_var = (*val->contents.result);
2453         uint64_t res_ref = 0;
2454         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2455         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2456         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2457         res_ref = (uint64_t)res_var.inner & ~1;
2458         return res_ref;
2459 }
2460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2461         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2462         CHECK(!val->result_ok);
2463         LDKDecodeError err_var = (*val->contents.err);
2464         uint64_t err_ref = 0;
2465         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2466         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2467         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2468         err_ref = (uint64_t)err_var.inner & ~1;
2469         return err_ref;
2470 }
2471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2472         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2473         CHECK(val->result_ok);
2474         LDKInvoiceFeatures res_var = (*val->contents.result);
2475         uint64_t res_ref = 0;
2476         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2477         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2478         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2479         res_ref = (uint64_t)res_var.inner & ~1;
2480         return res_ref;
2481 }
2482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2483         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2484         CHECK(!val->result_ok);
2485         LDKDecodeError err_var = (*val->contents.err);
2486         uint64_t err_ref = 0;
2487         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2488         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2489         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2490         err_ref = (uint64_t)err_var.inner & ~1;
2491         return err_ref;
2492 }
2493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2494         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
2495         CHECK(val->result_ok);
2496         LDKScoringParameters res_var = (*val->contents.result);
2497         uint64_t res_ref = 0;
2498         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2499         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2500         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2501         res_ref = (uint64_t)res_var.inner & ~1;
2502         return res_ref;
2503 }
2504 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2505         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
2506         CHECK(!val->result_ok);
2507         LDKDecodeError err_var = (*val->contents.err);
2508         uint64_t err_ref = 0;
2509         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2510         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2511         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2512         err_ref = (uint64_t)err_var.inner & ~1;
2513         return err_ref;
2514 }
2515 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2516         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
2517         CHECK(val->result_ok);
2518         LDKScorer res_var = (*val->contents.result);
2519         uint64_t res_ref = 0;
2520         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2521         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2522         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2523         res_ref = (uint64_t)res_var.inner & ~1;
2524         return res_ref;
2525 }
2526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2527         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
2528         CHECK(!val->result_ok);
2529         LDKDecodeError err_var = (*val->contents.err);
2530         uint64_t err_ref = 0;
2531         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2532         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2533         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2534         err_ref = (uint64_t)err_var.inner & ~1;
2535         return err_ref;
2536 }
2537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2538         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2539         CHECK(val->result_ok);
2540         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2541         uint64_t res_ref = 0;
2542         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2543         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2544         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2545         res_ref = (uint64_t)res_var.inner & ~1;
2546         return res_ref;
2547 }
2548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2549         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2550         CHECK(!val->result_ok);
2551         LDKDecodeError err_var = (*val->contents.err);
2552         uint64_t err_ref = 0;
2553         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2554         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2555         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2556         err_ref = (uint64_t)err_var.inner & ~1;
2557         return err_ref;
2558 }
2559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2560         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2561         CHECK(val->result_ok);
2562         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2563         uint64_t res_ref = 0;
2564         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2565         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2566         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2567         res_ref = (uint64_t)res_var.inner & ~1;
2568         return res_ref;
2569 }
2570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2571         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2572         CHECK(!val->result_ok);
2573         LDKDecodeError err_var = (*val->contents.err);
2574         uint64_t err_ref = 0;
2575         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2576         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2577         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2578         err_ref = (uint64_t)err_var.inner & ~1;
2579         return err_ref;
2580 }
2581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2582         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2583         CHECK(val->result_ok);
2584         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2585         return res_ref;
2586 }
2587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2588         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2589         CHECK(!val->result_ok);
2590         LDKDecodeError err_var = (*val->contents.err);
2591         uint64_t err_ref = 0;
2592         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2593         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2594         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2595         err_ref = (uint64_t)err_var.inner & ~1;
2596         return err_ref;
2597 }
2598 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2599         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2600         CHECK(val->result_ok);
2601         return *val->contents.result;
2602 }
2603 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2604         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2605         CHECK(!val->result_ok);
2606         return *val->contents.err;
2607 }
2608 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2609         return tuple->a;
2610 }
2611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
2612         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2613         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
2614         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form);
2615         return ret_arr;
2616 }
2617
2618 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2619         return tuple->b;
2620 }
2621 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
2622         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2623         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
2624         jobjectArray ret_arr = NULL;
2625         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
2626         ;
2627         for (size_t i = 0; i < ret_var.datalen; i++) {
2628                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
2629                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
2630                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
2631         }
2632         
2633         FREE(ret_var.data);
2634         return ret_arr;
2635 }
2636
2637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2638         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2639         CHECK(val->result_ok);
2640         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2641         *res_conv = (*val->contents.result);
2642         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
2643         return ((uint64_t)res_conv);
2644 }
2645 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2646         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2647         CHECK(!val->result_ok);
2648         return *val->contents.err;
2649 }
2650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2651         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2652         CHECK(val->result_ok);
2653         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2654         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2655         return res_arr;
2656 }
2657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2658         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2659         CHECK(!val->result_ok);
2660         return *val->contents.err;
2661 }
2662 typedef struct LDKBaseSign_JCalls {
2663         atomic_size_t refcnt;
2664         JavaVM *vm;
2665         jweak o;
2666         jmethodID get_per_commitment_point_meth;
2667         jmethodID release_commitment_secret_meth;
2668         jmethodID validate_holder_commitment_meth;
2669         jmethodID channel_keys_id_meth;
2670         jmethodID sign_counterparty_commitment_meth;
2671         jmethodID validate_counterparty_revocation_meth;
2672         jmethodID sign_holder_commitment_and_htlcs_meth;
2673         jmethodID sign_justice_revoked_output_meth;
2674         jmethodID sign_justice_revoked_htlc_meth;
2675         jmethodID sign_counterparty_htlc_transaction_meth;
2676         jmethodID sign_closing_transaction_meth;
2677         jmethodID sign_channel_announcement_meth;
2678         jmethodID ready_channel_meth;
2679 } LDKBaseSign_JCalls;
2680 static void LDKBaseSign_JCalls_free(void* this_arg) {
2681         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2682         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2683                 JNIEnv *env;
2684                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2685                 if (get_jenv_res == JNI_EDETACHED) {
2686                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2687                 } else {
2688                         DO_ASSERT(get_jenv_res == JNI_OK);
2689                 }
2690                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2691                 if (get_jenv_res == JNI_EDETACHED) {
2692                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2693                 }
2694                 FREE(j_calls);
2695         }
2696 }
2697 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2698         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2699         JNIEnv *env;
2700         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2701         if (get_jenv_res == JNI_EDETACHED) {
2702                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2703         } else {
2704                 DO_ASSERT(get_jenv_res == JNI_OK);
2705         }
2706         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2707         CHECK(obj != NULL);
2708         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2709         if ((*env)->ExceptionCheck(env)) {
2710                 (*env)->ExceptionDescribe(env);
2711                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2712         }
2713         LDKPublicKey ret_ref;
2714         CHECK((*env)->GetArrayLength(env, ret) == 33);
2715         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2716         if (get_jenv_res == JNI_EDETACHED) {
2717                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2718         }
2719         return ret_ref;
2720 }
2721 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2722         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2723         JNIEnv *env;
2724         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2725         if (get_jenv_res == JNI_EDETACHED) {
2726                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2727         } else {
2728                 DO_ASSERT(get_jenv_res == JNI_OK);
2729         }
2730         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2731         CHECK(obj != NULL);
2732         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2733         if ((*env)->ExceptionCheck(env)) {
2734                 (*env)->ExceptionDescribe(env);
2735                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2736         }
2737         LDKThirtyTwoBytes ret_ref;
2738         CHECK((*env)->GetArrayLength(env, ret) == 32);
2739         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2740         if (get_jenv_res == JNI_EDETACHED) {
2741                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2742         }
2743         return ret_ref;
2744 }
2745 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
2746         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2747         JNIEnv *env;
2748         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2749         if (get_jenv_res == JNI_EDETACHED) {
2750                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2751         } else {
2752                 DO_ASSERT(get_jenv_res == JNI_OK);
2753         }
2754         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2755         uint64_t holder_tx_ref = 0;
2756         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
2757         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2758         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2759         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2760         holder_tx_ref = (uint64_t)holder_tx_var.inner;
2761         if (holder_tx_var.is_owned) {
2762                 holder_tx_ref |= 1;
2763         }
2764         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2765         CHECK(obj != NULL);
2766         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref);
2767         if ((*env)->ExceptionCheck(env)) {
2768                 (*env)->ExceptionDescribe(env);
2769                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
2770         }
2771         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2772         CHECK_ACCESS(ret_ptr);
2773         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2774         FREE((void*)ret);
2775         if (get_jenv_res == JNI_EDETACHED) {
2776                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2777         }
2778         return ret_conv;
2779 }
2780 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2781         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2782         JNIEnv *env;
2783         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2784         if (get_jenv_res == JNI_EDETACHED) {
2785                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2786         } else {
2787                 DO_ASSERT(get_jenv_res == JNI_OK);
2788         }
2789         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2790         CHECK(obj != NULL);
2791         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2792         if ((*env)->ExceptionCheck(env)) {
2793                 (*env)->ExceptionDescribe(env);
2794                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2795         }
2796         LDKThirtyTwoBytes ret_ref;
2797         CHECK((*env)->GetArrayLength(env, ret) == 32);
2798         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2799         if (get_jenv_res == JNI_EDETACHED) {
2800                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2801         }
2802         return ret_ref;
2803 }
2804 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2805         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2806         JNIEnv *env;
2807         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2808         if (get_jenv_res == JNI_EDETACHED) {
2809                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2810         } else {
2811                 DO_ASSERT(get_jenv_res == JNI_OK);
2812         }
2813         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2814         uint64_t commitment_tx_ref = 0;
2815         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2816         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2817         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2818         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2819         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2820         if (commitment_tx_var.is_owned) {
2821                 commitment_tx_ref |= 1;
2822         }
2823         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2824         CHECK(obj != NULL);
2825         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2826         if ((*env)->ExceptionCheck(env)) {
2827                 (*env)->ExceptionDescribe(env);
2828                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2829         }
2830         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2831         CHECK_ACCESS(ret_ptr);
2832         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2833         FREE((void*)ret);
2834         if (get_jenv_res == JNI_EDETACHED) {
2835                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2836         }
2837         return ret_conv;
2838 }
2839 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2840         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2841         JNIEnv *env;
2842         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2843         if (get_jenv_res == JNI_EDETACHED) {
2844                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2845         } else {
2846                 DO_ASSERT(get_jenv_res == JNI_OK);
2847         }
2848         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
2849         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
2850         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2851         CHECK(obj != NULL);
2852         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
2853         if ((*env)->ExceptionCheck(env)) {
2854                 (*env)->ExceptionDescribe(env);
2855                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
2856         }
2857         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2858         CHECK_ACCESS(ret_ptr);
2859         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2860         FREE((void*)ret);
2861         if (get_jenv_res == JNI_EDETACHED) {
2862                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2863         }
2864         return ret_conv;
2865 }
2866 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2867         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2868         JNIEnv *env;
2869         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2870         if (get_jenv_res == JNI_EDETACHED) {
2871                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2872         } else {
2873                 DO_ASSERT(get_jenv_res == JNI_OK);
2874         }
2875         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2876         uint64_t commitment_tx_ref = 0;
2877         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2878         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2879         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2880         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2881         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2882         if (commitment_tx_var.is_owned) {
2883                 commitment_tx_ref |= 1;
2884         }
2885         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2886         CHECK(obj != NULL);
2887         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2888         if ((*env)->ExceptionCheck(env)) {
2889                 (*env)->ExceptionDescribe(env);
2890                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2891         }
2892         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2893         CHECK_ACCESS(ret_ptr);
2894         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2895         FREE((void*)ret);
2896         if (get_jenv_res == JNI_EDETACHED) {
2897                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2898         }
2899         return ret_conv;
2900 }
2901 LDKCResult_SignatureNoneZ sign_justice_revoked_output_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32]) {
2902         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2903         JNIEnv *env;
2904         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2905         if (get_jenv_res == JNI_EDETACHED) {
2906                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2907         } else {
2908                 DO_ASSERT(get_jenv_res == JNI_OK);
2909         }
2910         LDKTransaction justice_tx_var = justice_tx;
2911         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2912         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2913         Transaction_free(justice_tx_var);
2914         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2915         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2916         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2917         CHECK(obj != NULL);
2918         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2919         if ((*env)->ExceptionCheck(env)) {
2920                 (*env)->ExceptionDescribe(env);
2921                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2922         }
2923         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2924         CHECK_ACCESS(ret_ptr);
2925         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2926         FREE((void*)ret);
2927         if (get_jenv_res == JNI_EDETACHED) {
2928                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2929         }
2930         return ret_conv;
2931 }
2932 LDKCResult_SignatureNoneZ sign_justice_revoked_htlc_LDKBaseSign_jcall(const void* this_arg, LDKTransaction justice_tx, uintptr_t input, uint64_t amount, const uint8_t (* per_commitment_key)[32], const LDKHTLCOutputInCommitment * htlc) {
2933         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2934         JNIEnv *env;
2935         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2936         if (get_jenv_res == JNI_EDETACHED) {
2937                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2938         } else {
2939                 DO_ASSERT(get_jenv_res == JNI_OK);
2940         }
2941         LDKTransaction justice_tx_var = justice_tx;
2942         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2943         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2944         Transaction_free(justice_tx_var);
2945         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2946         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2947         LDKHTLCOutputInCommitment htlc_var = *htlc;
2948         uint64_t htlc_ref = 0;
2949         htlc_var = HTLCOutputInCommitment_clone(htlc);
2950         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2951         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2952         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2953         htlc_ref = (uint64_t)htlc_var.inner;
2954         if (htlc_var.is_owned) {
2955                 htlc_ref |= 1;
2956         }
2957         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2958         CHECK(obj != NULL);
2959         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_htlc_meth, justice_tx_arr, input, amount, per_commitment_key_arr, htlc_ref);
2960         if ((*env)->ExceptionCheck(env)) {
2961                 (*env)->ExceptionDescribe(env);
2962                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2963         }
2964         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2965         CHECK_ACCESS(ret_ptr);
2966         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2967         FREE((void*)ret);
2968         if (get_jenv_res == JNI_EDETACHED) {
2969                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2970         }
2971         return ret_conv;
2972 }
2973 LDKCResult_SignatureNoneZ sign_counterparty_htlc_transaction_LDKBaseSign_jcall(const void* this_arg, LDKTransaction htlc_tx, uintptr_t input, uint64_t amount, LDKPublicKey per_commitment_point, const LDKHTLCOutputInCommitment * htlc) {
2974         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2975         JNIEnv *env;
2976         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2977         if (get_jenv_res == JNI_EDETACHED) {
2978                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2979         } else {
2980                 DO_ASSERT(get_jenv_res == JNI_OK);
2981         }
2982         LDKTransaction htlc_tx_var = htlc_tx;
2983         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2984         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2985         Transaction_free(htlc_tx_var);
2986         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2987         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2988         LDKHTLCOutputInCommitment htlc_var = *htlc;
2989         uint64_t htlc_ref = 0;
2990         htlc_var = HTLCOutputInCommitment_clone(htlc);
2991         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2992         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2993         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2994         htlc_ref = (uint64_t)htlc_var.inner;
2995         if (htlc_var.is_owned) {
2996                 htlc_ref |= 1;
2997         }
2998         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2999         CHECK(obj != NULL);
3000         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_htlc_transaction_meth, htlc_tx_arr, input, amount, per_commitment_point_arr, htlc_ref);
3001         if ((*env)->ExceptionCheck(env)) {
3002                 (*env)->ExceptionDescribe(env);
3003                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
3004         }
3005         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3006         CHECK_ACCESS(ret_ptr);
3007         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3008         FREE((void*)ret);
3009         if (get_jenv_res == JNI_EDETACHED) {
3010                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3011         }
3012         return ret_conv;
3013 }
3014 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3015         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3016         JNIEnv *env;
3017         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3018         if (get_jenv_res == JNI_EDETACHED) {
3019                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3020         } else {
3021                 DO_ASSERT(get_jenv_res == JNI_OK);
3022         }
3023         LDKClosingTransaction closing_tx_var = *closing_tx;
3024         uint64_t closing_tx_ref = 0;
3025         closing_tx_var = ClosingTransaction_clone(closing_tx);
3026         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3027         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3028         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3029         closing_tx_ref = (uint64_t)closing_tx_var.inner;
3030         if (closing_tx_var.is_owned) {
3031                 closing_tx_ref |= 1;
3032         }
3033         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3034         CHECK(obj != NULL);
3035         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
3036         if ((*env)->ExceptionCheck(env)) {
3037                 (*env)->ExceptionDescribe(env);
3038                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
3039         }
3040         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3041         CHECK_ACCESS(ret_ptr);
3042         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3043         FREE((void*)ret);
3044         if (get_jenv_res == JNI_EDETACHED) {
3045                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3046         }
3047         return ret_conv;
3048 }
3049 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3050         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3051         JNIEnv *env;
3052         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3053         if (get_jenv_res == JNI_EDETACHED) {
3054                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3055         } else {
3056                 DO_ASSERT(get_jenv_res == JNI_OK);
3057         }
3058         LDKUnsignedChannelAnnouncement msg_var = *msg;
3059         uint64_t msg_ref = 0;
3060         msg_var = UnsignedChannelAnnouncement_clone(msg);
3061         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3062         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3063         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3064         msg_ref = (uint64_t)msg_var.inner;
3065         if (msg_var.is_owned) {
3066                 msg_ref |= 1;
3067         }
3068         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3069         CHECK(obj != NULL);
3070         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
3071         if ((*env)->ExceptionCheck(env)) {
3072                 (*env)->ExceptionDescribe(env);
3073                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
3074         }
3075         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3076         CHECK_ACCESS(ret_ptr);
3077         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3078         FREE((void*)ret);
3079         if (get_jenv_res == JNI_EDETACHED) {
3080                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3081         }
3082         return ret_conv;
3083 }
3084 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3085         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3086         JNIEnv *env;
3087         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3088         if (get_jenv_res == JNI_EDETACHED) {
3089                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3090         } else {
3091                 DO_ASSERT(get_jenv_res == JNI_OK);
3092         }
3093         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3094         uint64_t channel_parameters_ref = 0;
3095         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
3096         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3097         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3098         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3099         channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
3100         if (channel_parameters_var.is_owned) {
3101                 channel_parameters_ref |= 1;
3102         }
3103         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3104         CHECK(obj != NULL);
3105         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
3106         if ((*env)->ExceptionCheck(env)) {
3107                 (*env)->ExceptionDescribe(env);
3108                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
3109         }
3110         if (get_jenv_res == JNI_EDETACHED) {
3111                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3112         }
3113 }
3114 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3115         jclass c = (*env)->GetObjectClass(env, o);
3116         CHECK(c != NULL);
3117         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3118         atomic_init(&calls->refcnt, 1);
3119         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3120         calls->o = (*env)->NewWeakGlobalRef(env, o);
3121         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
3122         CHECK(calls->get_per_commitment_point_meth != NULL);
3123         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
3124         CHECK(calls->release_commitment_secret_meth != NULL);
3125         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J");
3126         CHECK(calls->validate_holder_commitment_meth != NULL);
3127         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
3128         CHECK(calls->channel_keys_id_meth != NULL);
3129         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
3130         CHECK(calls->sign_counterparty_commitment_meth != NULL);
3131         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
3132         CHECK(calls->validate_counterparty_revocation_meth != NULL);
3133         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
3134         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
3135         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
3136         CHECK(calls->sign_justice_revoked_output_meth != NULL);
3137         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
3138         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
3139         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
3140         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
3141         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
3142         CHECK(calls->sign_closing_transaction_meth != NULL);
3143         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
3144         CHECK(calls->sign_channel_announcement_meth != NULL);
3145         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
3146         CHECK(calls->ready_channel_meth != NULL);
3147
3148         LDKChannelPublicKeys pubkeys_conv;
3149         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3150         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3151         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3152
3153         LDKBaseSign ret = {
3154                 .this_arg = (void*) calls,
3155                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3156                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3157                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3158                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3159                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3160                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3161                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3162                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3163                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3164                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3165                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3166                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3167                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3168                 .free = LDKBaseSign_JCalls_free,
3169                 .pubkeys = pubkeys_conv,
3170                 .set_pubkeys = NULL,
3171         };
3172         return ret;
3173 }
3174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3175         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3176         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
3177         return (uint64_t)res_ptr;
3178 }
3179 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
3180         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3181         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3182         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3183         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3184         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
3185         return ret_arr;
3186 }
3187
3188 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
3189         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3190         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3191         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3192         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3193         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
3194         return ret_arr;
3195 }
3196
3197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1holder_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t holder_tx) {
3198         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3199         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3200         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3201         LDKHolderCommitmentTransaction holder_tx_conv;
3202         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3203         holder_tx_conv.is_owned = false;
3204         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3205         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3206         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
3207         return (uint64_t)ret_conv;
3208 }
3209
3210 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
3211         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3212         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3213         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3214         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3215         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
3216         return ret_arr;
3217 }
3218
3219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1counterparty_1commitment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
3220         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3221         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3222         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3223         LDKCommitmentTransaction commitment_tx_conv;
3224         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3225         commitment_tx_conv.is_owned = false;
3226         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3227         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3228         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
3229         return (uint64_t)ret_conv;
3230 }
3231
3232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1validate_1counterparty_1revocation(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx, int8_tArray secret) {
3233         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3234         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3235         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3236         unsigned char secret_arr[32];
3237         CHECK((*env)->GetArrayLength(env, secret) == 32);
3238         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
3239         unsigned char (*secret_ref)[32] = &secret_arr;
3240         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3241         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3242         return (uint64_t)ret_conv;
3243 }
3244
3245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1holder_1commitment_1and_1htlcs(JNIEnv *env, jclass clz, int64_t this_arg, int64_t commitment_tx) {
3246         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3247         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3248         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3249         LDKHolderCommitmentTransaction commitment_tx_conv;
3250         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3251         commitment_tx_conv.is_owned = false;
3252         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3253         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3254         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3255         return (uint64_t)ret_conv;
3256 }
3257
3258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_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) {
3259         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3260         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3261         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3262         LDKTransaction justice_tx_ref;
3263         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3264         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3265         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3266         justice_tx_ref.data_is_owned = true;
3267         unsigned char per_commitment_key_arr[32];
3268         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3269         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3270         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3271         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3272         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3273         return (uint64_t)ret_conv;
3274 }
3275
3276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_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) {
3277         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3278         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3279         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3280         LDKTransaction justice_tx_ref;
3281         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3282         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3283         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3284         justice_tx_ref.data_is_owned = true;
3285         unsigned char per_commitment_key_arr[32];
3286         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3287         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3288         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3289         LDKHTLCOutputInCommitment htlc_conv;
3290         htlc_conv.inner = (void*)(htlc & (~1));
3291         htlc_conv.is_owned = false;
3292         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3293         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3294         *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);
3295         return (uint64_t)ret_conv;
3296 }
3297
3298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_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) {
3299         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3300         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3301         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3302         LDKTransaction htlc_tx_ref;
3303         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
3304         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3305         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
3306         htlc_tx_ref.data_is_owned = true;
3307         LDKPublicKey per_commitment_point_ref;
3308         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
3309         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
3310         LDKHTLCOutputInCommitment htlc_conv;
3311         htlc_conv.inner = (void*)(htlc & (~1));
3312         htlc_conv.is_owned = false;
3313         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3314         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3315         *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);
3316         return (uint64_t)ret_conv;
3317 }
3318
3319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1closing_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int64_t closing_tx) {
3320         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3321         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3322         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3323         LDKClosingTransaction closing_tx_conv;
3324         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3325         closing_tx_conv.is_owned = false;
3326         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3327         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3328         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3329         return (uint64_t)ret_conv;
3330 }
3331
3332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
3333         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3334         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3335         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3336         LDKUnsignedChannelAnnouncement msg_conv;
3337         msg_conv.inner = (void*)(msg & (~1));
3338         msg_conv.is_owned = false;
3339         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3340         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3341         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3342         return (uint64_t)ret_conv;
3343 }
3344
3345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
3346         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3347         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3348         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3349         LDKChannelTransactionParameters channel_parameters_conv;
3350         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3351         channel_parameters_conv.is_owned = false;
3352         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3353         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3354 }
3355
3356 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3357         if (this_arg->set_pubkeys != NULL)
3358                 this_arg->set_pubkeys(this_arg);
3359         return this_arg->pubkeys;
3360 }
3361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
3362         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3363         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3364         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3365         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3366         uint64_t ret_ref = 0;
3367         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3368         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3369         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3370         ret_ref = (uint64_t)ret_var.inner;
3371         if (ret_var.is_owned) {
3372                 ret_ref |= 1;
3373         }
3374         return ret_ref;
3375 }
3376
3377 typedef struct LDKSign_JCalls {
3378         atomic_size_t refcnt;
3379         JavaVM *vm;
3380         jweak o;
3381         LDKBaseSign_JCalls* BaseSign;
3382         jmethodID write_meth;
3383 } LDKSign_JCalls;
3384 static void LDKSign_JCalls_free(void* this_arg) {
3385         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3386         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3387                 JNIEnv *env;
3388                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3389                 if (get_jenv_res == JNI_EDETACHED) {
3390                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3391                 } else {
3392                         DO_ASSERT(get_jenv_res == JNI_OK);
3393                 }
3394                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3395                 if (get_jenv_res == JNI_EDETACHED) {
3396                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3397                 }
3398                 FREE(j_calls);
3399         }
3400 }
3401 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3402         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3403         JNIEnv *env;
3404         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3405         if (get_jenv_res == JNI_EDETACHED) {
3406                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3407         } else {
3408                 DO_ASSERT(get_jenv_res == JNI_OK);
3409         }
3410         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3411         CHECK(obj != NULL);
3412         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
3413         if ((*env)->ExceptionCheck(env)) {
3414                 (*env)->ExceptionDescribe(env);
3415                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
3416         }
3417         LDKCVec_u8Z ret_ref;
3418         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3419         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3420         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3421         if (get_jenv_res == JNI_EDETACHED) {
3422                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3423         }
3424         return ret_ref;
3425 }
3426 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3427         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3428         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3429         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3430 }
3431 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3432         jclass c = (*env)->GetObjectClass(env, o);
3433         CHECK(c != NULL);
3434         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3435         atomic_init(&calls->refcnt, 1);
3436         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3437         calls->o = (*env)->NewWeakGlobalRef(env, o);
3438         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
3439         CHECK(calls->write_meth != NULL);
3440
3441         LDKChannelPublicKeys pubkeys_conv;
3442         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3443         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3444         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3445
3446         LDKSign ret = {
3447                 .this_arg = (void*) calls,
3448                 .write = write_LDKSign_jcall,
3449                 .cloned = LDKSign_JCalls_cloned,
3450                 .free = LDKSign_JCalls_free,
3451                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
3452         };
3453         calls->BaseSign = ret.BaseSign.this_arg;
3454         return ret;
3455 }
3456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3457         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3458         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
3459         return (uint64_t)res_ptr;
3460 }
3461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
3462         LDKSign *inp = (LDKSign *)(arg & ~1);
3463         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
3464         DO_ASSERT((res_ptr & 1) == 0);
3465         return (int64_t)(res_ptr | 1);
3466 }
3467 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
3468         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3469         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3470         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3471         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3472         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3473         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3474         CVec_u8Z_free(ret_var);
3475         return ret_arr;
3476 }
3477
3478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3479         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3480         CHECK(val->result_ok);
3481         LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3482         *res_ret = Sign_clone(&(*val->contents.result));
3483         return (uint64_t)res_ret;
3484 }
3485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3486         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3487         CHECK(!val->result_ok);
3488         LDKDecodeError err_var = (*val->contents.err);
3489         uint64_t err_ref = 0;
3490         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3491         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3492         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3493         err_ref = (uint64_t)err_var.inner & ~1;
3494         return err_ref;
3495 }
3496 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3497         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3498         CHECK(val->result_ok);
3499         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
3500         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
3501         return es_arr;
3502 }
3503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3504         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3505         CHECK(!val->result_ok);
3506         return *val->contents.err;
3507 }
3508 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3509         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3510         for (size_t i = 0; i < ret.datalen; i++) {
3511                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3512         }
3513         return ret;
3514 }
3515 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3516         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3517         CHECK(val->result_ok);
3518         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3519         jobjectArray res_arr = NULL;
3520         res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3521         ;
3522         for (size_t i = 0; i < res_var.datalen; i++) {
3523                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3524                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3525                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3526                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3527         }
3528         
3529         return res_arr;
3530 }
3531 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3532         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3533         CHECK(!val->result_ok);
3534         return *val->contents.err;
3535 }
3536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3537         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3538         CHECK(val->result_ok);
3539         LDKInMemorySigner res_var = (*val->contents.result);
3540         uint64_t res_ref = 0;
3541         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3542         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3543         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3544         res_ref = (uint64_t)res_var.inner & ~1;
3545         return res_ref;
3546 }
3547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3548         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3549         CHECK(!val->result_ok);
3550         LDKDecodeError err_var = (*val->contents.err);
3551         uint64_t err_ref = 0;
3552         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3553         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3554         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3555         err_ref = (uint64_t)err_var.inner & ~1;
3556         return err_ref;
3557 }
3558 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3559         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3560         for (size_t i = 0; i < ret.datalen; i++) {
3561                 ret.data[i] = TxOut_clone(&orig->data[i]);
3562         }
3563         return ret;
3564 }
3565 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3566         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3567         CHECK(val->result_ok);
3568         LDKTransaction res_var = (*val->contents.result);
3569         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3570         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3571         return res_arr;
3572 }
3573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3574         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3575         CHECK(!val->result_ok);
3576         return *val->contents.err;
3577 }
3578 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3579         return ThirtyTwoBytes_clone(&tuple->a);
3580 }
3581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3582         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3583         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3584         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data);
3585         return ret_arr;
3586 }
3587
3588 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3589         return ChannelMonitor_clone(&tuple->b);
3590 }
3591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3592         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3593         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
3594         uint64_t ret_ref = 0;
3595         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3596         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3598         ret_ref = (uint64_t)ret_var.inner;
3599         if (ret_var.is_owned) {
3600                 ret_ref |= 1;
3601         }
3602         return ret_ref;
3603 }
3604
3605 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
3606         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
3607         for (size_t i = 0; i < ret.datalen; i++) {
3608                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
3609         }
3610         return ret;
3611 }
3612 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3613         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3614         CHECK(val->result_ok);
3615         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3616         int64_tArray res_arr = NULL;
3617         res_arr = (*env)->NewLongArray(env, res_var.datalen);
3618         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3619         for (size_t j = 0; j < res_var.datalen; j++) {
3620                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3621                 *res_conv_35_conv = res_var.data[j];
3622                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
3623                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
3624         }
3625         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3626         return res_arr;
3627 }
3628 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3629         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3630         CHECK(!val->result_ok);
3631         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3632         return err_conv;
3633 }
3634 static jclass LDKCOption_u16Z_Some_class = NULL;
3635 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3636 static jclass LDKCOption_u16Z_None_class = NULL;
3637 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3639         LDKCOption_u16Z_Some_class =
3640                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3641         CHECK(LDKCOption_u16Z_Some_class != NULL);
3642         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3643         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3644         LDKCOption_u16Z_None_class =
3645                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3646         CHECK(LDKCOption_u16Z_None_class != NULL);
3647         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3648         CHECK(LDKCOption_u16Z_None_meth != NULL);
3649 }
3650 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3651         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3652         switch(obj->tag) {
3653                 case LDKCOption_u16Z_Some: {
3654                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3655                 }
3656                 case LDKCOption_u16Z_None: {
3657                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3658                 }
3659                 default: abort();
3660         }
3661 }
3662 static jclass LDKAPIError_APIMisuseError_class = NULL;
3663 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3664 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3665 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3666 static jclass LDKAPIError_RouteError_class = NULL;
3667 static jmethodID LDKAPIError_RouteError_meth = NULL;
3668 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3669 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3670 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3671 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3672 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3673 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3675         LDKAPIError_APIMisuseError_class =
3676                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3677         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3678         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3679         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3680         LDKAPIError_FeeRateTooHigh_class =
3681                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3682         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3683         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3684         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3685         LDKAPIError_RouteError_class =
3686                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3687         CHECK(LDKAPIError_RouteError_class != NULL);
3688         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3689         CHECK(LDKAPIError_RouteError_meth != NULL);
3690         LDKAPIError_ChannelUnavailable_class =
3691                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3692         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3693         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3694         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3695         LDKAPIError_MonitorUpdateFailed_class =
3696                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3697         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3698         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3699         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3700         LDKAPIError_IncompatibleShutdownScript_class =
3701                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript;"));
3702         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3703         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3704         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3705 }
3706 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3707         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3708         switch(obj->tag) {
3709                 case LDKAPIError_APIMisuseError: {
3710                         LDKStr err_str = obj->api_misuse_error.err;
3711                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3712                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3713                 }
3714                 case LDKAPIError_FeeRateTooHigh: {
3715                         LDKStr err_str = obj->fee_rate_too_high.err;
3716                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3717                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3718                 }
3719                 case LDKAPIError_RouteError: {
3720                         LDKStr err_str = obj->route_error.err;
3721                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3722                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3723                 }
3724                 case LDKAPIError_ChannelUnavailable: {
3725                         LDKStr err_str = obj->channel_unavailable.err;
3726                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3727                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3728                 }
3729                 case LDKAPIError_MonitorUpdateFailed: {
3730                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3731                 }
3732                 case LDKAPIError_IncompatibleShutdownScript: {
3733                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3734                         uint64_t script_ref = 0;
3735                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3736                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3737                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3738                         script_ref = (uint64_t)script_var.inner & ~1;
3739                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3740                 }
3741                 default: abort();
3742         }
3743 }
3744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3745         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3746         CHECK(val->result_ok);
3747         return *val->contents.result;
3748 }
3749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3750         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3751         CHECK(!val->result_ok);
3752         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3753         return err_ref;
3754 }
3755 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3756         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3757         for (size_t i = 0; i < ret.datalen; i++) {
3758                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3759         }
3760         return ret;
3761 }
3762 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3763         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3764         for (size_t i = 0; i < ret.datalen; i++) {
3765                 ret.data[i] = APIError_clone(&orig->data[i]);
3766         }
3767         return ret;
3768 }
3769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3770         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3771         CHECK(val->result_ok);
3772         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3773         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3774         return res_arr;
3775 }
3776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3777         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3778         CHECK(!val->result_ok);
3779         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3780         return err_ref;
3781 }
3782 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3783 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3784 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3785 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3786 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3787 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3788 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3789 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3790 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3791         LDKPaymentSendFailure_ParameterError_class =
3792                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3793         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3794         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3795         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3796         LDKPaymentSendFailure_PathParameterError_class =
3797                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3798         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3799         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3800         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3801         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3802                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3803         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3804         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3805         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3806         LDKPaymentSendFailure_PartialFailure_class =
3807                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3808         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3809         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
3810         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3811 }
3812 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3813         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3814         switch(obj->tag) {
3815                 case LDKPaymentSendFailure_ParameterError: {
3816                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3817                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3818                 }
3819                 case LDKPaymentSendFailure_PathParameterError: {
3820                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3821                         int64_tArray path_parameter_error_arr = NULL;
3822                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3823                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3824                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3825                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3826                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3827                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3828                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3829                         }
3830                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3831                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3832                 }
3833                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3834                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3835                         int64_tArray all_failed_retry_safe_arr = NULL;
3836                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3837                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3838                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3839                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3840                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3841                         }
3842                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3843                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3844                 }
3845                 case LDKPaymentSendFailure_PartialFailure: {
3846                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3847                         int64_tArray results_arr = NULL;
3848                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
3849                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
3850                         for (size_t w = 0; w < results_var.datalen; w++) {
3851                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3852                                 *results_conv_22_conv = results_var.data[w];
3853                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3854                                 results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
3855                         }
3856                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
3857                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3858                         uint64_t failed_paths_retry_ref = 0;
3859                         if ((uint64_t)failed_paths_retry_var.inner > 4096) {
3860                                 CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3861                                 CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3862                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3863                                 failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
3864                         }
3865                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3866                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
3867                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
3868                 }
3869                 default: abort();
3870         }
3871 }
3872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3873         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3874         CHECK(val->result_ok);
3875         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3876         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3877         return res_arr;
3878 }
3879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3880         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3881         CHECK(!val->result_ok);
3882         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3883         return err_ref;
3884 }
3885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3886         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3887         CHECK(val->result_ok);
3888         return *val->contents.result;
3889 }
3890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3891         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3892         CHECK(!val->result_ok);
3893         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3894         return err_ref;
3895 }
3896 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3897         return ThirtyTwoBytes_clone(&tuple->a);
3898 }
3899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3900         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3901         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3902         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data);
3903         return ret_arr;
3904 }
3905
3906 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3907         return ThirtyTwoBytes_clone(&tuple->b);
3908 }
3909 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3910         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3911         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data);
3913         return ret_arr;
3914 }
3915
3916 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3917         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3918         CHECK(val->result_ok);
3919         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3920         *res_conv = (*val->contents.result);
3921         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
3922         return ((uint64_t)res_conv);
3923 }
3924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3925         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3926         CHECK(!val->result_ok);
3927         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3928         return err_ref;
3929 }
3930 static jclass LDKNetAddress_IPv4_class = NULL;
3931 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3932 static jclass LDKNetAddress_IPv6_class = NULL;
3933 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3934 static jclass LDKNetAddress_OnionV2_class = NULL;
3935 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3936 static jclass LDKNetAddress_OnionV3_class = NULL;
3937 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3938 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3939         LDKNetAddress_IPv4_class =
3940                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3941         CHECK(LDKNetAddress_IPv4_class != NULL);
3942         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3943         CHECK(LDKNetAddress_IPv4_meth != NULL);
3944         LDKNetAddress_IPv6_class =
3945                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3946         CHECK(LDKNetAddress_IPv6_class != NULL);
3947         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3948         CHECK(LDKNetAddress_IPv6_meth != NULL);
3949         LDKNetAddress_OnionV2_class =
3950                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3951         CHECK(LDKNetAddress_OnionV2_class != NULL);
3952         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3953         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3954         LDKNetAddress_OnionV3_class =
3955                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3956         CHECK(LDKNetAddress_OnionV3_class != NULL);
3957         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3958         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3959 }
3960 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3961         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3962         switch(obj->tag) {
3963                 case LDKNetAddress_IPv4: {
3964                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3965                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3966                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3967                 }
3968                 case LDKNetAddress_IPv6: {
3969                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3970                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3971                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3972                 }
3973                 case LDKNetAddress_OnionV2: {
3974                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3975                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3976                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3977                 }
3978                 case LDKNetAddress_OnionV3: {
3979                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3980                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3981                         return (*env)->NewObject(env, LDKNetAddress_OnionV3_class, LDKNetAddress_OnionV3_meth, ed25519_pubkey_arr, obj->onion_v3.checksum, obj->onion_v3.version, obj->onion_v3.port);
3982                 }
3983                 default: abort();
3984         }
3985 }
3986 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3987         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3988         for (size_t i = 0; i < ret.datalen; i++) {
3989                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3990         }
3991         return ret;
3992 }
3993 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3994         return ThirtyTwoBytes_clone(&tuple->a);
3995 }
3996 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3997         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
3998         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3999         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data);
4000         return ret_arr;
4001 }
4002
4003 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
4004         return ThirtyTwoBytes_clone(&tuple->b);
4005 }
4006 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4007         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
4008         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4009         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data);
4010         return ret_arr;
4011 }
4012
4013 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4014         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
4015         CHECK(val->result_ok);
4016         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
4017         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
4018         return res_arr;
4019 }
4020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4021         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
4022         CHECK(!val->result_ok);
4023         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4024         return err_ref;
4025 }
4026 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4027         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4028         for (size_t i = 0; i < ret.datalen; i++) {
4029                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4030         }
4031         return ret;
4032 }
4033 typedef struct LDKWatch_JCalls {
4034         atomic_size_t refcnt;
4035         JavaVM *vm;
4036         jweak o;
4037         jmethodID watch_channel_meth;
4038         jmethodID update_channel_meth;
4039         jmethodID release_pending_monitor_events_meth;
4040 } LDKWatch_JCalls;
4041 static void LDKWatch_JCalls_free(void* this_arg) {
4042         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4043         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4044                 JNIEnv *env;
4045                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4046                 if (get_jenv_res == JNI_EDETACHED) {
4047                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4048                 } else {
4049                         DO_ASSERT(get_jenv_res == JNI_OK);
4050                 }
4051                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4052                 if (get_jenv_res == JNI_EDETACHED) {
4053                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4054                 }
4055                 FREE(j_calls);
4056         }
4057 }
4058 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4059         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4060         JNIEnv *env;
4061         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4062         if (get_jenv_res == JNI_EDETACHED) {
4063                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4064         } else {
4065                 DO_ASSERT(get_jenv_res == JNI_OK);
4066         }
4067         LDKOutPoint funding_txo_var = funding_txo;
4068         uint64_t funding_txo_ref = 0;
4069         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4070         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4071         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4072         funding_txo_ref = (uint64_t)funding_txo_var.inner;
4073         if (funding_txo_var.is_owned) {
4074                 funding_txo_ref |= 1;
4075         }
4076         LDKChannelMonitor monitor_var = monitor;
4077         uint64_t monitor_ref = 0;
4078         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4079         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4080         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4081         monitor_ref = (uint64_t)monitor_var.inner;
4082         if (monitor_var.is_owned) {
4083                 monitor_ref |= 1;
4084         }
4085         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4086         CHECK(obj != NULL);
4087         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
4088         if ((*env)->ExceptionCheck(env)) {
4089                 (*env)->ExceptionDescribe(env);
4090                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
4091         }
4092         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4093         CHECK_ACCESS(ret_ptr);
4094         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4095         FREE((void*)ret);
4096         if (get_jenv_res == JNI_EDETACHED) {
4097                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4098         }
4099         return ret_conv;
4100 }
4101 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4102         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4103         JNIEnv *env;
4104         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4105         if (get_jenv_res == JNI_EDETACHED) {
4106                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4107         } else {
4108                 DO_ASSERT(get_jenv_res == JNI_OK);
4109         }
4110         LDKOutPoint funding_txo_var = funding_txo;
4111         uint64_t funding_txo_ref = 0;
4112         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4113         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4114         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4115         funding_txo_ref = (uint64_t)funding_txo_var.inner;
4116         if (funding_txo_var.is_owned) {
4117                 funding_txo_ref |= 1;
4118         }
4119         LDKChannelMonitorUpdate update_var = update;
4120         uint64_t update_ref = 0;
4121         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4122         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4123         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4124         update_ref = (uint64_t)update_var.inner;
4125         if (update_var.is_owned) {
4126                 update_ref |= 1;
4127         }
4128         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4129         CHECK(obj != NULL);
4130         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
4131         if ((*env)->ExceptionCheck(env)) {
4132                 (*env)->ExceptionDescribe(env);
4133                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
4134         }
4135         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4136         CHECK_ACCESS(ret_ptr);
4137         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4138         FREE((void*)ret);
4139         if (get_jenv_res == JNI_EDETACHED) {
4140                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4141         }
4142         return ret_conv;
4143 }
4144 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4145         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4146         JNIEnv *env;
4147         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4148         if (get_jenv_res == JNI_EDETACHED) {
4149                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4150         } else {
4151                 DO_ASSERT(get_jenv_res == JNI_OK);
4152         }
4153         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4154         CHECK(obj != NULL);
4155         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
4156         if ((*env)->ExceptionCheck(env)) {
4157                 (*env)->ExceptionDescribe(env);
4158                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
4159         }
4160         LDKCVec_MonitorEventZ ret_constr;
4161         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4162         if (ret_constr.datalen > 0)
4163                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4164         else
4165                 ret_constr.data = NULL;
4166         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4167         for (size_t o = 0; o < ret_constr.datalen; o++) {
4168                 int64_t ret_conv_14 = ret_vals[o];
4169                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
4170                 CHECK_ACCESS(ret_conv_14_ptr);
4171                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4172                 FREE((void*)ret_conv_14);
4173                 ret_constr.data[o] = ret_conv_14_conv;
4174         }
4175         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4176         if (get_jenv_res == JNI_EDETACHED) {
4177                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4178         }
4179         return ret_constr;
4180 }
4181 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4182         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4183         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4184 }
4185 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
4186         jclass c = (*env)->GetObjectClass(env, o);
4187         CHECK(c != NULL);
4188         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4189         atomic_init(&calls->refcnt, 1);
4190         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4191         calls->o = (*env)->NewWeakGlobalRef(env, o);
4192         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
4193         CHECK(calls->watch_channel_meth != NULL);
4194         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
4195         CHECK(calls->update_channel_meth != NULL);
4196         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
4197         CHECK(calls->release_pending_monitor_events_meth != NULL);
4198
4199         LDKWatch ret = {
4200                 .this_arg = (void*) calls,
4201                 .watch_channel = watch_channel_LDKWatch_jcall,
4202                 .update_channel = update_channel_LDKWatch_jcall,
4203                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4204                 .free = LDKWatch_JCalls_free,
4205         };
4206         return ret;
4207 }
4208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
4209         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4210         *res_ptr = LDKWatch_init(env, clz, o);
4211         return (uint64_t)res_ptr;
4212 }
4213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1watch_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t monitor) {
4214         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4215         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4216         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4217         LDKOutPoint funding_txo_conv;
4218         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4219         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4220         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4221         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4222         LDKChannelMonitor monitor_conv;
4223         monitor_conv.inner = (void*)(monitor & (~1));
4224         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4225         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4226         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4227         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4228         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4229         return (uint64_t)ret_conv;
4230 }
4231
4232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Watch_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo, int64_t update) {
4233         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4234         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4235         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4236         LDKOutPoint funding_txo_conv;
4237         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4238         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4239         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4240         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4241         LDKChannelMonitorUpdate update_conv;
4242         update_conv.inner = (void*)(update & (~1));
4243         update_conv.is_owned = (update & 1) || (update == 0);
4244         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4245         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4246         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4247         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4248         return (uint64_t)ret_conv;
4249 }
4250
4251 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4252         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4253         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4254         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4255         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4256         int64_tArray ret_arr = NULL;
4257         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4258         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4259         for (size_t o = 0; o < ret_var.datalen; o++) {
4260                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4261                 *ret_conv_14_copy = ret_var.data[o];
4262                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
4263                 ret_arr_ptr[o] = ret_conv_14_ref;
4264         }
4265         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4266         FREE(ret_var.data);
4267         return ret_arr;
4268 }
4269
4270 typedef struct LDKBroadcasterInterface_JCalls {
4271         atomic_size_t refcnt;
4272         JavaVM *vm;
4273         jweak o;
4274         jmethodID broadcast_transaction_meth;
4275 } LDKBroadcasterInterface_JCalls;
4276 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4277         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4278         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4279                 JNIEnv *env;
4280                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4281                 if (get_jenv_res == JNI_EDETACHED) {
4282                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4283                 } else {
4284                         DO_ASSERT(get_jenv_res == JNI_OK);
4285                 }
4286                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4287                 if (get_jenv_res == JNI_EDETACHED) {
4288                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4289                 }
4290                 FREE(j_calls);
4291         }
4292 }
4293 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4294         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4295         JNIEnv *env;
4296         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4297         if (get_jenv_res == JNI_EDETACHED) {
4298                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4299         } else {
4300                 DO_ASSERT(get_jenv_res == JNI_OK);
4301         }
4302         LDKTransaction tx_var = tx;
4303         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
4304         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
4305         Transaction_free(tx_var);
4306         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4307         CHECK(obj != NULL);
4308         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
4309         if ((*env)->ExceptionCheck(env)) {
4310                 (*env)->ExceptionDescribe(env);
4311                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
4312         }
4313         if (get_jenv_res == JNI_EDETACHED) {
4314                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4315         }
4316 }
4317 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4318         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4319         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4320 }
4321 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
4322         jclass c = (*env)->GetObjectClass(env, o);
4323         CHECK(c != NULL);
4324         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4325         atomic_init(&calls->refcnt, 1);
4326         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4327         calls->o = (*env)->NewWeakGlobalRef(env, o);
4328         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
4329         CHECK(calls->broadcast_transaction_meth != NULL);
4330
4331         LDKBroadcasterInterface ret = {
4332                 .this_arg = (void*) calls,
4333                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4334                 .free = LDKBroadcasterInterface_JCalls_free,
4335         };
4336         return ret;
4337 }
4338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4339         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4340         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
4341         return (uint64_t)res_ptr;
4342 }
4343 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
4344         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4345         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4346         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4347         LDKTransaction tx_ref;
4348         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
4349         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4350         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
4351         tx_ref.data_is_owned = true;
4352         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4353 }
4354
4355 typedef struct LDKKeysInterface_JCalls {
4356         atomic_size_t refcnt;
4357         JavaVM *vm;
4358         jweak o;
4359         jmethodID get_node_secret_meth;
4360         jmethodID get_destination_script_meth;
4361         jmethodID get_shutdown_scriptpubkey_meth;
4362         jmethodID get_channel_signer_meth;
4363         jmethodID get_secure_random_bytes_meth;
4364         jmethodID read_chan_signer_meth;
4365         jmethodID sign_invoice_meth;
4366 } LDKKeysInterface_JCalls;
4367 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4368         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4369         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4370                 JNIEnv *env;
4371                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4372                 if (get_jenv_res == JNI_EDETACHED) {
4373                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4374                 } else {
4375                         DO_ASSERT(get_jenv_res == JNI_OK);
4376                 }
4377                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4378                 if (get_jenv_res == JNI_EDETACHED) {
4379                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4380                 }
4381                 FREE(j_calls);
4382         }
4383 }
4384 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
4385         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4386         JNIEnv *env;
4387         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4388         if (get_jenv_res == JNI_EDETACHED) {
4389                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4390         } else {
4391                 DO_ASSERT(get_jenv_res == JNI_OK);
4392         }
4393         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4394         CHECK(obj != NULL);
4395         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
4396         if ((*env)->ExceptionCheck(env)) {
4397                 (*env)->ExceptionDescribe(env);
4398                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
4399         }
4400         LDKSecretKey ret_ref;
4401         CHECK((*env)->GetArrayLength(env, ret) == 32);
4402         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
4403         if (get_jenv_res == JNI_EDETACHED) {
4404                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4405         }
4406         return ret_ref;
4407 }
4408 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4409         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4410         JNIEnv *env;
4411         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4412         if (get_jenv_res == JNI_EDETACHED) {
4413                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4414         } else {
4415                 DO_ASSERT(get_jenv_res == JNI_OK);
4416         }
4417         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4418         CHECK(obj != NULL);
4419         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4420         if ((*env)->ExceptionCheck(env)) {
4421                 (*env)->ExceptionDescribe(env);
4422                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
4423         }
4424         LDKCVec_u8Z ret_ref;
4425         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4426         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4427         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4428         if (get_jenv_res == JNI_EDETACHED) {
4429                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4430         }
4431         return ret_ref;
4432 }
4433 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4434         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4435         JNIEnv *env;
4436         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4437         if (get_jenv_res == JNI_EDETACHED) {
4438                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4439         } else {
4440                 DO_ASSERT(get_jenv_res == JNI_OK);
4441         }
4442         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4443         CHECK(obj != NULL);
4444         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
4445         if ((*env)->ExceptionCheck(env)) {
4446                 (*env)->ExceptionDescribe(env);
4447                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
4448         }
4449         LDKShutdownScript ret_conv;
4450         ret_conv.inner = (void*)(ret & (~1));
4451         ret_conv.is_owned = (ret & 1) || (ret == 0);
4452         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4453         if (get_jenv_res == JNI_EDETACHED) {
4454                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4455         }
4456         return ret_conv;
4457 }
4458 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4459         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4460         JNIEnv *env;
4461         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4462         if (get_jenv_res == JNI_EDETACHED) {
4463                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4464         } else {
4465                 DO_ASSERT(get_jenv_res == JNI_OK);
4466         }
4467         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4468         CHECK(obj != NULL);
4469         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4470         if ((*env)->ExceptionCheck(env)) {
4471                 (*env)->ExceptionDescribe(env);
4472                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
4473         }
4474         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4475         CHECK_ACCESS(ret_ptr);
4476         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4477         FREE((void*)ret);
4478         if (get_jenv_res == JNI_EDETACHED) {
4479                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4480         }
4481         return ret_conv;
4482 }
4483 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4484         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4485         JNIEnv *env;
4486         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4487         if (get_jenv_res == JNI_EDETACHED) {
4488                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4489         } else {
4490                 DO_ASSERT(get_jenv_res == JNI_OK);
4491         }
4492         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4493         CHECK(obj != NULL);
4494         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4495         if ((*env)->ExceptionCheck(env)) {
4496                 (*env)->ExceptionDescribe(env);
4497                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
4498         }
4499         LDKThirtyTwoBytes ret_ref;
4500         CHECK((*env)->GetArrayLength(env, ret) == 32);
4501         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4502         if (get_jenv_res == JNI_EDETACHED) {
4503                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4504         }
4505         return ret_ref;
4506 }
4507 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4508         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4509         JNIEnv *env;
4510         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4511         if (get_jenv_res == JNI_EDETACHED) {
4512                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4513         } else {
4514                 DO_ASSERT(get_jenv_res == JNI_OK);
4515         }
4516         LDKu8slice reader_var = reader;
4517         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4518         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4519         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4520         CHECK(obj != NULL);
4521         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4522         if ((*env)->ExceptionCheck(env)) {
4523                 (*env)->ExceptionDescribe(env);
4524                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
4525         }
4526         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4527         CHECK_ACCESS(ret_ptr);
4528         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4529         FREE((void*)ret);
4530         if (get_jenv_res == JNI_EDETACHED) {
4531                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4532         }
4533         return ret_conv;
4534 }
4535 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
4536         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4537         JNIEnv *env;
4538         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4539         if (get_jenv_res == JNI_EDETACHED) {
4540                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4541         } else {
4542                 DO_ASSERT(get_jenv_res == JNI_OK);
4543         }
4544         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
4545         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
4546         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
4547         CVec_u8Z_free(invoice_preimage_var);
4548         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4549         CHECK(obj != NULL);
4550         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
4551         if ((*env)->ExceptionCheck(env)) {
4552                 (*env)->ExceptionDescribe(env);
4553                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
4554         }
4555         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4556         CHECK_ACCESS(ret_ptr);
4557         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4558         FREE((void*)ret);
4559         if (get_jenv_res == JNI_EDETACHED) {
4560                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4561         }
4562         return ret_conv;
4563 }
4564 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4565         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4566         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4567 }
4568 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4569         jclass c = (*env)->GetObjectClass(env, o);
4570         CHECK(c != NULL);
4571         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4572         atomic_init(&calls->refcnt, 1);
4573         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4574         calls->o = (*env)->NewWeakGlobalRef(env, o);
4575         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4576         CHECK(calls->get_node_secret_meth != NULL);
4577         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4578         CHECK(calls->get_destination_script_meth != NULL);
4579         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
4580         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
4581         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4582         CHECK(calls->get_channel_signer_meth != NULL);
4583         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4584         CHECK(calls->get_secure_random_bytes_meth != NULL);
4585         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4586         CHECK(calls->read_chan_signer_meth != NULL);
4587         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4588         CHECK(calls->sign_invoice_meth != NULL);
4589
4590         LDKKeysInterface ret = {
4591                 .this_arg = (void*) calls,
4592                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4593                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4594                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4595                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4596                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4597                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4598                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4599                 .free = LDKKeysInterface_JCalls_free,
4600         };
4601         return ret;
4602 }
4603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4604         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4605         *res_ptr = LDKKeysInterface_init(env, clz, o);
4606         return (uint64_t)res_ptr;
4607 }
4608 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4609         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4610         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4611         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4612         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4613         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4614         return ret_arr;
4615 }
4616
4617 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4618         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4619         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4620         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4621         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4622         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4623         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4624         CVec_u8Z_free(ret_var);
4625         return ret_arr;
4626 }
4627
4628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4629         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4630         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4631         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4632         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4633         uint64_t ret_ref = 0;
4634         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4635         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4637         ret_ref = (uint64_t)ret_var.inner;
4638         if (ret_var.is_owned) {
4639                 ret_ref |= 1;
4640         }
4641         return ret_ref;
4642 }
4643
4644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1channel_1signer(JNIEnv *env, jclass clz, int64_t this_arg, jboolean inbound, int64_t channel_value_satoshis) {
4645         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4646         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4647         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4648         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4649         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4650         return (uint64_t)ret_ret;
4651 }
4652
4653 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4654         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4655         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4656         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4657         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4658         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4659         return ret_arr;
4660 }
4661
4662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4663         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4664         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4665         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4666         LDKu8slice reader_ref;
4667         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4668         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4669         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4670         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4671         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4672         return (uint64_t)ret_conv;
4673 }
4674
4675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4676         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4677         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4678         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4679         LDKCVec_u8Z invoice_preimage_ref;
4680         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4681         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4682         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4683         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4684         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4685         return (uint64_t)ret_conv;
4686 }
4687
4688 typedef struct LDKFeeEstimator_JCalls {
4689         atomic_size_t refcnt;
4690         JavaVM *vm;
4691         jweak o;
4692         jmethodID get_est_sat_per_1000_weight_meth;
4693 } LDKFeeEstimator_JCalls;
4694 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4695         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4696         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4697                 JNIEnv *env;
4698                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4699                 if (get_jenv_res == JNI_EDETACHED) {
4700                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4701                 } else {
4702                         DO_ASSERT(get_jenv_res == JNI_OK);
4703                 }
4704                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4705                 if (get_jenv_res == JNI_EDETACHED) {
4706                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4707                 }
4708                 FREE(j_calls);
4709         }
4710 }
4711 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4712         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4713         JNIEnv *env;
4714         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4715         if (get_jenv_res == JNI_EDETACHED) {
4716                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4717         } else {
4718                 DO_ASSERT(get_jenv_res == JNI_OK);
4719         }
4720         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4721         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4722         CHECK(obj != NULL);
4723         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4724         if ((*env)->ExceptionCheck(env)) {
4725                 (*env)->ExceptionDescribe(env);
4726                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4727         }
4728         if (get_jenv_res == JNI_EDETACHED) {
4729                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4730         }
4731         return ret;
4732 }
4733 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4734         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4735         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4736 }
4737 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4738         jclass c = (*env)->GetObjectClass(env, o);
4739         CHECK(c != NULL);
4740         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4741         atomic_init(&calls->refcnt, 1);
4742         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4743         calls->o = (*env)->NewWeakGlobalRef(env, o);
4744         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4745         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4746
4747         LDKFeeEstimator ret = {
4748                 .this_arg = (void*) calls,
4749                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4750                 .free = LDKFeeEstimator_JCalls_free,
4751         };
4752         return ret;
4753 }
4754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4755         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4756         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4757         return (uint64_t)res_ptr;
4758 }
4759 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) {
4760         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4761         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4762         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4763         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4764         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4765         return ret_val;
4766 }
4767
4768 typedef struct LDKLogger_JCalls {
4769         atomic_size_t refcnt;
4770         JavaVM *vm;
4771         jweak o;
4772         jmethodID log_meth;
4773 } LDKLogger_JCalls;
4774 static void LDKLogger_JCalls_free(void* this_arg) {
4775         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4776         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4777                 JNIEnv *env;
4778                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4779                 if (get_jenv_res == JNI_EDETACHED) {
4780                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4781                 } else {
4782                         DO_ASSERT(get_jenv_res == JNI_OK);
4783                 }
4784                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4785                 if (get_jenv_res == JNI_EDETACHED) {
4786                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4787                 }
4788                 FREE(j_calls);
4789         }
4790 }
4791 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4792         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4793         JNIEnv *env;
4794         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4795         if (get_jenv_res == JNI_EDETACHED) {
4796                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4797         } else {
4798                 DO_ASSERT(get_jenv_res == JNI_OK);
4799         }
4800         LDKRecord record_var = *record;
4801         uint64_t record_ref = 0;
4802         record_var = Record_clone(record);
4803         CHECK((((uint64_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4804         CHECK((((uint64_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4805         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4806         record_ref = (uint64_t)record_var.inner;
4807         if (record_var.is_owned) {
4808                 record_ref |= 1;
4809         }
4810         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4811         CHECK(obj != NULL);
4812         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
4813         if ((*env)->ExceptionCheck(env)) {
4814                 (*env)->ExceptionDescribe(env);
4815                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4816         }
4817         if (get_jenv_res == JNI_EDETACHED) {
4818                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4819         }
4820 }
4821 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4822         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4823         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4824 }
4825 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4826         jclass c = (*env)->GetObjectClass(env, o);
4827         CHECK(c != NULL);
4828         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4829         atomic_init(&calls->refcnt, 1);
4830         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4831         calls->o = (*env)->NewWeakGlobalRef(env, o);
4832         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
4833         CHECK(calls->log_meth != NULL);
4834
4835         LDKLogger ret = {
4836                 .this_arg = (void*) calls,
4837                 .log = log_LDKLogger_jcall,
4838                 .free = LDKLogger_JCalls_free,
4839         };
4840         return ret;
4841 }
4842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4843         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4844         *res_ptr = LDKLogger_init(env, clz, o);
4845         return (uint64_t)res_ptr;
4846 }
4847 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4848         return ThirtyTwoBytes_clone(&tuple->a);
4849 }
4850 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4851         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4852         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4853         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data);
4854         return ret_arr;
4855 }
4856
4857 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4858         return &tuple->b;
4859 }
4860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4861         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4862         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
4863         uint64_t ret_ref = 0;
4864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4867         ret_ref = (uint64_t)ret_var.inner & ~1;
4868         return ret_ref;
4869 }
4870
4871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4872         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4873         CHECK(val->result_ok);
4874         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
4875         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
4876         return ((uint64_t)res_conv) | 1;
4877 }
4878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4879         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4880         CHECK(!val->result_ok);
4881         LDKDecodeError err_var = (*val->contents.err);
4882         uint64_t err_ref = 0;
4883         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4884         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4885         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4886         err_ref = (uint64_t)err_var.inner & ~1;
4887         return err_ref;
4888 }
4889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4890         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4891         CHECK(val->result_ok);
4892         LDKChannelConfig res_var = (*val->contents.result);
4893         uint64_t res_ref = 0;
4894         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4895         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4896         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4897         res_ref = (uint64_t)res_var.inner & ~1;
4898         return res_ref;
4899 }
4900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4901         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4902         CHECK(!val->result_ok);
4903         LDKDecodeError err_var = (*val->contents.err);
4904         uint64_t err_ref = 0;
4905         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4906         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4907         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4908         err_ref = (uint64_t)err_var.inner & ~1;
4909         return err_ref;
4910 }
4911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4912         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4913         CHECK(val->result_ok);
4914         LDKOutPoint res_var = (*val->contents.result);
4915         uint64_t res_ref = 0;
4916         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4917         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4918         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4919         res_ref = (uint64_t)res_var.inner & ~1;
4920         return res_ref;
4921 }
4922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4923         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4924         CHECK(!val->result_ok);
4925         LDKDecodeError err_var = (*val->contents.err);
4926         uint64_t err_ref = 0;
4927         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4928         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4929         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4930         err_ref = (uint64_t)err_var.inner & ~1;
4931         return err_ref;
4932 }
4933 typedef struct LDKType_JCalls {
4934         atomic_size_t refcnt;
4935         JavaVM *vm;
4936         jweak o;
4937         jmethodID type_id_meth;
4938         jmethodID debug_str_meth;
4939         jmethodID write_meth;
4940 } LDKType_JCalls;
4941 static void LDKType_JCalls_free(void* this_arg) {
4942         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4943         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4944                 JNIEnv *env;
4945                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4946                 if (get_jenv_res == JNI_EDETACHED) {
4947                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4948                 } else {
4949                         DO_ASSERT(get_jenv_res == JNI_OK);
4950                 }
4951                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4952                 if (get_jenv_res == JNI_EDETACHED) {
4953                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4954                 }
4955                 FREE(j_calls);
4956         }
4957 }
4958 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4959         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4960         JNIEnv *env;
4961         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4962         if (get_jenv_res == JNI_EDETACHED) {
4963                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4964         } else {
4965                 DO_ASSERT(get_jenv_res == JNI_OK);
4966         }
4967         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4968         CHECK(obj != NULL);
4969         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
4970         if ((*env)->ExceptionCheck(env)) {
4971                 (*env)->ExceptionDescribe(env);
4972                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
4973         }
4974         if (get_jenv_res == JNI_EDETACHED) {
4975                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4976         }
4977         return ret;
4978 }
4979 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4980         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4981         JNIEnv *env;
4982         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4983         if (get_jenv_res == JNI_EDETACHED) {
4984                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4985         } else {
4986                 DO_ASSERT(get_jenv_res == JNI_OK);
4987         }
4988         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4989         CHECK(obj != NULL);
4990         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
4991         if ((*env)->ExceptionCheck(env)) {
4992                 (*env)->ExceptionDescribe(env);
4993                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
4994         }
4995         LDKStr ret_conv = java_to_owned_str(env, ret);
4996         if (get_jenv_res == JNI_EDETACHED) {
4997                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4998         }
4999         return ret_conv;
5000 }
5001 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5002         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5003         JNIEnv *env;
5004         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5005         if (get_jenv_res == JNI_EDETACHED) {
5006                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5007         } else {
5008                 DO_ASSERT(get_jenv_res == JNI_OK);
5009         }
5010         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5011         CHECK(obj != NULL);
5012         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5013         if ((*env)->ExceptionCheck(env)) {
5014                 (*env)->ExceptionDescribe(env);
5015                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
5016         }
5017         LDKCVec_u8Z ret_ref;
5018         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5019         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5020         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5021         if (get_jenv_res == JNI_EDETACHED) {
5022                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5023         }
5024         return ret_ref;
5025 }
5026 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5027         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5028         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5029 }
5030 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
5031         jclass c = (*env)->GetObjectClass(env, o);
5032         CHECK(c != NULL);
5033         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5034         atomic_init(&calls->refcnt, 1);
5035         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5036         calls->o = (*env)->NewWeakGlobalRef(env, o);
5037         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
5038         CHECK(calls->type_id_meth != NULL);
5039         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
5040         CHECK(calls->debug_str_meth != NULL);
5041         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5042         CHECK(calls->write_meth != NULL);
5043
5044         LDKType ret = {
5045                 .this_arg = (void*) calls,
5046                 .type_id = type_id_LDKType_jcall,
5047                 .debug_str = debug_str_LDKType_jcall,
5048                 .write = write_LDKType_jcall,
5049                 .cloned = LDKType_JCalls_cloned,
5050                 .free = LDKType_JCalls_free,
5051         };
5052         return ret;
5053 }
5054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
5055         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5056         *res_ptr = LDKType_init(env, clz, o);
5057         return (uint64_t)res_ptr;
5058 }
5059 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5060         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5061         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5062         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5063         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5064         return ret_val;
5065 }
5066
5067 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
5068         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5069         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5070         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5071         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5072         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
5073         Str_free(ret_str);
5074         return ret_conv;
5075 }
5076
5077 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5078         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5079         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5080         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5081         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5082         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5083         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5084         CVec_u8Z_free(ret_var);
5085         return ret_arr;
5086 }
5087
5088 static jclass LDKCOption_TypeZ_Some_class = NULL;
5089 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
5090 static jclass LDKCOption_TypeZ_None_class = NULL;
5091 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
5092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
5093         LDKCOption_TypeZ_Some_class =
5094                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$Some;"));
5095         CHECK(LDKCOption_TypeZ_Some_class != NULL);
5096         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
5097         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
5098         LDKCOption_TypeZ_None_class =
5099                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$None;"));
5100         CHECK(LDKCOption_TypeZ_None_class != NULL);
5101         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
5102         CHECK(LDKCOption_TypeZ_None_meth != NULL);
5103 }
5104 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5105         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5106         switch(obj->tag) {
5107                 case LDKCOption_TypeZ_Some: {
5108                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5109                         *some_ret = Type_clone(&obj->some);
5110                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret);
5111                 }
5112                 case LDKCOption_TypeZ_None: {
5113                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
5114                 }
5115                 default: abort();
5116         }
5117 }
5118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5119         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
5120         CHECK(val->result_ok);
5121         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5122         return res_ref;
5123 }
5124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5125         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
5126         CHECK(!val->result_ok);
5127         LDKDecodeError err_var = (*val->contents.err);
5128         uint64_t err_ref = 0;
5129         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5130         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5131         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5132         err_ref = (uint64_t)err_var.inner & ~1;
5133         return err_ref;
5134 }
5135 static jclass LDKPaymentError_Invoice_class = NULL;
5136 static jmethodID LDKPaymentError_Invoice_meth = NULL;
5137 static jclass LDKPaymentError_Routing_class = NULL;
5138 static jmethodID LDKPaymentError_Routing_meth = NULL;
5139 static jclass LDKPaymentError_Sending_class = NULL;
5140 static jmethodID LDKPaymentError_Sending_meth = NULL;
5141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
5142         LDKPaymentError_Invoice_class =
5143                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Invoice;"));
5144         CHECK(LDKPaymentError_Invoice_class != NULL);
5145         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
5146         CHECK(LDKPaymentError_Invoice_meth != NULL);
5147         LDKPaymentError_Routing_class =
5148                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Routing;"));
5149         CHECK(LDKPaymentError_Routing_class != NULL);
5150         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
5151         CHECK(LDKPaymentError_Routing_meth != NULL);
5152         LDKPaymentError_Sending_class =
5153                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Sending;"));
5154         CHECK(LDKPaymentError_Sending_class != NULL);
5155         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
5156         CHECK(LDKPaymentError_Sending_meth != NULL);
5157 }
5158 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5159         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5160         switch(obj->tag) {
5161                 case LDKPaymentError_Invoice: {
5162                         LDKStr invoice_str = obj->invoice;
5163                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
5164                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
5165                 }
5166                 case LDKPaymentError_Routing: {
5167                         LDKLightningError routing_var = obj->routing;
5168                         uint64_t routing_ref = 0;
5169                         CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5170                         CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5171                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5172                         routing_ref = (uint64_t)routing_var.inner & ~1;
5173                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
5174                 }
5175                 case LDKPaymentError_Sending: {
5176                         uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
5177                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
5178                 }
5179                 default: abort();
5180         }
5181 }
5182 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5183         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
5184         CHECK(val->result_ok);
5185         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
5186         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
5187         return res_arr;
5188 }
5189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5190         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
5191         CHECK(!val->result_ok);
5192         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5193         return err_ref;
5194 }
5195 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5196         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
5197         CHECK(val->result_ok);
5198         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
5199         return res_conv;
5200 }
5201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5202         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
5203         CHECK(!val->result_ok);
5204         return *val->contents.err;
5205 }
5206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5207         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
5208         CHECK(val->result_ok);
5209         LDKInvoice res_var = (*val->contents.result);
5210         uint64_t res_ref = 0;
5211         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5212         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5213         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5214         res_ref = (uint64_t)res_var.inner & ~1;
5215         return res_ref;
5216 }
5217 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5218         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
5219         CHECK(!val->result_ok);
5220         return *val->contents.err;
5221 }
5222 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5223         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
5224         CHECK(val->result_ok);
5225         LDKSignedRawInvoice res_var = (*val->contents.result);
5226         uint64_t res_ref = 0;
5227         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5228         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5229         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5230         res_ref = (uint64_t)res_var.inner & ~1;
5231         return res_ref;
5232 }
5233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5234         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
5235         CHECK(!val->result_ok);
5236         return *val->contents.err;
5237 }
5238 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5239         return RawInvoice_clone(&tuple->a);
5240 }
5241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5242         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5243         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
5244         uint64_t ret_ref = 0;
5245         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5246         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5248         ret_ref = (uint64_t)ret_var.inner;
5249         if (ret_var.is_owned) {
5250                 ret_ref |= 1;
5251         }
5252         return ret_ref;
5253 }
5254
5255 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5256         return ThirtyTwoBytes_clone(&tuple->b);
5257 }
5258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5259         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5260         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5261         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data);
5262         return ret_arr;
5263 }
5264
5265 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5266         return InvoiceSignature_clone(&tuple->c);
5267 }
5268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5269         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5270         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
5271         uint64_t ret_ref = 0;
5272         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5273         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5274         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5275         ret_ref = (uint64_t)ret_var.inner;
5276         if (ret_var.is_owned) {
5277                 ret_ref |= 1;
5278         }
5279         return ret_ref;
5280 }
5281
5282 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5283         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
5284         CHECK(val->result_ok);
5285         LDKPayeePubKey res_var = (*val->contents.result);
5286         uint64_t res_ref = 0;
5287         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5288         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5289         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5290         res_ref = (uint64_t)res_var.inner & ~1;
5291         return res_ref;
5292 }
5293 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5294         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
5295         CHECK(!val->result_ok);
5296         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5297         return err_conv;
5298 }
5299 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5300         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5301         for (size_t i = 0; i < ret.datalen; i++) {
5302                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5303         }
5304         return ret;
5305 }
5306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5307         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
5308         CHECK(val->result_ok);
5309         LDKPositiveTimestamp res_var = (*val->contents.result);
5310         uint64_t res_ref = 0;
5311         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5312         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5313         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5314         res_ref = (uint64_t)res_var.inner & ~1;
5315         return res_ref;
5316 }
5317 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5318         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
5319         CHECK(!val->result_ok);
5320         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5321         return err_conv;
5322 }
5323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5324         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
5325         CHECK(val->result_ok);
5326         return *val->contents.result;
5327 }
5328 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5329         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
5330         CHECK(!val->result_ok);
5331         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
5332         return err_conv;
5333 }
5334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5335         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
5336         CHECK(val->result_ok);
5337         LDKInvoice res_var = (*val->contents.result);
5338         uint64_t res_ref = 0;
5339         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5340         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5341         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5342         res_ref = (uint64_t)res_var.inner & ~1;
5343         return res_ref;
5344 }
5345 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5346         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
5347         CHECK(!val->result_ok);
5348         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
5349         return err_conv;
5350 }
5351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5352         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5353         CHECK(val->result_ok);
5354         LDKDescription res_var = (*val->contents.result);
5355         uint64_t res_ref = 0;
5356         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5357         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5358         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5359         res_ref = (uint64_t)res_var.inner & ~1;
5360         return res_ref;
5361 }
5362 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5363         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5364         CHECK(!val->result_ok);
5365         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5366         return err_conv;
5367 }
5368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5369         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5370         CHECK(val->result_ok);
5371         LDKExpiryTime res_var = (*val->contents.result);
5372         uint64_t res_ref = 0;
5373         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5374         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5375         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5376         res_ref = (uint64_t)res_var.inner & ~1;
5377         return res_ref;
5378 }
5379 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5380         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5381         CHECK(!val->result_ok);
5382         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5383         return err_conv;
5384 }
5385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5386         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5387         CHECK(val->result_ok);
5388         LDKPrivateRoute res_var = (*val->contents.result);
5389         uint64_t res_ref = 0;
5390         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5391         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5392         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5393         res_ref = (uint64_t)res_var.inner & ~1;
5394         return res_ref;
5395 }
5396 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5397         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5398         CHECK(!val->result_ok);
5399         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5400         return err_conv;
5401 }
5402 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5403         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5404         CHECK(val->result_ok);
5405         LDKStr res_str = (*val->contents.result);
5406         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
5407         return res_conv;
5408 }
5409 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5410         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5411         CHECK(!val->result_ok);
5412         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5413         return err_conv;
5414 }
5415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5416         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5417         CHECK(val->result_ok);
5418         LDKChannelMonitorUpdate res_var = (*val->contents.result);
5419         uint64_t res_ref = 0;
5420         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5421         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5422         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5423         res_ref = (uint64_t)res_var.inner & ~1;
5424         return res_ref;
5425 }
5426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5427         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5428         CHECK(!val->result_ok);
5429         LDKDecodeError err_var = (*val->contents.err);
5430         uint64_t err_ref = 0;
5431         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5432         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5433         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5434         err_ref = (uint64_t)err_var.inner & ~1;
5435         return err_ref;
5436 }
5437 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
5438 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
5439 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
5440 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
5441 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
5442         LDKCOption_MonitorEventZ_Some_class =
5443                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some;"));
5444         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
5445         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
5446         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
5447         LDKCOption_MonitorEventZ_None_class =
5448                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_MonitorEventZ$None;"));
5449         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
5450         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
5451         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
5452 }
5453 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5454         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5455         switch(obj->tag) {
5456                 case LDKCOption_MonitorEventZ_Some: {
5457                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
5458                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
5459                 }
5460                 case LDKCOption_MonitorEventZ_None: {
5461                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
5462                 }
5463                 default: abort();
5464         }
5465 }
5466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5467         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
5468         CHECK(val->result_ok);
5469         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5470         return res_ref;
5471 }
5472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5473         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
5474         CHECK(!val->result_ok);
5475         LDKDecodeError err_var = (*val->contents.err);
5476         uint64_t err_ref = 0;
5477         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5478         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5479         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5480         err_ref = (uint64_t)err_var.inner & ~1;
5481         return err_ref;
5482 }
5483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5484         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5485         CHECK(val->result_ok);
5486         LDKHTLCUpdate res_var = (*val->contents.result);
5487         uint64_t res_ref = 0;
5488         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5489         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5490         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5491         res_ref = (uint64_t)res_var.inner & ~1;
5492         return res_ref;
5493 }
5494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5495         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5496         CHECK(!val->result_ok);
5497         LDKDecodeError err_var = (*val->contents.err);
5498         uint64_t err_ref = 0;
5499         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5500         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5501         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5502         err_ref = (uint64_t)err_var.inner & ~1;
5503         return err_ref;
5504 }
5505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5506         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5507         CHECK(val->result_ok);
5508         return *val->contents.result;
5509 }
5510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5511         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5512         CHECK(!val->result_ok);
5513         LDKMonitorUpdateError err_var = (*val->contents.err);
5514         uint64_t err_ref = 0;
5515         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5516         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5517         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5518         err_ref = (uint64_t)err_var.inner & ~1;
5519         return err_ref;
5520 }
5521 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5522         return OutPoint_clone(&tuple->a);
5523 }
5524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5525         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5526         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
5527         uint64_t ret_ref = 0;
5528         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5529         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5530         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5531         ret_ref = (uint64_t)ret_var.inner;
5532         if (ret_var.is_owned) {
5533                 ret_ref |= 1;
5534         }
5535         return ret_ref;
5536 }
5537
5538 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5539         return CVec_u8Z_clone(&tuple->b);
5540 }
5541 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5542         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5543         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
5544         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5545         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5546         CVec_u8Z_free(ret_var);
5547         return ret_arr;
5548 }
5549
5550 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5551         return tuple->a;
5552 }
5553 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5554         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5555         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
5556         return ret_val;
5557 }
5558
5559 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5560         return CVec_u8Z_clone(&tuple->b);
5561 }
5562 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5563         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5564         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
5565         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5566         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5567         CVec_u8Z_free(ret_var);
5568         return ret_arr;
5569 }
5570
5571 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5572         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5573         for (size_t i = 0; i < ret.datalen; i++) {
5574                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5575         }
5576         return ret;
5577 }
5578 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5579         return ThirtyTwoBytes_clone(&tuple->a);
5580 }
5581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5582         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5583         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5584         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data);
5585         return ret_arr;
5586 }
5587
5588 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5589         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
5590 }
5591 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5592         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5593         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
5594         int64_tArray ret_arr = NULL;
5595         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5596         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5597         for (size_t v = 0; v < ret_var.datalen; v++) {
5598                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5599                 *ret_conv_21_conv = ret_var.data[v];
5600                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
5601         }
5602         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5603         FREE(ret_var.data);
5604         return ret_arr;
5605 }
5606
5607 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5608         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 };
5609         for (size_t i = 0; i < ret.datalen; i++) {
5610                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5611         }
5612         return ret;
5613 }
5614 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5615         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5616         for (size_t i = 0; i < ret.datalen; i++) {
5617                 ret.data[i] = Event_clone(&orig->data[i]);
5618         }
5619         return ret;
5620 }
5621 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5622         return tuple->a;
5623 }
5624 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5625         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5626         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
5627         return ret_val;
5628 }
5629
5630 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5631         return TxOut_clone(&tuple->b);
5632 }
5633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5634         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5635         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5636         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
5637         return (uint64_t)ret_ref;
5638 }
5639
5640 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5641         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5642         for (size_t i = 0; i < ret.datalen; i++) {
5643                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5644         }
5645         return ret;
5646 }
5647 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5648         return ThirtyTwoBytes_clone(&tuple->a);
5649 }
5650 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5651         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5652         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5653         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data);
5654         return ret_arr;
5655 }
5656
5657 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5658         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
5659 }
5660 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5661         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5662         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
5663         int64_tArray ret_arr = NULL;
5664         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5665         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5666         for (size_t u = 0; u < ret_var.datalen; u++) {
5667                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5668                 *ret_conv_20_conv = ret_var.data[u];
5669                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
5670         }
5671         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5672         FREE(ret_var.data);
5673         return ret_arr;
5674 }
5675
5676 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5677         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 };
5678         for (size_t i = 0; i < ret.datalen; i++) {
5679                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5680         }
5681         return ret;
5682 }
5683 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
5684 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
5685 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
5686 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
5687 static jclass LDKBalance_ContentiousClaimable_class = NULL;
5688 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
5689 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
5690 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
5691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
5692         LDKBalance_ClaimableOnChannelClose_class =
5693                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose;"));
5694         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
5695         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
5696         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
5697         LDKBalance_ClaimableAwaitingConfirmations_class =
5698                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations;"));
5699         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
5700         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
5701         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
5702         LDKBalance_ContentiousClaimable_class =
5703                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ContentiousClaimable;"));
5704         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
5705         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
5706         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
5707         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
5708                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout;"));
5709         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
5710         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
5711         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
5712 }
5713 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5714         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5715         switch(obj->tag) {
5716                 case LDKBalance_ClaimableOnChannelClose: {
5717                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
5718                 }
5719                 case LDKBalance_ClaimableAwaitingConfirmations: {
5720                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
5721                 }
5722                 case LDKBalance_ContentiousClaimable: {
5723                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
5724                 }
5725                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
5726                         return (*env)->NewObject(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth, obj->maybe_claimable_htlc_awaiting_timeout.claimable_amount_satoshis, obj->maybe_claimable_htlc_awaiting_timeout.claimable_height);
5727                 }
5728                 default: abort();
5729         }
5730 }
5731 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5732         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5733         for (size_t i = 0; i < ret.datalen; i++) {
5734                 ret.data[i] = Balance_clone(&orig->data[i]);
5735         }
5736         return ret;
5737 }
5738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5739         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5740         CHECK(val->result_ok);
5741         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5742         *res_conv = (*val->contents.result);
5743         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
5744         return ((uint64_t)res_conv);
5745 }
5746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5747         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5748         CHECK(!val->result_ok);
5749         LDKDecodeError err_var = (*val->contents.err);
5750         uint64_t err_ref = 0;
5751         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5752         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5753         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5754         err_ref = (uint64_t)err_var.inner & ~1;
5755         return err_ref;
5756 }
5757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5758         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5759         CHECK(val->result_ok);
5760         return *val->contents.result;
5761 }
5762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5763         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5764         CHECK(!val->result_ok);
5765         LDKLightningError err_var = (*val->contents.err);
5766         uint64_t err_ref = 0;
5767         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5768         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5769         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5770         err_ref = (uint64_t)err_var.inner & ~1;
5771         return err_ref;
5772 }
5773 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5774         return tuple->a;
5775 }
5776 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5777         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5778         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5779         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form);
5780         return ret_arr;
5781 }
5782
5783 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5784         return Type_clone(&tuple->b);
5785 }
5786 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5787         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5788         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
5789         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
5790         return (uint64_t)ret_ret;
5791 }
5792
5793 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5794         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5795         for (size_t i = 0; i < ret.datalen; i++) {
5796                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5797         }
5798         return ret;
5799 }
5800 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5801         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5802         CHECK(val->result_ok);
5803         return *val->contents.result;
5804 }
5805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5806         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5807         CHECK(!val->result_ok);
5808         LDKLightningError err_var = (*val->contents.err);
5809         uint64_t err_ref = 0;
5810         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5811         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5812         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5813         err_ref = (uint64_t)err_var.inner & ~1;
5814         return err_ref;
5815 }
5816 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5817         return ChannelAnnouncement_clone(&tuple->a);
5818 }
5819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5820         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5821         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
5822         uint64_t ret_ref = 0;
5823         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5824         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5825         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5826         ret_ref = (uint64_t)ret_var.inner;
5827         if (ret_var.is_owned) {
5828                 ret_ref |= 1;
5829         }
5830         return ret_ref;
5831 }
5832
5833 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5834         return ChannelUpdate_clone(&tuple->b);
5835 }
5836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5837         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5838         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
5839         uint64_t ret_ref = 0;
5840         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5841         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5843         ret_ref = (uint64_t)ret_var.inner;
5844         if (ret_var.is_owned) {
5845                 ret_ref |= 1;
5846         }
5847         return ret_ref;
5848 }
5849
5850 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5851         return ChannelUpdate_clone(&tuple->c);
5852 }
5853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5854         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5855         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
5856         uint64_t ret_ref = 0;
5857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5860         ret_ref = (uint64_t)ret_var.inner;
5861         if (ret_var.is_owned) {
5862                 ret_ref |= 1;
5863         }
5864         return ret_ref;
5865 }
5866
5867 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5868         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5869         for (size_t i = 0; i < ret.datalen; i++) {
5870                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5871         }
5872         return ret;
5873 }
5874 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5875         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5876         for (size_t i = 0; i < ret.datalen; i++) {
5877                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5878         }
5879         return ret;
5880 }
5881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5882         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5883         CHECK(val->result_ok);
5884         LDKCVec_u8Z res_var = (*val->contents.result);
5885         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5886         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5887         return res_arr;
5888 }
5889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5890         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5891         CHECK(!val->result_ok);
5892         LDKPeerHandleError err_var = (*val->contents.err);
5893         uint64_t err_ref = 0;
5894         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5895         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5896         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5897         err_ref = (uint64_t)err_var.inner & ~1;
5898         return err_ref;
5899 }
5900 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5901         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5902         CHECK(val->result_ok);
5903         return *val->contents.result;
5904 }
5905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5906         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5907         CHECK(!val->result_ok);
5908         LDKPeerHandleError err_var = (*val->contents.err);
5909         uint64_t err_ref = 0;
5910         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5911         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5912         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5913         err_ref = (uint64_t)err_var.inner & ~1;
5914         return err_ref;
5915 }
5916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5917         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5918         CHECK(val->result_ok);
5919         return *val->contents.result;
5920 }
5921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5922         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5923         CHECK(!val->result_ok);
5924         LDKPeerHandleError err_var = (*val->contents.err);
5925         uint64_t err_ref = 0;
5926         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5927         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5928         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5929         err_ref = (uint64_t)err_var.inner & ~1;
5930         return err_ref;
5931 }
5932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5933         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
5934         CHECK(val->result_ok);
5935         LDKNodeId res_var = (*val->contents.result);
5936         uint64_t res_ref = 0;
5937         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5938         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5939         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5940         res_ref = (uint64_t)res_var.inner & ~1;
5941         return res_ref;
5942 }
5943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5944         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
5945         CHECK(!val->result_ok);
5946         LDKDecodeError err_var = (*val->contents.err);
5947         uint64_t err_ref = 0;
5948         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5949         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5950         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5951         err_ref = (uint64_t)err_var.inner & ~1;
5952         return err_ref;
5953 }
5954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5955         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
5956         CHECK(val->result_ok);
5957         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5958         return res_ref;
5959 }
5960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5961         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
5962         CHECK(!val->result_ok);
5963         LDKDecodeError err_var = (*val->contents.err);
5964         uint64_t err_ref = 0;
5965         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5966         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5967         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5968         err_ref = (uint64_t)err_var.inner & ~1;
5969         return err_ref;
5970 }
5971 typedef struct LDKAccess_JCalls {
5972         atomic_size_t refcnt;
5973         JavaVM *vm;
5974         jweak o;
5975         jmethodID get_utxo_meth;
5976 } LDKAccess_JCalls;
5977 static void LDKAccess_JCalls_free(void* this_arg) {
5978         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5979         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5980                 JNIEnv *env;
5981                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5982                 if (get_jenv_res == JNI_EDETACHED) {
5983                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5984                 } else {
5985                         DO_ASSERT(get_jenv_res == JNI_OK);
5986                 }
5987                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5988                 if (get_jenv_res == JNI_EDETACHED) {
5989                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5990                 }
5991                 FREE(j_calls);
5992         }
5993 }
5994 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
5995         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5996         JNIEnv *env;
5997         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5998         if (get_jenv_res == JNI_EDETACHED) {
5999                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6000         } else {
6001                 DO_ASSERT(get_jenv_res == JNI_OK);
6002         }
6003         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6004         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6005         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6006         CHECK(obj != NULL);
6007         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6008         if ((*env)->ExceptionCheck(env)) {
6009                 (*env)->ExceptionDescribe(env);
6010                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6011         }
6012         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6013         CHECK_ACCESS(ret_ptr);
6014         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6015         FREE((void*)ret);
6016         if (get_jenv_res == JNI_EDETACHED) {
6017                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6018         }
6019         return ret_conv;
6020 }
6021 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6022         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6023         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6024 }
6025 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6026         jclass c = (*env)->GetObjectClass(env, o);
6027         CHECK(c != NULL);
6028         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6029         atomic_init(&calls->refcnt, 1);
6030         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6031         calls->o = (*env)->NewWeakGlobalRef(env, o);
6032         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6033         CHECK(calls->get_utxo_meth != NULL);
6034
6035         LDKAccess ret = {
6036                 .this_arg = (void*) calls,
6037                 .get_utxo = get_utxo_LDKAccess_jcall,
6038                 .free = LDKAccess_JCalls_free,
6039         };
6040         return ret;
6041 }
6042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6043         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6044         *res_ptr = LDKAccess_init(env, clz, o);
6045         return (uint64_t)res_ptr;
6046 }
6047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Access_1get_1utxo(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray genesis_hash, int64_t short_channel_id) {
6048         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6049         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6050         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6051         unsigned char genesis_hash_arr[32];
6052         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6053         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6054         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6055         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6056         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6057         return (uint64_t)ret_conv;
6058 }
6059
6060 static jclass LDKCOption_AccessZ_Some_class = NULL;
6061 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
6062 static jclass LDKCOption_AccessZ_None_class = NULL;
6063 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
6064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
6065         LDKCOption_AccessZ_Some_class =
6066                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$Some;"));
6067         CHECK(LDKCOption_AccessZ_Some_class != NULL);
6068         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
6069         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
6070         LDKCOption_AccessZ_None_class =
6071                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$None;"));
6072         CHECK(LDKCOption_AccessZ_None_class != NULL);
6073         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
6074         CHECK(LDKCOption_AccessZ_None_meth != NULL);
6075 }
6076 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6077         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6078         switch(obj->tag) {
6079                 case LDKCOption_AccessZ_Some: {
6080                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6081                         *some_ret = obj->some;
6082                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
6083                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6084                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6085                                 LDKAccess_JCalls_cloned(&(*some_ret));
6086                         }
6087                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret);
6088                 }
6089                 case LDKCOption_AccessZ_None: {
6090                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
6091                 }
6092                 default: abort();
6093         }
6094 }
6095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6096         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6097         CHECK(val->result_ok);
6098         LDKDirectionalChannelInfo res_var = (*val->contents.result);
6099         uint64_t res_ref = 0;
6100         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6101         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6102         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6103         res_ref = (uint64_t)res_var.inner & ~1;
6104         return res_ref;
6105 }
6106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6107         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6108         CHECK(!val->result_ok);
6109         LDKDecodeError err_var = (*val->contents.err);
6110         uint64_t err_ref = 0;
6111         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6112         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6113         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6114         err_ref = (uint64_t)err_var.inner & ~1;
6115         return err_ref;
6116 }
6117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6118         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6119         CHECK(val->result_ok);
6120         LDKChannelInfo res_var = (*val->contents.result);
6121         uint64_t res_ref = 0;
6122         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6123         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6124         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6125         res_ref = (uint64_t)res_var.inner & ~1;
6126         return res_ref;
6127 }
6128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6129         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6130         CHECK(!val->result_ok);
6131         LDKDecodeError err_var = (*val->contents.err);
6132         uint64_t err_ref = 0;
6133         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6134         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6135         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6136         err_ref = (uint64_t)err_var.inner & ~1;
6137         return err_ref;
6138 }
6139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6140         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6141         CHECK(val->result_ok);
6142         LDKRoutingFees res_var = (*val->contents.result);
6143         uint64_t res_ref = 0;
6144         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6145         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6146         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6147         res_ref = (uint64_t)res_var.inner & ~1;
6148         return res_ref;
6149 }
6150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6151         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6152         CHECK(!val->result_ok);
6153         LDKDecodeError err_var = (*val->contents.err);
6154         uint64_t err_ref = 0;
6155         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6156         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6157         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6158         err_ref = (uint64_t)err_var.inner & ~1;
6159         return err_ref;
6160 }
6161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6162         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6163         CHECK(val->result_ok);
6164         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
6165         uint64_t res_ref = 0;
6166         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6167         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6168         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6169         res_ref = (uint64_t)res_var.inner & ~1;
6170         return res_ref;
6171 }
6172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6173         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6174         CHECK(!val->result_ok);
6175         LDKDecodeError err_var = (*val->contents.err);
6176         uint64_t err_ref = 0;
6177         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6178         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6179         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6180         err_ref = (uint64_t)err_var.inner & ~1;
6181         return err_ref;
6182 }
6183 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6184         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6185         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6186         return ret;
6187 }
6188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6189         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6190         CHECK(val->result_ok);
6191         LDKNodeInfo res_var = (*val->contents.result);
6192         uint64_t res_ref = 0;
6193         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6194         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6195         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6196         res_ref = (uint64_t)res_var.inner & ~1;
6197         return res_ref;
6198 }
6199 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6200         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6201         CHECK(!val->result_ok);
6202         LDKDecodeError err_var = (*val->contents.err);
6203         uint64_t err_ref = 0;
6204         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6205         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6206         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6207         err_ref = (uint64_t)err_var.inner & ~1;
6208         return err_ref;
6209 }
6210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6211         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6212         CHECK(val->result_ok);
6213         LDKNetworkGraph res_var = (*val->contents.result);
6214         uint64_t res_ref = 0;
6215         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6216         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6217         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6218         res_ref = (uint64_t)res_var.inner & ~1;
6219         return res_ref;
6220 }
6221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6222         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6223         CHECK(!val->result_ok);
6224         LDKDecodeError err_var = (*val->contents.err);
6225         uint64_t err_ref = 0;
6226         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6227         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6228         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6229         err_ref = (uint64_t)err_var.inner & ~1;
6230         return err_ref;
6231 }
6232 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
6233 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
6234 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
6235 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
6236 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
6237         LDKCOption_CVec_NetAddressZZ_Some_class =
6238                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some;"));
6239         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
6240         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
6241         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
6242         LDKCOption_CVec_NetAddressZZ_None_class =
6243                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None;"));
6244         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
6245         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
6246         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
6247 }
6248 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6249         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6250         switch(obj->tag) {
6251                 case LDKCOption_CVec_NetAddressZZ_Some: {
6252                         LDKCVec_NetAddressZ some_var = obj->some;
6253                         int64_tArray some_arr = NULL;
6254                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
6255                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
6256                         for (size_t m = 0; m < some_var.datalen; m++) {
6257                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
6258                                 some_arr_ptr[m] = some_conv_12_ref;
6259                         }
6260                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
6261                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
6262                 }
6263                 case LDKCOption_CVec_NetAddressZZ_None: {
6264                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
6265                 }
6266                 default: abort();
6267         }
6268 }
6269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6270         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6271         CHECK(val->result_ok);
6272         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6273         return res_ref;
6274 }
6275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6276         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6277         CHECK(!val->result_ok);
6278         LDKDecodeError err_var = (*val->contents.err);
6279         uint64_t err_ref = 0;
6280         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6281         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6282         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6283         err_ref = (uint64_t)err_var.inner & ~1;
6284         return err_ref;
6285 }
6286 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6287         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6288         for (size_t i = 0; i < ret.datalen; i++) {
6289                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6290         }
6291         return ret;
6292 }
6293 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6294         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6295         for (size_t i = 0; i < ret.datalen; i++) {
6296                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6297         }
6298         return ret;
6299 }
6300 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6301         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6302         for (size_t i = 0; i < ret.datalen; i++) {
6303                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6304         }
6305         return ret;
6306 }
6307 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6308         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6309         for (size_t i = 0; i < ret.datalen; i++) {
6310                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6311         }
6312         return ret;
6313 }
6314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6315         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6316         CHECK(val->result_ok);
6317         LDKAcceptChannel res_var = (*val->contents.result);
6318         uint64_t res_ref = 0;
6319         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6320         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6321         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6322         res_ref = (uint64_t)res_var.inner & ~1;
6323         return res_ref;
6324 }
6325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6326         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6327         CHECK(!val->result_ok);
6328         LDKDecodeError err_var = (*val->contents.err);
6329         uint64_t err_ref = 0;
6330         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6331         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6332         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6333         err_ref = (uint64_t)err_var.inner & ~1;
6334         return err_ref;
6335 }
6336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6337         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6338         CHECK(val->result_ok);
6339         LDKAnnouncementSignatures res_var = (*val->contents.result);
6340         uint64_t res_ref = 0;
6341         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6342         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6343         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6344         res_ref = (uint64_t)res_var.inner & ~1;
6345         return res_ref;
6346 }
6347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6348         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6349         CHECK(!val->result_ok);
6350         LDKDecodeError err_var = (*val->contents.err);
6351         uint64_t err_ref = 0;
6352         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6353         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6354         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6355         err_ref = (uint64_t)err_var.inner & ~1;
6356         return err_ref;
6357 }
6358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6359         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6360         CHECK(val->result_ok);
6361         LDKChannelReestablish res_var = (*val->contents.result);
6362         uint64_t res_ref = 0;
6363         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6364         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6365         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6366         res_ref = (uint64_t)res_var.inner & ~1;
6367         return res_ref;
6368 }
6369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6370         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6371         CHECK(!val->result_ok);
6372         LDKDecodeError err_var = (*val->contents.err);
6373         uint64_t err_ref = 0;
6374         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6375         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6376         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6377         err_ref = (uint64_t)err_var.inner & ~1;
6378         return err_ref;
6379 }
6380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6381         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6382         CHECK(val->result_ok);
6383         LDKClosingSigned res_var = (*val->contents.result);
6384         uint64_t res_ref = 0;
6385         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6386         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6387         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6388         res_ref = (uint64_t)res_var.inner & ~1;
6389         return res_ref;
6390 }
6391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6392         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6393         CHECK(!val->result_ok);
6394         LDKDecodeError err_var = (*val->contents.err);
6395         uint64_t err_ref = 0;
6396         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6397         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6398         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6399         err_ref = (uint64_t)err_var.inner & ~1;
6400         return err_ref;
6401 }
6402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6403         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6404         CHECK(val->result_ok);
6405         LDKClosingSignedFeeRange res_var = (*val->contents.result);
6406         uint64_t res_ref = 0;
6407         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6408         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6409         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6410         res_ref = (uint64_t)res_var.inner & ~1;
6411         return res_ref;
6412 }
6413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6414         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6415         CHECK(!val->result_ok);
6416         LDKDecodeError err_var = (*val->contents.err);
6417         uint64_t err_ref = 0;
6418         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6419         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6420         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6421         err_ref = (uint64_t)err_var.inner & ~1;
6422         return err_ref;
6423 }
6424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6425         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6426         CHECK(val->result_ok);
6427         LDKCommitmentSigned res_var = (*val->contents.result);
6428         uint64_t res_ref = 0;
6429         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6430         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6431         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6432         res_ref = (uint64_t)res_var.inner & ~1;
6433         return res_ref;
6434 }
6435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6436         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6437         CHECK(!val->result_ok);
6438         LDKDecodeError err_var = (*val->contents.err);
6439         uint64_t err_ref = 0;
6440         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6441         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6442         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6443         err_ref = (uint64_t)err_var.inner & ~1;
6444         return err_ref;
6445 }
6446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6447         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6448         CHECK(val->result_ok);
6449         LDKFundingCreated res_var = (*val->contents.result);
6450         uint64_t res_ref = 0;
6451         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6452         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6453         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6454         res_ref = (uint64_t)res_var.inner & ~1;
6455         return res_ref;
6456 }
6457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6458         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6459         CHECK(!val->result_ok);
6460         LDKDecodeError err_var = (*val->contents.err);
6461         uint64_t err_ref = 0;
6462         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6463         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6464         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6465         err_ref = (uint64_t)err_var.inner & ~1;
6466         return err_ref;
6467 }
6468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6469         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6470         CHECK(val->result_ok);
6471         LDKFundingSigned res_var = (*val->contents.result);
6472         uint64_t res_ref = 0;
6473         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6474         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6475         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6476         res_ref = (uint64_t)res_var.inner & ~1;
6477         return res_ref;
6478 }
6479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6480         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6481         CHECK(!val->result_ok);
6482         LDKDecodeError err_var = (*val->contents.err);
6483         uint64_t err_ref = 0;
6484         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6485         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6486         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6487         err_ref = (uint64_t)err_var.inner & ~1;
6488         return err_ref;
6489 }
6490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6491         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6492         CHECK(val->result_ok);
6493         LDKFundingLocked res_var = (*val->contents.result);
6494         uint64_t res_ref = 0;
6495         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6496         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6497         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6498         res_ref = (uint64_t)res_var.inner & ~1;
6499         return res_ref;
6500 }
6501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6502         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6503         CHECK(!val->result_ok);
6504         LDKDecodeError err_var = (*val->contents.err);
6505         uint64_t err_ref = 0;
6506         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6507         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6508         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6509         err_ref = (uint64_t)err_var.inner & ~1;
6510         return err_ref;
6511 }
6512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6513         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6514         CHECK(val->result_ok);
6515         LDKInit res_var = (*val->contents.result);
6516         uint64_t res_ref = 0;
6517         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6518         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6519         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6520         res_ref = (uint64_t)res_var.inner & ~1;
6521         return res_ref;
6522 }
6523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6524         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6525         CHECK(!val->result_ok);
6526         LDKDecodeError err_var = (*val->contents.err);
6527         uint64_t err_ref = 0;
6528         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6529         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6530         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6531         err_ref = (uint64_t)err_var.inner & ~1;
6532         return err_ref;
6533 }
6534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6535         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6536         CHECK(val->result_ok);
6537         LDKOpenChannel res_var = (*val->contents.result);
6538         uint64_t res_ref = 0;
6539         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6540         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6541         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6542         res_ref = (uint64_t)res_var.inner & ~1;
6543         return res_ref;
6544 }
6545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6546         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6547         CHECK(!val->result_ok);
6548         LDKDecodeError err_var = (*val->contents.err);
6549         uint64_t err_ref = 0;
6550         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6551         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6552         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6553         err_ref = (uint64_t)err_var.inner & ~1;
6554         return err_ref;
6555 }
6556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6557         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6558         CHECK(val->result_ok);
6559         LDKRevokeAndACK res_var = (*val->contents.result);
6560         uint64_t res_ref = 0;
6561         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6562         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6563         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6564         res_ref = (uint64_t)res_var.inner & ~1;
6565         return res_ref;
6566 }
6567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6568         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6569         CHECK(!val->result_ok);
6570         LDKDecodeError err_var = (*val->contents.err);
6571         uint64_t err_ref = 0;
6572         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6573         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6574         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6575         err_ref = (uint64_t)err_var.inner & ~1;
6576         return err_ref;
6577 }
6578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6579         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6580         CHECK(val->result_ok);
6581         LDKShutdown res_var = (*val->contents.result);
6582         uint64_t res_ref = 0;
6583         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6584         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6585         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6586         res_ref = (uint64_t)res_var.inner & ~1;
6587         return res_ref;
6588 }
6589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6590         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6591         CHECK(!val->result_ok);
6592         LDKDecodeError err_var = (*val->contents.err);
6593         uint64_t err_ref = 0;
6594         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6595         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6596         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6597         err_ref = (uint64_t)err_var.inner & ~1;
6598         return err_ref;
6599 }
6600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6601         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6602         CHECK(val->result_ok);
6603         LDKUpdateFailHTLC res_var = (*val->contents.result);
6604         uint64_t res_ref = 0;
6605         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6606         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6607         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6608         res_ref = (uint64_t)res_var.inner & ~1;
6609         return res_ref;
6610 }
6611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6612         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6613         CHECK(!val->result_ok);
6614         LDKDecodeError err_var = (*val->contents.err);
6615         uint64_t err_ref = 0;
6616         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6617         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6618         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6619         err_ref = (uint64_t)err_var.inner & ~1;
6620         return err_ref;
6621 }
6622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6623         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6624         CHECK(val->result_ok);
6625         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
6626         uint64_t res_ref = 0;
6627         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6628         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6629         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6630         res_ref = (uint64_t)res_var.inner & ~1;
6631         return res_ref;
6632 }
6633 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6634         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6635         CHECK(!val->result_ok);
6636         LDKDecodeError err_var = (*val->contents.err);
6637         uint64_t err_ref = 0;
6638         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6639         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6640         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6641         err_ref = (uint64_t)err_var.inner & ~1;
6642         return err_ref;
6643 }
6644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6645         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6646         CHECK(val->result_ok);
6647         LDKUpdateFee res_var = (*val->contents.result);
6648         uint64_t res_ref = 0;
6649         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6650         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6651         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6652         res_ref = (uint64_t)res_var.inner & ~1;
6653         return res_ref;
6654 }
6655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6656         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6657         CHECK(!val->result_ok);
6658         LDKDecodeError err_var = (*val->contents.err);
6659         uint64_t err_ref = 0;
6660         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6661         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6662         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6663         err_ref = (uint64_t)err_var.inner & ~1;
6664         return err_ref;
6665 }
6666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6667         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6668         CHECK(val->result_ok);
6669         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
6670         uint64_t res_ref = 0;
6671         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6672         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6673         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6674         res_ref = (uint64_t)res_var.inner & ~1;
6675         return res_ref;
6676 }
6677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6678         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6679         CHECK(!val->result_ok);
6680         LDKDecodeError err_var = (*val->contents.err);
6681         uint64_t err_ref = 0;
6682         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6683         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6684         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6685         err_ref = (uint64_t)err_var.inner & ~1;
6686         return err_ref;
6687 }
6688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6689         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6690         CHECK(val->result_ok);
6691         LDKUpdateAddHTLC res_var = (*val->contents.result);
6692         uint64_t res_ref = 0;
6693         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6694         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6695         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6696         res_ref = (uint64_t)res_var.inner & ~1;
6697         return res_ref;
6698 }
6699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6700         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6701         CHECK(!val->result_ok);
6702         LDKDecodeError err_var = (*val->contents.err);
6703         uint64_t err_ref = 0;
6704         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6705         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6706         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6707         err_ref = (uint64_t)err_var.inner & ~1;
6708         return err_ref;
6709 }
6710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6711         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6712         CHECK(val->result_ok);
6713         LDKPing res_var = (*val->contents.result);
6714         uint64_t res_ref = 0;
6715         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6716         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6717         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6718         res_ref = (uint64_t)res_var.inner & ~1;
6719         return res_ref;
6720 }
6721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6722         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6723         CHECK(!val->result_ok);
6724         LDKDecodeError err_var = (*val->contents.err);
6725         uint64_t err_ref = 0;
6726         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6727         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6728         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6729         err_ref = (uint64_t)err_var.inner & ~1;
6730         return err_ref;
6731 }
6732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6733         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6734         CHECK(val->result_ok);
6735         LDKPong res_var = (*val->contents.result);
6736         uint64_t res_ref = 0;
6737         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6738         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6739         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6740         res_ref = (uint64_t)res_var.inner & ~1;
6741         return res_ref;
6742 }
6743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6744         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6745         CHECK(!val->result_ok);
6746         LDKDecodeError err_var = (*val->contents.err);
6747         uint64_t err_ref = 0;
6748         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6749         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6750         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6751         err_ref = (uint64_t)err_var.inner & ~1;
6752         return err_ref;
6753 }
6754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6755         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6756         CHECK(val->result_ok);
6757         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
6758         uint64_t res_ref = 0;
6759         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6760         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6761         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6762         res_ref = (uint64_t)res_var.inner & ~1;
6763         return res_ref;
6764 }
6765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6766         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6767         CHECK(!val->result_ok);
6768         LDKDecodeError err_var = (*val->contents.err);
6769         uint64_t err_ref = 0;
6770         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6771         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6772         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6773         err_ref = (uint64_t)err_var.inner & ~1;
6774         return err_ref;
6775 }
6776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6777         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6778         CHECK(val->result_ok);
6779         LDKChannelAnnouncement res_var = (*val->contents.result);
6780         uint64_t res_ref = 0;
6781         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6782         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6783         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6784         res_ref = (uint64_t)res_var.inner & ~1;
6785         return res_ref;
6786 }
6787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6788         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6789         CHECK(!val->result_ok);
6790         LDKDecodeError err_var = (*val->contents.err);
6791         uint64_t err_ref = 0;
6792         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6793         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6794         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6795         err_ref = (uint64_t)err_var.inner & ~1;
6796         return err_ref;
6797 }
6798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6799         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6800         CHECK(val->result_ok);
6801         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
6802         uint64_t res_ref = 0;
6803         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6804         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6805         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6806         res_ref = (uint64_t)res_var.inner & ~1;
6807         return res_ref;
6808 }
6809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6810         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6811         CHECK(!val->result_ok);
6812         LDKDecodeError err_var = (*val->contents.err);
6813         uint64_t err_ref = 0;
6814         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6815         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6816         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6817         err_ref = (uint64_t)err_var.inner & ~1;
6818         return err_ref;
6819 }
6820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6821         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6822         CHECK(val->result_ok);
6823         LDKChannelUpdate res_var = (*val->contents.result);
6824         uint64_t res_ref = 0;
6825         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6826         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6827         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6828         res_ref = (uint64_t)res_var.inner & ~1;
6829         return res_ref;
6830 }
6831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6832         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6833         CHECK(!val->result_ok);
6834         LDKDecodeError err_var = (*val->contents.err);
6835         uint64_t err_ref = 0;
6836         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6837         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6838         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6839         err_ref = (uint64_t)err_var.inner & ~1;
6840         return err_ref;
6841 }
6842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6843         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6844         CHECK(val->result_ok);
6845         LDKErrorMessage res_var = (*val->contents.result);
6846         uint64_t res_ref = 0;
6847         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6848         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6849         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6850         res_ref = (uint64_t)res_var.inner & ~1;
6851         return res_ref;
6852 }
6853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6854         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6855         CHECK(!val->result_ok);
6856         LDKDecodeError err_var = (*val->contents.err);
6857         uint64_t err_ref = 0;
6858         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6859         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6860         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6861         err_ref = (uint64_t)err_var.inner & ~1;
6862         return err_ref;
6863 }
6864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6865         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6866         CHECK(val->result_ok);
6867         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
6868         uint64_t res_ref = 0;
6869         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6870         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6871         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6872         res_ref = (uint64_t)res_var.inner & ~1;
6873         return res_ref;
6874 }
6875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6876         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6877         CHECK(!val->result_ok);
6878         LDKDecodeError err_var = (*val->contents.err);
6879         uint64_t err_ref = 0;
6880         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6881         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6882         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6883         err_ref = (uint64_t)err_var.inner & ~1;
6884         return err_ref;
6885 }
6886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6887         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6888         CHECK(val->result_ok);
6889         LDKNodeAnnouncement res_var = (*val->contents.result);
6890         uint64_t res_ref = 0;
6891         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6892         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6893         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6894         res_ref = (uint64_t)res_var.inner & ~1;
6895         return res_ref;
6896 }
6897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6898         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6899         CHECK(!val->result_ok);
6900         LDKDecodeError err_var = (*val->contents.err);
6901         uint64_t err_ref = 0;
6902         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6903         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6904         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6905         err_ref = (uint64_t)err_var.inner & ~1;
6906         return err_ref;
6907 }
6908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6909         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6910         CHECK(val->result_ok);
6911         LDKQueryShortChannelIds res_var = (*val->contents.result);
6912         uint64_t res_ref = 0;
6913         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6914         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6915         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6916         res_ref = (uint64_t)res_var.inner & ~1;
6917         return res_ref;
6918 }
6919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6920         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6921         CHECK(!val->result_ok);
6922         LDKDecodeError err_var = (*val->contents.err);
6923         uint64_t err_ref = 0;
6924         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6925         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6926         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6927         err_ref = (uint64_t)err_var.inner & ~1;
6928         return err_ref;
6929 }
6930 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6931         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6932         CHECK(val->result_ok);
6933         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
6934         uint64_t res_ref = 0;
6935         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6936         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6937         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6938         res_ref = (uint64_t)res_var.inner & ~1;
6939         return res_ref;
6940 }
6941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6942         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6943         CHECK(!val->result_ok);
6944         LDKDecodeError err_var = (*val->contents.err);
6945         uint64_t err_ref = 0;
6946         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6947         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6948         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6949         err_ref = (uint64_t)err_var.inner & ~1;
6950         return err_ref;
6951 }
6952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6953         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6954         CHECK(val->result_ok);
6955         LDKQueryChannelRange res_var = (*val->contents.result);
6956         uint64_t res_ref = 0;
6957         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6958         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6959         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6960         res_ref = (uint64_t)res_var.inner & ~1;
6961         return res_ref;
6962 }
6963 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6964         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6965         CHECK(!val->result_ok);
6966         LDKDecodeError err_var = (*val->contents.err);
6967         uint64_t err_ref = 0;
6968         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6969         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6970         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6971         err_ref = (uint64_t)err_var.inner & ~1;
6972         return err_ref;
6973 }
6974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6975         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6976         CHECK(val->result_ok);
6977         LDKReplyChannelRange res_var = (*val->contents.result);
6978         uint64_t res_ref = 0;
6979         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6980         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6981         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6982         res_ref = (uint64_t)res_var.inner & ~1;
6983         return res_ref;
6984 }
6985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6986         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6987         CHECK(!val->result_ok);
6988         LDKDecodeError err_var = (*val->contents.err);
6989         uint64_t err_ref = 0;
6990         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6991         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6992         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6993         err_ref = (uint64_t)err_var.inner & ~1;
6994         return err_ref;
6995 }
6996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6997         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
6998         CHECK(val->result_ok);
6999         LDKGossipTimestampFilter res_var = (*val->contents.result);
7000         uint64_t res_ref = 0;
7001         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7002         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7003         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7004         res_ref = (uint64_t)res_var.inner & ~1;
7005         return res_ref;
7006 }
7007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7008         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7009         CHECK(!val->result_ok);
7010         LDKDecodeError err_var = (*val->contents.err);
7011         uint64_t err_ref = 0;
7012         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7013         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7014         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7015         err_ref = (uint64_t)err_var.inner & ~1;
7016         return err_ref;
7017 }
7018 static jclass LDKSignOrCreationError_SignError_class = NULL;
7019 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
7020 static jclass LDKSignOrCreationError_CreationError_class = NULL;
7021 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
7022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
7023         LDKSignOrCreationError_SignError_class =
7024                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
7025         CHECK(LDKSignOrCreationError_SignError_class != NULL);
7026         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
7027         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
7028         LDKSignOrCreationError_CreationError_class =
7029                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
7030         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
7031         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
7032         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
7033 }
7034 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7035         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7036         switch(obj->tag) {
7037                 case LDKSignOrCreationError_SignError: {
7038                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
7039                 }
7040                 case LDKSignOrCreationError_CreationError: {
7041                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
7042                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
7043                 }
7044                 default: abort();
7045         }
7046 }
7047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7048         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7049         CHECK(val->result_ok);
7050         LDKInvoice res_var = (*val->contents.result);
7051         uint64_t res_ref = 0;
7052         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7053         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7054         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7055         res_ref = (uint64_t)res_var.inner & ~1;
7056         return res_ref;
7057 }
7058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7059         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7060         CHECK(!val->result_ok);
7061         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
7062         return err_ref;
7063 }
7064 typedef struct LDKFilter_JCalls {
7065         atomic_size_t refcnt;
7066         JavaVM *vm;
7067         jweak o;
7068         jmethodID register_tx_meth;
7069         jmethodID register_output_meth;
7070 } LDKFilter_JCalls;
7071 static void LDKFilter_JCalls_free(void* this_arg) {
7072         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7073         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7074                 JNIEnv *env;
7075                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7076                 if (get_jenv_res == JNI_EDETACHED) {
7077                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7078                 } else {
7079                         DO_ASSERT(get_jenv_res == JNI_OK);
7080                 }
7081                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7082                 if (get_jenv_res == JNI_EDETACHED) {
7083                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7084                 }
7085                 FREE(j_calls);
7086         }
7087 }
7088 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7089         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7090         JNIEnv *env;
7091         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7092         if (get_jenv_res == JNI_EDETACHED) {
7093                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7094         } else {
7095                 DO_ASSERT(get_jenv_res == JNI_OK);
7096         }
7097         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7098         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7099         LDKu8slice script_pubkey_var = script_pubkey;
7100         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
7101         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
7102         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7103         CHECK(obj != NULL);
7104         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
7105         if ((*env)->ExceptionCheck(env)) {
7106                 (*env)->ExceptionDescribe(env);
7107                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
7108         }
7109         if (get_jenv_res == JNI_EDETACHED) {
7110                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7111         }
7112 }
7113 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7114         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7115         JNIEnv *env;
7116         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7117         if (get_jenv_res == JNI_EDETACHED) {
7118                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7119         } else {
7120                 DO_ASSERT(get_jenv_res == JNI_OK);
7121         }
7122         LDKWatchedOutput output_var = output;
7123         uint64_t output_ref = 0;
7124         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7125         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7126         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7127         output_ref = (uint64_t)output_var.inner;
7128         if (output_var.is_owned) {
7129                 output_ref |= 1;
7130         }
7131         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7132         CHECK(obj != NULL);
7133         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7134         if ((*env)->ExceptionCheck(env)) {
7135                 (*env)->ExceptionDescribe(env);
7136                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7137         }
7138         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7139         CHECK_ACCESS(ret_ptr);
7140         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7141         FREE((void*)ret);
7142         if (get_jenv_res == JNI_EDETACHED) {
7143                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7144         }
7145         return ret_conv;
7146 }
7147 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7148         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7149         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7150 }
7151 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7152         jclass c = (*env)->GetObjectClass(env, o);
7153         CHECK(c != NULL);
7154         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7155         atomic_init(&calls->refcnt, 1);
7156         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7157         calls->o = (*env)->NewWeakGlobalRef(env, o);
7158         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7159         CHECK(calls->register_tx_meth != NULL);
7160         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7161         CHECK(calls->register_output_meth != NULL);
7162
7163         LDKFilter ret = {
7164                 .this_arg = (void*) calls,
7165                 .register_tx = register_tx_LDKFilter_jcall,
7166                 .register_output = register_output_LDKFilter_jcall,
7167                 .free = LDKFilter_JCalls_free,
7168         };
7169         return ret;
7170 }
7171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7172         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7173         *res_ptr = LDKFilter_init(env, clz, o);
7174         return (uint64_t)res_ptr;
7175 }
7176 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) {
7177         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7178         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7179         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7180         unsigned char txid_arr[32];
7181         CHECK((*env)->GetArrayLength(env, txid) == 32);
7182         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7183         unsigned char (*txid_ref)[32] = &txid_arr;
7184         LDKu8slice script_pubkey_ref;
7185         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7186         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7187         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7188         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7189 }
7190
7191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7192         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7193         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7194         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7195         LDKWatchedOutput output_conv;
7196         output_conv.inner = (void*)(output & (~1));
7197         output_conv.is_owned = (output & 1) || (output == 0);
7198         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7199         output_conv = WatchedOutput_clone(&output_conv);
7200         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7201         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7202         uint64_t ret_ref = (uint64_t)ret_copy;
7203         return ret_ref;
7204 }
7205
7206 static jclass LDKCOption_FilterZ_Some_class = NULL;
7207 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
7208 static jclass LDKCOption_FilterZ_None_class = NULL;
7209 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
7210 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
7211         LDKCOption_FilterZ_Some_class =
7212                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$Some;"));
7213         CHECK(LDKCOption_FilterZ_Some_class != NULL);
7214         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
7215         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
7216         LDKCOption_FilterZ_None_class =
7217                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$None;"));
7218         CHECK(LDKCOption_FilterZ_None_class != NULL);
7219         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
7220         CHECK(LDKCOption_FilterZ_None_meth != NULL);
7221 }
7222 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7223         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7224         switch(obj->tag) {
7225                 case LDKCOption_FilterZ_Some: {
7226                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7227                         *some_ret = obj->some;
7228                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
7229                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7230                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7231                                 LDKFilter_JCalls_cloned(&(*some_ret));
7232                         }
7233                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret);
7234                 }
7235                 case LDKCOption_FilterZ_None: {
7236                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
7237                 }
7238                 default: abort();
7239         }
7240 }
7241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7242         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7243         CHECK(val->result_ok);
7244         LDKLockedChannelMonitor res_var = (*val->contents.result);
7245         uint64_t res_ref = 0;
7246         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7247         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7248         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7249         res_ref = (uint64_t)res_var.inner & ~1;
7250         return res_ref;
7251 }
7252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7253         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7254         CHECK(!val->result_ok);
7255         return *val->contents.err;
7256 }
7257 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7258         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7259         for (size_t i = 0; i < ret.datalen; i++) {
7260                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7261         }
7262         return ret;
7263 }
7264 typedef struct LDKMessageSendEventsProvider_JCalls {
7265         atomic_size_t refcnt;
7266         JavaVM *vm;
7267         jweak o;
7268         jmethodID get_and_clear_pending_msg_events_meth;
7269 } LDKMessageSendEventsProvider_JCalls;
7270 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7271         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7272         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7273                 JNIEnv *env;
7274                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7275                 if (get_jenv_res == JNI_EDETACHED) {
7276                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7277                 } else {
7278                         DO_ASSERT(get_jenv_res == JNI_OK);
7279                 }
7280                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7281                 if (get_jenv_res == JNI_EDETACHED) {
7282                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7283                 }
7284                 FREE(j_calls);
7285         }
7286 }
7287 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7288         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7289         JNIEnv *env;
7290         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7291         if (get_jenv_res == JNI_EDETACHED) {
7292                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7293         } else {
7294                 DO_ASSERT(get_jenv_res == JNI_OK);
7295         }
7296         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7297         CHECK(obj != NULL);
7298         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
7299         if ((*env)->ExceptionCheck(env)) {
7300                 (*env)->ExceptionDescribe(env);
7301                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
7302         }
7303         LDKCVec_MessageSendEventZ ret_constr;
7304         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7305         if (ret_constr.datalen > 0)
7306                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7307         else
7308                 ret_constr.data = NULL;
7309         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7310         for (size_t s = 0; s < ret_constr.datalen; s++) {
7311                 int64_t ret_conv_18 = ret_vals[s];
7312                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
7313                 CHECK_ACCESS(ret_conv_18_ptr);
7314                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7315                 FREE((void*)ret_conv_18);
7316                 ret_constr.data[s] = ret_conv_18_conv;
7317         }
7318         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7319         if (get_jenv_res == JNI_EDETACHED) {
7320                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7321         }
7322         return ret_constr;
7323 }
7324 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7325         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7326         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7327 }
7328 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7329         jclass c = (*env)->GetObjectClass(env, o);
7330         CHECK(c != NULL);
7331         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7332         atomic_init(&calls->refcnt, 1);
7333         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7334         calls->o = (*env)->NewWeakGlobalRef(env, o);
7335         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
7336         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
7337
7338         LDKMessageSendEventsProvider ret = {
7339                 .this_arg = (void*) calls,
7340                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7341                 .free = LDKMessageSendEventsProvider_JCalls_free,
7342         };
7343         return ret;
7344 }
7345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7346         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7347         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
7348         return (uint64_t)res_ptr;
7349 }
7350 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7351         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7352         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7353         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7354         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7355         int64_tArray ret_arr = NULL;
7356         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7357         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7358         for (size_t s = 0; s < ret_var.datalen; s++) {
7359                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7360                 *ret_conv_18_copy = ret_var.data[s];
7361                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
7362                 ret_arr_ptr[s] = ret_conv_18_ref;
7363         }
7364         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7365         FREE(ret_var.data);
7366         return ret_arr;
7367 }
7368
7369 typedef struct LDKEventHandler_JCalls {
7370         atomic_size_t refcnt;
7371         JavaVM *vm;
7372         jweak o;
7373         jmethodID handle_event_meth;
7374 } LDKEventHandler_JCalls;
7375 static void LDKEventHandler_JCalls_free(void* this_arg) {
7376         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7377         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7378                 JNIEnv *env;
7379                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7380                 if (get_jenv_res == JNI_EDETACHED) {
7381                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7382                 } else {
7383                         DO_ASSERT(get_jenv_res == JNI_OK);
7384                 }
7385                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7386                 if (get_jenv_res == JNI_EDETACHED) {
7387                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7388                 }
7389                 FREE(j_calls);
7390         }
7391 }
7392 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7393         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7394         JNIEnv *env;
7395         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7396         if (get_jenv_res == JNI_EDETACHED) {
7397                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7398         } else {
7399                 DO_ASSERT(get_jenv_res == JNI_OK);
7400         }
7401         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7402         *ret_event = Event_clone(event);
7403         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7404         CHECK(obj != NULL);
7405         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event);
7406         if ((*env)->ExceptionCheck(env)) {
7407                 (*env)->ExceptionDescribe(env);
7408                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
7409         }
7410         if (get_jenv_res == JNI_EDETACHED) {
7411                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7412         }
7413 }
7414 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7415         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7416         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7417 }
7418 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
7419         jclass c = (*env)->GetObjectClass(env, o);
7420         CHECK(c != NULL);
7421         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7422         atomic_init(&calls->refcnt, 1);
7423         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7424         calls->o = (*env)->NewWeakGlobalRef(env, o);
7425         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
7426         CHECK(calls->handle_event_meth != NULL);
7427
7428         LDKEventHandler ret = {
7429                 .this_arg = (void*) calls,
7430                 .handle_event = handle_event_LDKEventHandler_jcall,
7431                 .free = LDKEventHandler_JCalls_free,
7432         };
7433         return ret;
7434 }
7435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
7436         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7437         *res_ptr = LDKEventHandler_init(env, clz, o);
7438         return (uint64_t)res_ptr;
7439 }
7440 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
7441         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7442         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7443         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
7444         LDKEvent* event_conv = (LDKEvent*)event;
7445         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
7446 }
7447
7448 typedef struct LDKEventsProvider_JCalls {
7449         atomic_size_t refcnt;
7450         JavaVM *vm;
7451         jweak o;
7452         jmethodID process_pending_events_meth;
7453 } LDKEventsProvider_JCalls;
7454 static void LDKEventsProvider_JCalls_free(void* this_arg) {
7455         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7456         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7457                 JNIEnv *env;
7458                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7459                 if (get_jenv_res == JNI_EDETACHED) {
7460                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7461                 } else {
7462                         DO_ASSERT(get_jenv_res == JNI_OK);
7463                 }
7464                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7465                 if (get_jenv_res == JNI_EDETACHED) {
7466                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7467                 }
7468                 FREE(j_calls);
7469         }
7470 }
7471 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
7472         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7473         JNIEnv *env;
7474         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7475         if (get_jenv_res == JNI_EDETACHED) {
7476                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7477         } else {
7478                 DO_ASSERT(get_jenv_res == JNI_OK);
7479         }
7480         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7481         *handler_ret = handler;
7482         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7483         CHECK(obj != NULL);
7484         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret);
7485         if ((*env)->ExceptionCheck(env)) {
7486                 (*env)->ExceptionDescribe(env);
7487                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
7488         }
7489         if (get_jenv_res == JNI_EDETACHED) {
7490                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7491         }
7492 }
7493 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
7494         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
7495         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7496 }
7497 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7498         jclass c = (*env)->GetObjectClass(env, o);
7499         CHECK(c != NULL);
7500         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
7501         atomic_init(&calls->refcnt, 1);
7502         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7503         calls->o = (*env)->NewWeakGlobalRef(env, o);
7504         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
7505         CHECK(calls->process_pending_events_meth != NULL);
7506
7507         LDKEventsProvider ret = {
7508                 .this_arg = (void*) calls,
7509                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
7510                 .free = LDKEventsProvider_JCalls_free,
7511         };
7512         return ret;
7513 }
7514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7515         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7516         *res_ptr = LDKEventsProvider_init(env, clz, o);
7517         return (uint64_t)res_ptr;
7518 }
7519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
7520         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7521         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7522         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
7523         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
7524         CHECK_ACCESS(handler_ptr);
7525         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
7526         if (handler_conv.free == LDKEventHandler_JCalls_free) {
7527                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7528                 LDKEventHandler_JCalls_cloned(&handler_conv);
7529         }
7530         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
7531 }
7532
7533 typedef struct LDKListen_JCalls {
7534         atomic_size_t refcnt;
7535         JavaVM *vm;
7536         jweak o;
7537         jmethodID block_connected_meth;
7538         jmethodID block_disconnected_meth;
7539 } LDKListen_JCalls;
7540 static void LDKListen_JCalls_free(void* this_arg) {
7541         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7542         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7543                 JNIEnv *env;
7544                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7545                 if (get_jenv_res == JNI_EDETACHED) {
7546                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7547                 } else {
7548                         DO_ASSERT(get_jenv_res == JNI_OK);
7549                 }
7550                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7551                 if (get_jenv_res == JNI_EDETACHED) {
7552                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7553                 }
7554                 FREE(j_calls);
7555         }
7556 }
7557 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
7558         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7559         JNIEnv *env;
7560         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7561         if (get_jenv_res == JNI_EDETACHED) {
7562                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7563         } else {
7564                 DO_ASSERT(get_jenv_res == JNI_OK);
7565         }
7566         LDKu8slice block_var = block;
7567         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
7568         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
7569         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7570         CHECK(obj != NULL);
7571         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
7572         if ((*env)->ExceptionCheck(env)) {
7573                 (*env)->ExceptionDescribe(env);
7574                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
7575         }
7576         if (get_jenv_res == JNI_EDETACHED) {
7577                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7578         }
7579 }
7580 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7581         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7582         JNIEnv *env;
7583         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7584         if (get_jenv_res == JNI_EDETACHED) {
7585                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7586         } else {
7587                 DO_ASSERT(get_jenv_res == JNI_OK);
7588         }
7589         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7590         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7592         CHECK(obj != NULL);
7593         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
7594         if ((*env)->ExceptionCheck(env)) {
7595                 (*env)->ExceptionDescribe(env);
7596                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
7597         }
7598         if (get_jenv_res == JNI_EDETACHED) {
7599                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7600         }
7601 }
7602 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
7603         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
7604         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7605 }
7606 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
7607         jclass c = (*env)->GetObjectClass(env, o);
7608         CHECK(c != NULL);
7609         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
7610         atomic_init(&calls->refcnt, 1);
7611         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7612         calls->o = (*env)->NewWeakGlobalRef(env, o);
7613         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
7614         CHECK(calls->block_connected_meth != NULL);
7615         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
7616         CHECK(calls->block_disconnected_meth != NULL);
7617
7618         LDKListen ret = {
7619                 .this_arg = (void*) calls,
7620                 .block_connected = block_connected_LDKListen_jcall,
7621                 .block_disconnected = block_disconnected_LDKListen_jcall,
7622                 .free = LDKListen_JCalls_free,
7623         };
7624         return ret;
7625 }
7626 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
7627         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7628         *res_ptr = LDKListen_init(env, clz, o);
7629         return (uint64_t)res_ptr;
7630 }
7631 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) {
7632         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7633         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7634         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7635         LDKu8slice block_ref;
7636         block_ref.datalen = (*env)->GetArrayLength(env, block);
7637         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
7638         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7639         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
7640 }
7641
7642 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) {
7643         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7644         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7645         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7646         unsigned char header_arr[80];
7647         CHECK((*env)->GetArrayLength(env, header) == 80);
7648         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7649         unsigned char (*header_ref)[80] = &header_arr;
7650         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7651 }
7652
7653 typedef struct LDKConfirm_JCalls {
7654         atomic_size_t refcnt;
7655         JavaVM *vm;
7656         jweak o;
7657         jmethodID transactions_confirmed_meth;
7658         jmethodID transaction_unconfirmed_meth;
7659         jmethodID best_block_updated_meth;
7660         jmethodID get_relevant_txids_meth;
7661 } LDKConfirm_JCalls;
7662 static void LDKConfirm_JCalls_free(void* this_arg) {
7663         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7664         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7665                 JNIEnv *env;
7666                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7667                 if (get_jenv_res == JNI_EDETACHED) {
7668                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7669                 } else {
7670                         DO_ASSERT(get_jenv_res == JNI_OK);
7671                 }
7672                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7673                 if (get_jenv_res == JNI_EDETACHED) {
7674                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7675                 }
7676                 FREE(j_calls);
7677         }
7678 }
7679 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7680         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7681         JNIEnv *env;
7682         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7683         if (get_jenv_res == JNI_EDETACHED) {
7684                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7685         } else {
7686                 DO_ASSERT(get_jenv_res == JNI_OK);
7687         }
7688         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7689         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7690         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7691         int64_tArray txdata_arr = NULL;
7692         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
7693         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
7694         for (size_t c = 0; c < txdata_var.datalen; c++) {
7695                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7696                 *txdata_conv_28_conv = txdata_var.data[c];
7697                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
7698         }
7699         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
7700         FREE(txdata_var.data);
7701         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7702         CHECK(obj != NULL);
7703         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
7704         if ((*env)->ExceptionCheck(env)) {
7705                 (*env)->ExceptionDescribe(env);
7706                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
7707         }
7708         if (get_jenv_res == JNI_EDETACHED) {
7709                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7710         }
7711 }
7712 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7713         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7714         JNIEnv *env;
7715         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7716         if (get_jenv_res == JNI_EDETACHED) {
7717                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7718         } else {
7719                 DO_ASSERT(get_jenv_res == JNI_OK);
7720         }
7721         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7722         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7723         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7724         CHECK(obj != NULL);
7725         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
7726         if ((*env)->ExceptionCheck(env)) {
7727                 (*env)->ExceptionDescribe(env);
7728                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
7729         }
7730         if (get_jenv_res == JNI_EDETACHED) {
7731                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7732         }
7733 }
7734 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7735         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7736         JNIEnv *env;
7737         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7738         if (get_jenv_res == JNI_EDETACHED) {
7739                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7740         } else {
7741                 DO_ASSERT(get_jenv_res == JNI_OK);
7742         }
7743         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7744         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7745         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7746         CHECK(obj != NULL);
7747         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
7748         if ((*env)->ExceptionCheck(env)) {
7749                 (*env)->ExceptionDescribe(env);
7750                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
7751         }
7752         if (get_jenv_res == JNI_EDETACHED) {
7753                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7754         }
7755 }
7756 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
7757         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7758         JNIEnv *env;
7759         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7760         if (get_jenv_res == JNI_EDETACHED) {
7761                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7762         } else {
7763                 DO_ASSERT(get_jenv_res == JNI_OK);
7764         }
7765         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7766         CHECK(obj != NULL);
7767         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
7768         if ((*env)->ExceptionCheck(env)) {
7769                 (*env)->ExceptionDescribe(env);
7770                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
7771         }
7772         LDKCVec_TxidZ ret_constr;
7773         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7774         if (ret_constr.datalen > 0)
7775                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7776         else
7777                 ret_constr.data = NULL;
7778         for (size_t i = 0; i < ret_constr.datalen; i++) {
7779                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
7780                 LDKThirtyTwoBytes ret_conv_8_ref;
7781                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
7782                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
7783                 ret_constr.data[i] = ret_conv_8_ref;
7784         }
7785         if (get_jenv_res == JNI_EDETACHED) {
7786                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7787         }
7788         return ret_constr;
7789 }
7790 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
7791         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
7792         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7793 }
7794 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
7795         jclass c = (*env)->GetObjectClass(env, o);
7796         CHECK(c != NULL);
7797         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
7798         atomic_init(&calls->refcnt, 1);
7799         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7800         calls->o = (*env)->NewWeakGlobalRef(env, o);
7801         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
7802         CHECK(calls->transactions_confirmed_meth != NULL);
7803         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
7804         CHECK(calls->transaction_unconfirmed_meth != NULL);
7805         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
7806         CHECK(calls->best_block_updated_meth != NULL);
7807         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
7808         CHECK(calls->get_relevant_txids_meth != NULL);
7809
7810         LDKConfirm ret = {
7811                 .this_arg = (void*) calls,
7812                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
7813                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
7814                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
7815                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
7816                 .free = LDKConfirm_JCalls_free,
7817         };
7818         return ret;
7819 }
7820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
7821         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
7822         *res_ptr = LDKConfirm_init(env, clz, o);
7823         return (uint64_t)res_ptr;
7824 }
7825 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) {
7826         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7827         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7828         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7829         unsigned char header_arr[80];
7830         CHECK((*env)->GetArrayLength(env, header) == 80);
7831         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7832         unsigned char (*header_ref)[80] = &header_arr;
7833         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7834         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
7835         if (txdata_constr.datalen > 0)
7836                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7837         else
7838                 txdata_constr.data = NULL;
7839         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
7840         for (size_t c = 0; c < txdata_constr.datalen; c++) {
7841                 int64_t txdata_conv_28 = txdata_vals[c];
7842                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
7843                 CHECK_ACCESS(txdata_conv_28_ptr);
7844                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
7845                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
7846                 txdata_constr.data[c] = txdata_conv_28_conv;
7847         }
7848         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
7849         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
7850 }
7851
7852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
7853         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7854         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7855         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7856         unsigned char txid_arr[32];
7857         CHECK((*env)->GetArrayLength(env, txid) == 32);
7858         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7859         unsigned char (*txid_ref)[32] = &txid_arr;
7860         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
7861 }
7862
7863 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) {
7864         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7865         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7866         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7867         unsigned char header_arr[80];
7868         CHECK((*env)->GetArrayLength(env, header) == 80);
7869         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7870         unsigned char (*header_ref)[80] = &header_arr;
7871         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
7872 }
7873
7874 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
7875         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7876         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7877         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7878         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
7879         jobjectArray ret_arr = NULL;
7880         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
7881         ;
7882         for (size_t i = 0; i < ret_var.datalen; i++) {
7883                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
7884                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
7885                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
7886         }
7887         
7888         FREE(ret_var.data);
7889         return ret_arr;
7890 }
7891
7892 typedef struct LDKPersist_JCalls {
7893         atomic_size_t refcnt;
7894         JavaVM *vm;
7895         jweak o;
7896         jmethodID persist_new_channel_meth;
7897         jmethodID update_persisted_channel_meth;
7898 } LDKPersist_JCalls;
7899 static void LDKPersist_JCalls_free(void* this_arg) {
7900         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7901         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7902                 JNIEnv *env;
7903                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7904                 if (get_jenv_res == JNI_EDETACHED) {
7905                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7906                 } else {
7907                         DO_ASSERT(get_jenv_res == JNI_OK);
7908                 }
7909                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7910                 if (get_jenv_res == JNI_EDETACHED) {
7911                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7912                 }
7913                 FREE(j_calls);
7914         }
7915 }
7916 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7917         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7918         JNIEnv *env;
7919         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7920         if (get_jenv_res == JNI_EDETACHED) {
7921                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7922         } else {
7923                 DO_ASSERT(get_jenv_res == JNI_OK);
7924         }
7925         LDKOutPoint channel_id_var = channel_id;
7926         uint64_t channel_id_ref = 0;
7927         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7928         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7929         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7930         channel_id_ref = (uint64_t)channel_id_var.inner;
7931         if (channel_id_var.is_owned) {
7932                 channel_id_ref |= 1;
7933         }
7934         LDKChannelMonitor data_var = *data;
7935         uint64_t data_ref = 0;
7936         data_var = ChannelMonitor_clone(data);
7937         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7938         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7939         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
7940         data_ref = (uint64_t)data_var.inner;
7941         if (data_var.is_owned) {
7942                 data_ref |= 1;
7943         }
7944         LDKMonitorUpdateId update_id_var = update_id;
7945         uint64_t update_id_ref = 0;
7946         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7947         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7948         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
7949         update_id_ref = (uint64_t)update_id_var.inner;
7950         if (update_id_var.is_owned) {
7951                 update_id_ref |= 1;
7952         }
7953         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7954         CHECK(obj != NULL);
7955         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
7956         if ((*env)->ExceptionCheck(env)) {
7957                 (*env)->ExceptionDescribe(env);
7958                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
7959         }
7960         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7961         CHECK_ACCESS(ret_ptr);
7962         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
7963         FREE((void*)ret);
7964         if (get_jenv_res == JNI_EDETACHED) {
7965                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7966         }
7967         return ret_conv;
7968 }
7969 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7970         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7971         JNIEnv *env;
7972         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7973         if (get_jenv_res == JNI_EDETACHED) {
7974                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7975         } else {
7976                 DO_ASSERT(get_jenv_res == JNI_OK);
7977         }
7978         LDKOutPoint channel_id_var = channel_id;
7979         uint64_t channel_id_ref = 0;
7980         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7981         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7982         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7983         channel_id_ref = (uint64_t)channel_id_var.inner;
7984         if (channel_id_var.is_owned) {
7985                 channel_id_ref |= 1;
7986         }
7987         LDKChannelMonitorUpdate update_var = *update;
7988         uint64_t update_ref = 0;
7989         if ((uint64_t)update_var.inner > 4096) {
7990                 update_var = ChannelMonitorUpdate_clone(update);
7991                 CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7992                 CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7993         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7994                 update_ref = (uint64_t)update_var.inner;
7995                 if (update_var.is_owned) {
7996                         update_ref |= 1;
7997                 }
7998         }
7999         LDKChannelMonitor data_var = *data;
8000         uint64_t data_ref = 0;
8001         data_var = ChannelMonitor_clone(data);
8002         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8003         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8004         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8005         data_ref = (uint64_t)data_var.inner;
8006         if (data_var.is_owned) {
8007                 data_ref |= 1;
8008         }
8009         LDKMonitorUpdateId update_id_var = update_id;
8010         uint64_t update_id_ref = 0;
8011         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8012         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8013         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8014         update_id_ref = (uint64_t)update_id_var.inner;
8015         if (update_id_var.is_owned) {
8016                 update_id_ref |= 1;
8017         }
8018         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8019         CHECK(obj != NULL);
8020         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
8021         if ((*env)->ExceptionCheck(env)) {
8022                 (*env)->ExceptionDescribe(env);
8023                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
8024         }
8025         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8026         CHECK_ACCESS(ret_ptr);
8027         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8028         FREE((void*)ret);
8029         if (get_jenv_res == JNI_EDETACHED) {
8030                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8031         }
8032         return ret_conv;
8033 }
8034 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8035         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8036         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8037 }
8038 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
8039         jclass c = (*env)->GetObjectClass(env, o);
8040         CHECK(c != NULL);
8041         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8042         atomic_init(&calls->refcnt, 1);
8043         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8044         calls->o = (*env)->NewWeakGlobalRef(env, o);
8045         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
8046         CHECK(calls->persist_new_channel_meth != NULL);
8047         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
8048         CHECK(calls->update_persisted_channel_meth != NULL);
8049
8050         LDKPersist ret = {
8051                 .this_arg = (void*) calls,
8052                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8053                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8054                 .free = LDKPersist_JCalls_free,
8055         };
8056         return ret;
8057 }
8058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
8059         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8060         *res_ptr = LDKPersist_init(env, clz, o);
8061         return (uint64_t)res_ptr;
8062 }
8063 JNIEXPORT int64_t 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) {
8064         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8065         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8066         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8067         LDKOutPoint channel_id_conv;
8068         channel_id_conv.inner = (void*)(channel_id & (~1));
8069         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8070         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8071         channel_id_conv = OutPoint_clone(&channel_id_conv);
8072         LDKChannelMonitor data_conv;
8073         data_conv.inner = (void*)(data & (~1));
8074         data_conv.is_owned = false;
8075         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8076         LDKMonitorUpdateId update_id_conv;
8077         update_id_conv.inner = (void*)(update_id & (~1));
8078         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8079         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8080         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8081         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8082         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8083         return (uint64_t)ret_conv;
8084 }
8085
8086 JNIEXPORT int64_t 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) {
8087         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8088         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8089         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8090         LDKOutPoint channel_id_conv;
8091         channel_id_conv.inner = (void*)(channel_id & (~1));
8092         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8093         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8094         channel_id_conv = OutPoint_clone(&channel_id_conv);
8095         LDKChannelMonitorUpdate update_conv;
8096         update_conv.inner = (void*)(update & (~1));
8097         update_conv.is_owned = false;
8098         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8099         LDKChannelMonitor data_conv;
8100         data_conv.inner = (void*)(data & (~1));
8101         data_conv.is_owned = false;
8102         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8103         LDKMonitorUpdateId update_id_conv;
8104         update_id_conv.inner = (void*)(update_id & (~1));
8105         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8106         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8107         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8108         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8109         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8110         return (uint64_t)ret_conv;
8111 }
8112
8113 typedef struct LDKChannelMessageHandler_JCalls {
8114         atomic_size_t refcnt;
8115         JavaVM *vm;
8116         jweak o;
8117         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8118         jmethodID handle_open_channel_meth;
8119         jmethodID handle_accept_channel_meth;
8120         jmethodID handle_funding_created_meth;
8121         jmethodID handle_funding_signed_meth;
8122         jmethodID handle_funding_locked_meth;
8123         jmethodID handle_shutdown_meth;
8124         jmethodID handle_closing_signed_meth;
8125         jmethodID handle_update_add_htlc_meth;
8126         jmethodID handle_update_fulfill_htlc_meth;
8127         jmethodID handle_update_fail_htlc_meth;
8128         jmethodID handle_update_fail_malformed_htlc_meth;
8129         jmethodID handle_commitment_signed_meth;
8130         jmethodID handle_revoke_and_ack_meth;
8131         jmethodID handle_update_fee_meth;
8132         jmethodID handle_announcement_signatures_meth;
8133         jmethodID peer_disconnected_meth;
8134         jmethodID peer_connected_meth;
8135         jmethodID handle_channel_reestablish_meth;
8136         jmethodID handle_channel_update_meth;
8137         jmethodID handle_error_meth;
8138 } LDKChannelMessageHandler_JCalls;
8139 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8140         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8141         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8142                 JNIEnv *env;
8143                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8144                 if (get_jenv_res == JNI_EDETACHED) {
8145                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8146                 } else {
8147                         DO_ASSERT(get_jenv_res == JNI_OK);
8148                 }
8149                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8150                 if (get_jenv_res == JNI_EDETACHED) {
8151                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8152                 }
8153                 FREE(j_calls);
8154         }
8155 }
8156 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8157         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8158         JNIEnv *env;
8159         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8160         if (get_jenv_res == JNI_EDETACHED) {
8161                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8162         } else {
8163                 DO_ASSERT(get_jenv_res == JNI_OK);
8164         }
8165         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8166         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8167         LDKInitFeatures their_features_var = their_features;
8168         uint64_t their_features_ref = 0;
8169         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8170         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8171         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8172         their_features_ref = (uint64_t)their_features_var.inner;
8173         if (their_features_var.is_owned) {
8174                 their_features_ref |= 1;
8175         }
8176         LDKOpenChannel msg_var = *msg;
8177         uint64_t msg_ref = 0;
8178         msg_var = OpenChannel_clone(msg);
8179         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8180         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8181         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8182         msg_ref = (uint64_t)msg_var.inner;
8183         if (msg_var.is_owned) {
8184                 msg_ref |= 1;
8185         }
8186         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8187         CHECK(obj != NULL);
8188         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8189         if ((*env)->ExceptionCheck(env)) {
8190                 (*env)->ExceptionDescribe(env);
8191                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
8192         }
8193         if (get_jenv_res == JNI_EDETACHED) {
8194                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8195         }
8196 }
8197 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8198         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8199         JNIEnv *env;
8200         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8201         if (get_jenv_res == JNI_EDETACHED) {
8202                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8203         } else {
8204                 DO_ASSERT(get_jenv_res == JNI_OK);
8205         }
8206         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8207         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8208         LDKInitFeatures their_features_var = their_features;
8209         uint64_t their_features_ref = 0;
8210         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8211         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8212         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8213         their_features_ref = (uint64_t)their_features_var.inner;
8214         if (their_features_var.is_owned) {
8215                 their_features_ref |= 1;
8216         }
8217         LDKAcceptChannel msg_var = *msg;
8218         uint64_t msg_ref = 0;
8219         msg_var = AcceptChannel_clone(msg);
8220         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8221         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8222         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8223         msg_ref = (uint64_t)msg_var.inner;
8224         if (msg_var.is_owned) {
8225                 msg_ref |= 1;
8226         }
8227         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8228         CHECK(obj != NULL);
8229         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8230         if ((*env)->ExceptionCheck(env)) {
8231                 (*env)->ExceptionDescribe(env);
8232                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
8233         }
8234         if (get_jenv_res == JNI_EDETACHED) {
8235                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8236         }
8237 }
8238 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8239         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8240         JNIEnv *env;
8241         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8242         if (get_jenv_res == JNI_EDETACHED) {
8243                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8244         } else {
8245                 DO_ASSERT(get_jenv_res == JNI_OK);
8246         }
8247         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8248         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8249         LDKFundingCreated msg_var = *msg;
8250         uint64_t msg_ref = 0;
8251         msg_var = FundingCreated_clone(msg);
8252         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8253         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8254         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8255         msg_ref = (uint64_t)msg_var.inner;
8256         if (msg_var.is_owned) {
8257                 msg_ref |= 1;
8258         }
8259         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8260         CHECK(obj != NULL);
8261         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
8262         if ((*env)->ExceptionCheck(env)) {
8263                 (*env)->ExceptionDescribe(env);
8264                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
8265         }
8266         if (get_jenv_res == JNI_EDETACHED) {
8267                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8268         }
8269 }
8270 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8271         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8272         JNIEnv *env;
8273         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8274         if (get_jenv_res == JNI_EDETACHED) {
8275                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8276         } else {
8277                 DO_ASSERT(get_jenv_res == JNI_OK);
8278         }
8279         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8280         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8281         LDKFundingSigned msg_var = *msg;
8282         uint64_t msg_ref = 0;
8283         msg_var = FundingSigned_clone(msg);
8284         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8285         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8286         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8287         msg_ref = (uint64_t)msg_var.inner;
8288         if (msg_var.is_owned) {
8289                 msg_ref |= 1;
8290         }
8291         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8292         CHECK(obj != NULL);
8293         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
8294         if ((*env)->ExceptionCheck(env)) {
8295                 (*env)->ExceptionDescribe(env);
8296                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
8297         }
8298         if (get_jenv_res == JNI_EDETACHED) {
8299                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8300         }
8301 }
8302 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8303         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8304         JNIEnv *env;
8305         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8306         if (get_jenv_res == JNI_EDETACHED) {
8307                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8308         } else {
8309                 DO_ASSERT(get_jenv_res == JNI_OK);
8310         }
8311         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8312         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8313         LDKFundingLocked msg_var = *msg;
8314         uint64_t msg_ref = 0;
8315         msg_var = FundingLocked_clone(msg);
8316         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8317         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8318         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8319         msg_ref = (uint64_t)msg_var.inner;
8320         if (msg_var.is_owned) {
8321                 msg_ref |= 1;
8322         }
8323         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8324         CHECK(obj != NULL);
8325         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
8326         if ((*env)->ExceptionCheck(env)) {
8327                 (*env)->ExceptionDescribe(env);
8328                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
8329         }
8330         if (get_jenv_res == JNI_EDETACHED) {
8331                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8332         }
8333 }
8334 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8335         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8336         JNIEnv *env;
8337         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8338         if (get_jenv_res == JNI_EDETACHED) {
8339                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8340         } else {
8341                 DO_ASSERT(get_jenv_res == JNI_OK);
8342         }
8343         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8344         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8345         LDKInitFeatures their_features_var = *their_features;
8346         uint64_t their_features_ref = 0;
8347         their_features_var = InitFeatures_clone(their_features);
8348         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8349         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8350         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8351         their_features_ref = (uint64_t)their_features_var.inner;
8352         if (their_features_var.is_owned) {
8353                 their_features_ref |= 1;
8354         }
8355         LDKShutdown msg_var = *msg;
8356         uint64_t msg_ref = 0;
8357         msg_var = Shutdown_clone(msg);
8358         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8359         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8360         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8361         msg_ref = (uint64_t)msg_var.inner;
8362         if (msg_var.is_owned) {
8363                 msg_ref |= 1;
8364         }
8365         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8366         CHECK(obj != NULL);
8367         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
8368         if ((*env)->ExceptionCheck(env)) {
8369                 (*env)->ExceptionDescribe(env);
8370                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
8371         }
8372         if (get_jenv_res == JNI_EDETACHED) {
8373                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8374         }
8375 }
8376 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8377         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8378         JNIEnv *env;
8379         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8380         if (get_jenv_res == JNI_EDETACHED) {
8381                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8382         } else {
8383                 DO_ASSERT(get_jenv_res == JNI_OK);
8384         }
8385         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8386         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8387         LDKClosingSigned msg_var = *msg;
8388         uint64_t msg_ref = 0;
8389         msg_var = ClosingSigned_clone(msg);
8390         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8391         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8392         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8393         msg_ref = (uint64_t)msg_var.inner;
8394         if (msg_var.is_owned) {
8395                 msg_ref |= 1;
8396         }
8397         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8398         CHECK(obj != NULL);
8399         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
8400         if ((*env)->ExceptionCheck(env)) {
8401                 (*env)->ExceptionDescribe(env);
8402                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
8403         }
8404         if (get_jenv_res == JNI_EDETACHED) {
8405                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8406         }
8407 }
8408 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8409         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8410         JNIEnv *env;
8411         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8412         if (get_jenv_res == JNI_EDETACHED) {
8413                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8414         } else {
8415                 DO_ASSERT(get_jenv_res == JNI_OK);
8416         }
8417         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8418         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8419         LDKUpdateAddHTLC msg_var = *msg;
8420         uint64_t msg_ref = 0;
8421         msg_var = UpdateAddHTLC_clone(msg);
8422         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8423         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8424         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8425         msg_ref = (uint64_t)msg_var.inner;
8426         if (msg_var.is_owned) {
8427                 msg_ref |= 1;
8428         }
8429         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8430         CHECK(obj != NULL);
8431         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
8432         if ((*env)->ExceptionCheck(env)) {
8433                 (*env)->ExceptionDescribe(env);
8434                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
8435         }
8436         if (get_jenv_res == JNI_EDETACHED) {
8437                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8438         }
8439 }
8440 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8441         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8442         JNIEnv *env;
8443         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8444         if (get_jenv_res == JNI_EDETACHED) {
8445                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8446         } else {
8447                 DO_ASSERT(get_jenv_res == JNI_OK);
8448         }
8449         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8450         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8451         LDKUpdateFulfillHTLC msg_var = *msg;
8452         uint64_t msg_ref = 0;
8453         msg_var = UpdateFulfillHTLC_clone(msg);
8454         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8455         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8456         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8457         msg_ref = (uint64_t)msg_var.inner;
8458         if (msg_var.is_owned) {
8459                 msg_ref |= 1;
8460         }
8461         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8462         CHECK(obj != NULL);
8463         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
8464         if ((*env)->ExceptionCheck(env)) {
8465                 (*env)->ExceptionDescribe(env);
8466                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
8467         }
8468         if (get_jenv_res == JNI_EDETACHED) {
8469                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8470         }
8471 }
8472 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8473         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8474         JNIEnv *env;
8475         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8476         if (get_jenv_res == JNI_EDETACHED) {
8477                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8478         } else {
8479                 DO_ASSERT(get_jenv_res == JNI_OK);
8480         }
8481         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8482         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8483         LDKUpdateFailHTLC msg_var = *msg;
8484         uint64_t msg_ref = 0;
8485         msg_var = UpdateFailHTLC_clone(msg);
8486         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8487         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8488         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8489         msg_ref = (uint64_t)msg_var.inner;
8490         if (msg_var.is_owned) {
8491                 msg_ref |= 1;
8492         }
8493         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8494         CHECK(obj != NULL);
8495         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
8496         if ((*env)->ExceptionCheck(env)) {
8497                 (*env)->ExceptionDescribe(env);
8498                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
8499         }
8500         if (get_jenv_res == JNI_EDETACHED) {
8501                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8502         }
8503 }
8504 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8505         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8506         JNIEnv *env;
8507         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8508         if (get_jenv_res == JNI_EDETACHED) {
8509                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8510         } else {
8511                 DO_ASSERT(get_jenv_res == JNI_OK);
8512         }
8513         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8514         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8515         LDKUpdateFailMalformedHTLC msg_var = *msg;
8516         uint64_t msg_ref = 0;
8517         msg_var = UpdateFailMalformedHTLC_clone(msg);
8518         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8519         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8520         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8521         msg_ref = (uint64_t)msg_var.inner;
8522         if (msg_var.is_owned) {
8523                 msg_ref |= 1;
8524         }
8525         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8526         CHECK(obj != NULL);
8527         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
8528         if ((*env)->ExceptionCheck(env)) {
8529                 (*env)->ExceptionDescribe(env);
8530                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
8531         }
8532         if (get_jenv_res == JNI_EDETACHED) {
8533                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8534         }
8535 }
8536 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8537         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8538         JNIEnv *env;
8539         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8540         if (get_jenv_res == JNI_EDETACHED) {
8541                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8542         } else {
8543                 DO_ASSERT(get_jenv_res == JNI_OK);
8544         }
8545         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8546         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8547         LDKCommitmentSigned msg_var = *msg;
8548         uint64_t msg_ref = 0;
8549         msg_var = CommitmentSigned_clone(msg);
8550         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8551         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8552         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8553         msg_ref = (uint64_t)msg_var.inner;
8554         if (msg_var.is_owned) {
8555                 msg_ref |= 1;
8556         }
8557         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8558         CHECK(obj != NULL);
8559         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
8560         if ((*env)->ExceptionCheck(env)) {
8561                 (*env)->ExceptionDescribe(env);
8562                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
8563         }
8564         if (get_jenv_res == JNI_EDETACHED) {
8565                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8566         }
8567 }
8568 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8569         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8570         JNIEnv *env;
8571         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8572         if (get_jenv_res == JNI_EDETACHED) {
8573                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8574         } else {
8575                 DO_ASSERT(get_jenv_res == JNI_OK);
8576         }
8577         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8578         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8579         LDKRevokeAndACK msg_var = *msg;
8580         uint64_t msg_ref = 0;
8581         msg_var = RevokeAndACK_clone(msg);
8582         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8583         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8584         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8585         msg_ref = (uint64_t)msg_var.inner;
8586         if (msg_var.is_owned) {
8587                 msg_ref |= 1;
8588         }
8589         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8590         CHECK(obj != NULL);
8591         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
8592         if ((*env)->ExceptionCheck(env)) {
8593                 (*env)->ExceptionDescribe(env);
8594                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
8595         }
8596         if (get_jenv_res == JNI_EDETACHED) {
8597                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8598         }
8599 }
8600 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8601         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8602         JNIEnv *env;
8603         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8604         if (get_jenv_res == JNI_EDETACHED) {
8605                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8606         } else {
8607                 DO_ASSERT(get_jenv_res == JNI_OK);
8608         }
8609         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8610         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8611         LDKUpdateFee msg_var = *msg;
8612         uint64_t msg_ref = 0;
8613         msg_var = UpdateFee_clone(msg);
8614         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8615         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8616         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8617         msg_ref = (uint64_t)msg_var.inner;
8618         if (msg_var.is_owned) {
8619                 msg_ref |= 1;
8620         }
8621         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8622         CHECK(obj != NULL);
8623         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
8624         if ((*env)->ExceptionCheck(env)) {
8625                 (*env)->ExceptionDescribe(env);
8626                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
8627         }
8628         if (get_jenv_res == JNI_EDETACHED) {
8629                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8630         }
8631 }
8632 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8633         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8634         JNIEnv *env;
8635         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8636         if (get_jenv_res == JNI_EDETACHED) {
8637                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8638         } else {
8639                 DO_ASSERT(get_jenv_res == JNI_OK);
8640         }
8641         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8642         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8643         LDKAnnouncementSignatures msg_var = *msg;
8644         uint64_t msg_ref = 0;
8645         msg_var = AnnouncementSignatures_clone(msg);
8646         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8647         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8648         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8649         msg_ref = (uint64_t)msg_var.inner;
8650         if (msg_var.is_owned) {
8651                 msg_ref |= 1;
8652         }
8653         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8654         CHECK(obj != NULL);
8655         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
8656         if ((*env)->ExceptionCheck(env)) {
8657                 (*env)->ExceptionDescribe(env);
8658                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
8659         }
8660         if (get_jenv_res == JNI_EDETACHED) {
8661                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8662         }
8663 }
8664 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8665         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8666         JNIEnv *env;
8667         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8668         if (get_jenv_res == JNI_EDETACHED) {
8669                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8670         } else {
8671                 DO_ASSERT(get_jenv_res == JNI_OK);
8672         }
8673         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8674         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8675         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8676         CHECK(obj != NULL);
8677         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
8678         if ((*env)->ExceptionCheck(env)) {
8679                 (*env)->ExceptionDescribe(env);
8680                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
8681         }
8682         if (get_jenv_res == JNI_EDETACHED) {
8683                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8684         }
8685 }
8686 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8687         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8688         JNIEnv *env;
8689         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8690         if (get_jenv_res == JNI_EDETACHED) {
8691                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8692         } else {
8693                 DO_ASSERT(get_jenv_res == JNI_OK);
8694         }
8695         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8696         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8697         LDKInit msg_var = *msg;
8698         uint64_t msg_ref = 0;
8699         msg_var = Init_clone(msg);
8700         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8701         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8702         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8703         msg_ref = (uint64_t)msg_var.inner;
8704         if (msg_var.is_owned) {
8705                 msg_ref |= 1;
8706         }
8707         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8708         CHECK(obj != NULL);
8709         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
8710         if ((*env)->ExceptionCheck(env)) {
8711                 (*env)->ExceptionDescribe(env);
8712                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
8713         }
8714         if (get_jenv_res == JNI_EDETACHED) {
8715                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8716         }
8717 }
8718 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8719         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8720         JNIEnv *env;
8721         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8722         if (get_jenv_res == JNI_EDETACHED) {
8723                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8724         } else {
8725                 DO_ASSERT(get_jenv_res == JNI_OK);
8726         }
8727         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8728         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8729         LDKChannelReestablish msg_var = *msg;
8730         uint64_t msg_ref = 0;
8731         msg_var = ChannelReestablish_clone(msg);
8732         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8733         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8734         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8735         msg_ref = (uint64_t)msg_var.inner;
8736         if (msg_var.is_owned) {
8737                 msg_ref |= 1;
8738         }
8739         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8740         CHECK(obj != NULL);
8741         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
8742         if ((*env)->ExceptionCheck(env)) {
8743                 (*env)->ExceptionDescribe(env);
8744                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
8745         }
8746         if (get_jenv_res == JNI_EDETACHED) {
8747                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8748         }
8749 }
8750 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8751         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8752         JNIEnv *env;
8753         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8754         if (get_jenv_res == JNI_EDETACHED) {
8755                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8756         } else {
8757                 DO_ASSERT(get_jenv_res == JNI_OK);
8758         }
8759         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8760         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8761         LDKChannelUpdate msg_var = *msg;
8762         uint64_t msg_ref = 0;
8763         msg_var = ChannelUpdate_clone(msg);
8764         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8765         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8766         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8767         msg_ref = (uint64_t)msg_var.inner;
8768         if (msg_var.is_owned) {
8769                 msg_ref |= 1;
8770         }
8771         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8772         CHECK(obj != NULL);
8773         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
8774         if ((*env)->ExceptionCheck(env)) {
8775                 (*env)->ExceptionDescribe(env);
8776                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
8777         }
8778         if (get_jenv_res == JNI_EDETACHED) {
8779                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8780         }
8781 }
8782 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8783         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8784         JNIEnv *env;
8785         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8786         if (get_jenv_res == JNI_EDETACHED) {
8787                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8788         } else {
8789                 DO_ASSERT(get_jenv_res == JNI_OK);
8790         }
8791         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8792         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8793         LDKErrorMessage msg_var = *msg;
8794         uint64_t msg_ref = 0;
8795         msg_var = ErrorMessage_clone(msg);
8796         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8797         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8798         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8799         msg_ref = (uint64_t)msg_var.inner;
8800         if (msg_var.is_owned) {
8801                 msg_ref |= 1;
8802         }
8803         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8804         CHECK(obj != NULL);
8805         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
8806         if ((*env)->ExceptionCheck(env)) {
8807                 (*env)->ExceptionDescribe(env);
8808                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
8809         }
8810         if (get_jenv_res == JNI_EDETACHED) {
8811                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8812         }
8813 }
8814 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8815         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8816         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8817         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8818 }
8819 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8820         jclass c = (*env)->GetObjectClass(env, o);
8821         CHECK(c != NULL);
8822         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8823         atomic_init(&calls->refcnt, 1);
8824         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8825         calls->o = (*env)->NewWeakGlobalRef(env, o);
8826         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
8827         CHECK(calls->handle_open_channel_meth != NULL);
8828         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
8829         CHECK(calls->handle_accept_channel_meth != NULL);
8830         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
8831         CHECK(calls->handle_funding_created_meth != NULL);
8832         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
8833         CHECK(calls->handle_funding_signed_meth != NULL);
8834         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
8835         CHECK(calls->handle_funding_locked_meth != NULL);
8836         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
8837         CHECK(calls->handle_shutdown_meth != NULL);
8838         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
8839         CHECK(calls->handle_closing_signed_meth != NULL);
8840         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
8841         CHECK(calls->handle_update_add_htlc_meth != NULL);
8842         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
8843         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
8844         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
8845         CHECK(calls->handle_update_fail_htlc_meth != NULL);
8846         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
8847         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
8848         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
8849         CHECK(calls->handle_commitment_signed_meth != NULL);
8850         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
8851         CHECK(calls->handle_revoke_and_ack_meth != NULL);
8852         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
8853         CHECK(calls->handle_update_fee_meth != NULL);
8854         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
8855         CHECK(calls->handle_announcement_signatures_meth != NULL);
8856         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
8857         CHECK(calls->peer_disconnected_meth != NULL);
8858         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
8859         CHECK(calls->peer_connected_meth != NULL);
8860         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
8861         CHECK(calls->handle_channel_reestablish_meth != NULL);
8862         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
8863         CHECK(calls->handle_channel_update_meth != NULL);
8864         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
8865         CHECK(calls->handle_error_meth != NULL);
8866
8867         LDKChannelMessageHandler ret = {
8868                 .this_arg = (void*) calls,
8869                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8870                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8871                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8872                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8873                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8874                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8875                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8876                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8877                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8878                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8879                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8880                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8881                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8882                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8883                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8884                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8885                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8886                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8887                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8888                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8889                 .free = LDKChannelMessageHandler_JCalls_free,
8890                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8891         };
8892         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8893         return ret;
8894 }
8895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8896         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8897         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8898         return (uint64_t)res_ptr;
8899 }
8900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8901         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
8902         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8903         DO_ASSERT((res_ptr & 1) == 0);
8904         return (int64_t)(res_ptr | 1);
8905 }
8906 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 their_features, int64_t msg) {
8907         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8908         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8909         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8910         LDKPublicKey their_node_id_ref;
8911         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8912         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8913         LDKInitFeatures their_features_conv;
8914         their_features_conv.inner = (void*)(their_features & (~1));
8915         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8916         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8917         their_features_conv = InitFeatures_clone(&their_features_conv);
8918         LDKOpenChannel msg_conv;
8919         msg_conv.inner = (void*)(msg & (~1));
8920         msg_conv.is_owned = false;
8921         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8922         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8923 }
8924
8925 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 their_features, int64_t msg) {
8926         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8927         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8928         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8929         LDKPublicKey their_node_id_ref;
8930         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8931         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8932         LDKInitFeatures their_features_conv;
8933         their_features_conv.inner = (void*)(their_features & (~1));
8934         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8935         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8936         their_features_conv = InitFeatures_clone(&their_features_conv);
8937         LDKAcceptChannel msg_conv;
8938         msg_conv.inner = (void*)(msg & (~1));
8939         msg_conv.is_owned = false;
8940         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8941         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8942 }
8943
8944 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) {
8945         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8946         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8947         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8948         LDKPublicKey their_node_id_ref;
8949         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8950         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8951         LDKFundingCreated msg_conv;
8952         msg_conv.inner = (void*)(msg & (~1));
8953         msg_conv.is_owned = false;
8954         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8955         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8956 }
8957
8958 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) {
8959         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8960         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8961         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8962         LDKPublicKey their_node_id_ref;
8963         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8964         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8965         LDKFundingSigned msg_conv;
8966         msg_conv.inner = (void*)(msg & (~1));
8967         msg_conv.is_owned = false;
8968         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8969         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8970 }
8971
8972 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1handle_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t msg) {
8973         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8974         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8975         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8976         LDKPublicKey their_node_id_ref;
8977         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8978         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8979         LDKFundingLocked msg_conv;
8980         msg_conv.inner = (void*)(msg & (~1));
8981         msg_conv.is_owned = false;
8982         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8983         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8984 }
8985
8986 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 their_features, int64_t msg) {
8987         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8988         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8989         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8990         LDKPublicKey their_node_id_ref;
8991         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8992         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8993         LDKInitFeatures their_features_conv;
8994         their_features_conv.inner = (void*)(their_features & (~1));
8995         their_features_conv.is_owned = false;
8996         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8997         LDKShutdown msg_conv;
8998         msg_conv.inner = (void*)(msg & (~1));
8999         msg_conv.is_owned = false;
9000         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9001         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9002 }
9003
9004 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) {
9005         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9006         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9007         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9008         LDKPublicKey their_node_id_ref;
9009         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9010         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9011         LDKClosingSigned msg_conv;
9012         msg_conv.inner = (void*)(msg & (~1));
9013         msg_conv.is_owned = false;
9014         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9015         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9016 }
9017
9018 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) {
9019         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9020         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9021         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9022         LDKPublicKey their_node_id_ref;
9023         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9024         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9025         LDKUpdateAddHTLC msg_conv;
9026         msg_conv.inner = (void*)(msg & (~1));
9027         msg_conv.is_owned = false;
9028         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9029         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9030 }
9031
9032 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) {
9033         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9034         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9035         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9036         LDKPublicKey their_node_id_ref;
9037         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9038         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9039         LDKUpdateFulfillHTLC msg_conv;
9040         msg_conv.inner = (void*)(msg & (~1));
9041         msg_conv.is_owned = false;
9042         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9043         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9044 }
9045
9046 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) {
9047         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9048         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9049         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9050         LDKPublicKey their_node_id_ref;
9051         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9052         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9053         LDKUpdateFailHTLC msg_conv;
9054         msg_conv.inner = (void*)(msg & (~1));
9055         msg_conv.is_owned = false;
9056         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9057         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9058 }
9059
9060 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) {
9061         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9062         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9063         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9064         LDKPublicKey their_node_id_ref;
9065         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9066         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9067         LDKUpdateFailMalformedHTLC msg_conv;
9068         msg_conv.inner = (void*)(msg & (~1));
9069         msg_conv.is_owned = false;
9070         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9071         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9072 }
9073
9074 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) {
9075         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9076         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9077         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9078         LDKPublicKey their_node_id_ref;
9079         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9080         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9081         LDKCommitmentSigned msg_conv;
9082         msg_conv.inner = (void*)(msg & (~1));
9083         msg_conv.is_owned = false;
9084         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9085         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9086 }
9087
9088 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) {
9089         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9090         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9091         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9092         LDKPublicKey their_node_id_ref;
9093         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9094         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9095         LDKRevokeAndACK msg_conv;
9096         msg_conv.inner = (void*)(msg & (~1));
9097         msg_conv.is_owned = false;
9098         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9099         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9100 }
9101
9102 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) {
9103         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9104         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9105         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9106         LDKPublicKey their_node_id_ref;
9107         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9108         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9109         LDKUpdateFee msg_conv;
9110         msg_conv.inner = (void*)(msg & (~1));
9111         msg_conv.is_owned = false;
9112         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9113         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9114 }
9115
9116 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) {
9117         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9118         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9119         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9120         LDKPublicKey their_node_id_ref;
9121         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9122         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9123         LDKAnnouncementSignatures msg_conv;
9124         msg_conv.inner = (void*)(msg & (~1));
9125         msg_conv.is_owned = false;
9126         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9127         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9128 }
9129
9130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1peer_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, jboolean no_connection_possible) {
9131         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9132         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9133         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9134         LDKPublicKey their_node_id_ref;
9135         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9136         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9137         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9138 }
9139
9140 JNIEXPORT void 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) {
9141         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9142         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9143         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9144         LDKPublicKey their_node_id_ref;
9145         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9146         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9147         LDKInit msg_conv;
9148         msg_conv.inner = (void*)(msg & (~1));
9149         msg_conv.is_owned = false;
9150         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9151         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9152 }
9153
9154 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) {
9155         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9156         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9157         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9158         LDKPublicKey their_node_id_ref;
9159         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9160         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9161         LDKChannelReestablish msg_conv;
9162         msg_conv.inner = (void*)(msg & (~1));
9163         msg_conv.is_owned = false;
9164         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9165         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9166 }
9167
9168 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) {
9169         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9170         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9171         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9172         LDKPublicKey their_node_id_ref;
9173         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9174         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9175         LDKChannelUpdate msg_conv;
9176         msg_conv.inner = (void*)(msg & (~1));
9177         msg_conv.is_owned = false;
9178         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9179         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9180 }
9181
9182 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) {
9183         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9184         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9185         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9186         LDKPublicKey their_node_id_ref;
9187         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9188         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9189         LDKErrorMessage msg_conv;
9190         msg_conv.inner = (void*)(msg & (~1));
9191         msg_conv.is_owned = false;
9192         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9193         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9194 }
9195
9196 typedef struct LDKRoutingMessageHandler_JCalls {
9197         atomic_size_t refcnt;
9198         JavaVM *vm;
9199         jweak o;
9200         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9201         jmethodID handle_node_announcement_meth;
9202         jmethodID handle_channel_announcement_meth;
9203         jmethodID handle_channel_update_meth;
9204         jmethodID get_next_channel_announcements_meth;
9205         jmethodID get_next_node_announcements_meth;
9206         jmethodID sync_routing_table_meth;
9207         jmethodID handle_reply_channel_range_meth;
9208         jmethodID handle_reply_short_channel_ids_end_meth;
9209         jmethodID handle_query_channel_range_meth;
9210         jmethodID handle_query_short_channel_ids_meth;
9211 } LDKRoutingMessageHandler_JCalls;
9212 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9213         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9214         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9215                 JNIEnv *env;
9216                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9217                 if (get_jenv_res == JNI_EDETACHED) {
9218                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9219                 } else {
9220                         DO_ASSERT(get_jenv_res == JNI_OK);
9221                 }
9222                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9223                 if (get_jenv_res == JNI_EDETACHED) {
9224                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9225                 }
9226                 FREE(j_calls);
9227         }
9228 }
9229 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9230         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9231         JNIEnv *env;
9232         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9233         if (get_jenv_res == JNI_EDETACHED) {
9234                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9235         } else {
9236                 DO_ASSERT(get_jenv_res == JNI_OK);
9237         }
9238         LDKNodeAnnouncement msg_var = *msg;
9239         uint64_t msg_ref = 0;
9240         msg_var = NodeAnnouncement_clone(msg);
9241         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9242         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9243         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9244         msg_ref = (uint64_t)msg_var.inner;
9245         if (msg_var.is_owned) {
9246                 msg_ref |= 1;
9247         }
9248         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9249         CHECK(obj != NULL);
9250         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
9251         if ((*env)->ExceptionCheck(env)) {
9252                 (*env)->ExceptionDescribe(env);
9253                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9254         }
9255         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9256         CHECK_ACCESS(ret_ptr);
9257         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9258         FREE((void*)ret);
9259         if (get_jenv_res == JNI_EDETACHED) {
9260                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9261         }
9262         return ret_conv;
9263 }
9264 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9265         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9266         JNIEnv *env;
9267         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9268         if (get_jenv_res == JNI_EDETACHED) {
9269                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9270         } else {
9271                 DO_ASSERT(get_jenv_res == JNI_OK);
9272         }
9273         LDKChannelAnnouncement msg_var = *msg;
9274         uint64_t msg_ref = 0;
9275         msg_var = ChannelAnnouncement_clone(msg);
9276         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9277         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9278         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9279         msg_ref = (uint64_t)msg_var.inner;
9280         if (msg_var.is_owned) {
9281                 msg_ref |= 1;
9282         }
9283         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9284         CHECK(obj != NULL);
9285         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
9286         if ((*env)->ExceptionCheck(env)) {
9287                 (*env)->ExceptionDescribe(env);
9288                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9289         }
9290         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9291         CHECK_ACCESS(ret_ptr);
9292         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9293         FREE((void*)ret);
9294         if (get_jenv_res == JNI_EDETACHED) {
9295                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9296         }
9297         return ret_conv;
9298 }
9299 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9300         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9301         JNIEnv *env;
9302         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9303         if (get_jenv_res == JNI_EDETACHED) {
9304                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9305         } else {
9306                 DO_ASSERT(get_jenv_res == JNI_OK);
9307         }
9308         LDKChannelUpdate msg_var = *msg;
9309         uint64_t msg_ref = 0;
9310         msg_var = ChannelUpdate_clone(msg);
9311         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9312         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9313         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9314         msg_ref = (uint64_t)msg_var.inner;
9315         if (msg_var.is_owned) {
9316                 msg_ref |= 1;
9317         }
9318         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9319         CHECK(obj != NULL);
9320         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
9321         if ((*env)->ExceptionCheck(env)) {
9322                 (*env)->ExceptionDescribe(env);
9323                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
9324         }
9325         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9326         CHECK_ACCESS(ret_ptr);
9327         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9328         FREE((void*)ret);
9329         if (get_jenv_res == JNI_EDETACHED) {
9330                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9331         }
9332         return ret_conv;
9333 }
9334 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9335         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9336         JNIEnv *env;
9337         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9338         if (get_jenv_res == JNI_EDETACHED) {
9339                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9340         } else {
9341                 DO_ASSERT(get_jenv_res == JNI_OK);
9342         }
9343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9344         CHECK(obj != NULL);
9345         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
9346         if ((*env)->ExceptionCheck(env)) {
9347                 (*env)->ExceptionDescribe(env);
9348                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9349         }
9350         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9351         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9352         if (ret_constr.datalen > 0)
9353                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9354         else
9355                 ret_constr.data = NULL;
9356         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9357         for (size_t h = 0; h < ret_constr.datalen; h++) {
9358                 int64_t ret_conv_59 = ret_vals[h];
9359                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
9360                 CHECK_ACCESS(ret_conv_59_ptr);
9361                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9362                 FREE((void*)ret_conv_59);
9363                 ret_constr.data[h] = ret_conv_59_conv;
9364         }
9365         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9366         if (get_jenv_res == JNI_EDETACHED) {
9367                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9368         }
9369         return ret_constr;
9370 }
9371 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9372         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9373         JNIEnv *env;
9374         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9375         if (get_jenv_res == JNI_EDETACHED) {
9376                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9377         } else {
9378                 DO_ASSERT(get_jenv_res == JNI_OK);
9379         }
9380         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
9381         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
9382         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9383         CHECK(obj != NULL);
9384         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
9385         if ((*env)->ExceptionCheck(env)) {
9386                 (*env)->ExceptionDescribe(env);
9387                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9388         }
9389         LDKCVec_NodeAnnouncementZ ret_constr;
9390         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9391         if (ret_constr.datalen > 0)
9392                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9393         else
9394                 ret_constr.data = NULL;
9395         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9396         for (size_t s = 0; s < ret_constr.datalen; s++) {
9397                 int64_t ret_conv_18 = ret_vals[s];
9398                 LDKNodeAnnouncement ret_conv_18_conv;
9399                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9400                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9401                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9402                 ret_constr.data[s] = ret_conv_18_conv;
9403         }
9404         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9405         if (get_jenv_res == JNI_EDETACHED) {
9406                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9407         }
9408         return ret_constr;
9409 }
9410 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9411         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9412         JNIEnv *env;
9413         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9414         if (get_jenv_res == JNI_EDETACHED) {
9415                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9416         } else {
9417                 DO_ASSERT(get_jenv_res == JNI_OK);
9418         }
9419         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9420         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9421         LDKInit init_var = *init;
9422         uint64_t init_ref = 0;
9423         init_var = Init_clone(init);
9424         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9425         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9426         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9427         init_ref = (uint64_t)init_var.inner;
9428         if (init_var.is_owned) {
9429                 init_ref |= 1;
9430         }
9431         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9432         CHECK(obj != NULL);
9433         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
9434         if ((*env)->ExceptionCheck(env)) {
9435                 (*env)->ExceptionDescribe(env);
9436                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
9437         }
9438         if (get_jenv_res == JNI_EDETACHED) {
9439                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9440         }
9441 }
9442 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9443         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9444         JNIEnv *env;
9445         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9446         if (get_jenv_res == JNI_EDETACHED) {
9447                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9448         } else {
9449                 DO_ASSERT(get_jenv_res == JNI_OK);
9450         }
9451         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9452         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9453         LDKReplyChannelRange msg_var = msg;
9454         uint64_t msg_ref = 0;
9455         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9456         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9457         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9458         msg_ref = (uint64_t)msg_var.inner;
9459         if (msg_var.is_owned) {
9460                 msg_ref |= 1;
9461         }
9462         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9463         CHECK(obj != NULL);
9464         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
9465         if ((*env)->ExceptionCheck(env)) {
9466                 (*env)->ExceptionDescribe(env);
9467                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9468         }
9469         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9470         CHECK_ACCESS(ret_ptr);
9471         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9472         FREE((void*)ret);
9473         if (get_jenv_res == JNI_EDETACHED) {
9474                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9475         }
9476         return ret_conv;
9477 }
9478 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9479         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9480         JNIEnv *env;
9481         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9482         if (get_jenv_res == JNI_EDETACHED) {
9483                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9484         } else {
9485                 DO_ASSERT(get_jenv_res == JNI_OK);
9486         }
9487         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9488         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9489         LDKReplyShortChannelIdsEnd msg_var = msg;
9490         uint64_t msg_ref = 0;
9491         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9492         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9493         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9494         msg_ref = (uint64_t)msg_var.inner;
9495         if (msg_var.is_owned) {
9496                 msg_ref |= 1;
9497         }
9498         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9499         CHECK(obj != NULL);
9500         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
9501         if ((*env)->ExceptionCheck(env)) {
9502                 (*env)->ExceptionDescribe(env);
9503                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
9504         }
9505         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9506         CHECK_ACCESS(ret_ptr);
9507         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9508         FREE((void*)ret);
9509         if (get_jenv_res == JNI_EDETACHED) {
9510                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9511         }
9512         return ret_conv;
9513 }
9514 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9515         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9516         JNIEnv *env;
9517         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9518         if (get_jenv_res == JNI_EDETACHED) {
9519                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9520         } else {
9521                 DO_ASSERT(get_jenv_res == JNI_OK);
9522         }
9523         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9524         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9525         LDKQueryChannelRange msg_var = msg;
9526         uint64_t msg_ref = 0;
9527         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9528         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9529         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9530         msg_ref = (uint64_t)msg_var.inner;
9531         if (msg_var.is_owned) {
9532                 msg_ref |= 1;
9533         }
9534         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9535         CHECK(obj != NULL);
9536         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
9537         if ((*env)->ExceptionCheck(env)) {
9538                 (*env)->ExceptionDescribe(env);
9539                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9540         }
9541         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9542         CHECK_ACCESS(ret_ptr);
9543         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9544         FREE((void*)ret);
9545         if (get_jenv_res == JNI_EDETACHED) {
9546                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9547         }
9548         return ret_conv;
9549 }
9550 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9551         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9552         JNIEnv *env;
9553         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9554         if (get_jenv_res == JNI_EDETACHED) {
9555                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9556         } else {
9557                 DO_ASSERT(get_jenv_res == JNI_OK);
9558         }
9559         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9560         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9561         LDKQueryShortChannelIds msg_var = msg;
9562         uint64_t msg_ref = 0;
9563         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9564         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9565         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9566         msg_ref = (uint64_t)msg_var.inner;
9567         if (msg_var.is_owned) {
9568                 msg_ref |= 1;
9569         }
9570         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9571         CHECK(obj != NULL);
9572         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
9573         if ((*env)->ExceptionCheck(env)) {
9574                 (*env)->ExceptionDescribe(env);
9575                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
9576         }
9577         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9578         CHECK_ACCESS(ret_ptr);
9579         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9580         FREE((void*)ret);
9581         if (get_jenv_res == JNI_EDETACHED) {
9582                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9583         }
9584         return ret_conv;
9585 }
9586 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9587         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9588         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9589         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9590 }
9591 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9592         jclass c = (*env)->GetObjectClass(env, o);
9593         CHECK(c != NULL);
9594         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9595         atomic_init(&calls->refcnt, 1);
9596         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9597         calls->o = (*env)->NewWeakGlobalRef(env, o);
9598         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
9599         CHECK(calls->handle_node_announcement_meth != NULL);
9600         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
9601         CHECK(calls->handle_channel_announcement_meth != NULL);
9602         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
9603         CHECK(calls->handle_channel_update_meth != NULL);
9604         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
9605         CHECK(calls->get_next_channel_announcements_meth != NULL);
9606         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
9607         CHECK(calls->get_next_node_announcements_meth != NULL);
9608         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
9609         CHECK(calls->sync_routing_table_meth != NULL);
9610         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
9611         CHECK(calls->handle_reply_channel_range_meth != NULL);
9612         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
9613         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
9614         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
9615         CHECK(calls->handle_query_channel_range_meth != NULL);
9616         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
9617         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
9618
9619         LDKRoutingMessageHandler ret = {
9620                 .this_arg = (void*) calls,
9621                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9622                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9623                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9624                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9625                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9626                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9627                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9628                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9629                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9630                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9631                 .free = LDKRoutingMessageHandler_JCalls_free,
9632                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
9633         };
9634         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9635         return ret;
9636 }
9637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9638         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9639         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
9640         return (uint64_t)res_ptr;
9641 }
9642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
9643         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
9644         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
9645         DO_ASSERT((res_ptr & 1) == 0);
9646         return (int64_t)(res_ptr | 1);
9647 }
9648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9649         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9650         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9651         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9652         LDKNodeAnnouncement msg_conv;
9653         msg_conv.inner = (void*)(msg & (~1));
9654         msg_conv.is_owned = false;
9655         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9656         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9657         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9658         return (uint64_t)ret_conv;
9659 }
9660
9661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9662         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9663         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9664         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9665         LDKChannelAnnouncement msg_conv;
9666         msg_conv.inner = (void*)(msg & (~1));
9667         msg_conv.is_owned = false;
9668         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9669         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9670         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9671         return (uint64_t)ret_conv;
9672 }
9673
9674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9675         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9676         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9677         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9678         LDKChannelUpdate msg_conv;
9679         msg_conv.inner = (void*)(msg & (~1));
9680         msg_conv.is_owned = false;
9681         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9682         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9683         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9684         return (uint64_t)ret_conv;
9685 }
9686
9687 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1channel_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int64_t starting_point, int8_t batch_amount) {
9688         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9689         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9690         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9691         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9692         int64_tArray ret_arr = NULL;
9693         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9694         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9695         for (size_t h = 0; h < ret_var.datalen; h++) {
9696                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9697                 *ret_conv_59_conv = ret_var.data[h];
9698                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
9699         }
9700         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9701         FREE(ret_var.data);
9702         return ret_arr;
9703 }
9704
9705 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1get_1next_1node_1announcements(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray starting_point, int8_t batch_amount) {
9706         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9707         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9708         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9709         LDKPublicKey starting_point_ref;
9710         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
9711         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
9712         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9713         int64_tArray ret_arr = NULL;
9714         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9715         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9716         for (size_t s = 0; s < ret_var.datalen; s++) {
9717                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9718                 uint64_t ret_conv_18_ref = 0;
9719                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9720                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9721                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9722                 ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
9723                 if (ret_conv_18_var.is_owned) {
9724                         ret_conv_18_ref |= 1;
9725                 }
9726                 ret_arr_ptr[s] = ret_conv_18_ref;
9727         }
9728         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9729         FREE(ret_var.data);
9730         return ret_arr;
9731 }
9732
9733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1sync_1routing_1table(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray their_node_id, int64_t init) {
9734         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9735         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9736         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9737         LDKPublicKey their_node_id_ref;
9738         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9739         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9740         LDKInit init_conv;
9741         init_conv.inner = (void*)(init & (~1));
9742         init_conv.is_owned = false;
9743         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9744         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9745 }
9746
9747 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) {
9748         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9749         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9750         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9751         LDKPublicKey their_node_id_ref;
9752         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9753         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9754         LDKReplyChannelRange msg_conv;
9755         msg_conv.inner = (void*)(msg & (~1));
9756         msg_conv.is_owned = (msg & 1) || (msg == 0);
9757         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9758         msg_conv = ReplyChannelRange_clone(&msg_conv);
9759         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9760         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9761         return (uint64_t)ret_conv;
9762 }
9763
9764 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) {
9765         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9766         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9767         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9768         LDKPublicKey their_node_id_ref;
9769         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9770         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9771         LDKReplyShortChannelIdsEnd msg_conv;
9772         msg_conv.inner = (void*)(msg & (~1));
9773         msg_conv.is_owned = (msg & 1) || (msg == 0);
9774         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9775         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9776         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9777         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9778         return (uint64_t)ret_conv;
9779 }
9780
9781 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) {
9782         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9783         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9784         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9785         LDKPublicKey their_node_id_ref;
9786         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9787         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9788         LDKQueryChannelRange msg_conv;
9789         msg_conv.inner = (void*)(msg & (~1));
9790         msg_conv.is_owned = (msg & 1) || (msg == 0);
9791         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9792         msg_conv = QueryChannelRange_clone(&msg_conv);
9793         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9794         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9795         return (uint64_t)ret_conv;
9796 }
9797
9798 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) {
9799         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9800         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9801         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9802         LDKPublicKey their_node_id_ref;
9803         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9804         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9805         LDKQueryShortChannelIds msg_conv;
9806         msg_conv.inner = (void*)(msg & (~1));
9807         msg_conv.is_owned = (msg & 1) || (msg == 0);
9808         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9809         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9810         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9811         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9812         return (uint64_t)ret_conv;
9813 }
9814
9815 typedef struct LDKCustomMessageReader_JCalls {
9816         atomic_size_t refcnt;
9817         JavaVM *vm;
9818         jweak o;
9819         jmethodID read_meth;
9820 } LDKCustomMessageReader_JCalls;
9821 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9822         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9823         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9824                 JNIEnv *env;
9825                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9826                 if (get_jenv_res == JNI_EDETACHED) {
9827                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9828                 } else {
9829                         DO_ASSERT(get_jenv_res == JNI_OK);
9830                 }
9831                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9832                 if (get_jenv_res == JNI_EDETACHED) {
9833                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9834                 }
9835                 FREE(j_calls);
9836         }
9837 }
9838 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9839         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9840         JNIEnv *env;
9841         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9842         if (get_jenv_res == JNI_EDETACHED) {
9843                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9844         } else {
9845                 DO_ASSERT(get_jenv_res == JNI_OK);
9846         }
9847         LDKu8slice buffer_var = buffer;
9848         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
9849         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
9850         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9851         CHECK(obj != NULL);
9852         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
9853         if ((*env)->ExceptionCheck(env)) {
9854                 (*env)->ExceptionDescribe(env);
9855                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
9856         }
9857         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9858         CHECK_ACCESS(ret_ptr);
9859         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9860         FREE((void*)ret);
9861         if (get_jenv_res == JNI_EDETACHED) {
9862                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9863         }
9864         return ret_conv;
9865 }
9866 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9867         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9868         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9869 }
9870 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
9871         jclass c = (*env)->GetObjectClass(env, o);
9872         CHECK(c != NULL);
9873         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9874         atomic_init(&calls->refcnt, 1);
9875         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9876         calls->o = (*env)->NewWeakGlobalRef(env, o);
9877         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
9878         CHECK(calls->read_meth != NULL);
9879
9880         LDKCustomMessageReader ret = {
9881                 .this_arg = (void*) calls,
9882                 .read = read_LDKCustomMessageReader_jcall,
9883                 .free = LDKCustomMessageReader_JCalls_free,
9884         };
9885         return ret;
9886 }
9887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
9888         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9889         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
9890         return (uint64_t)res_ptr;
9891 }
9892 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) {
9893         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9894         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9895         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9896         LDKu8slice buffer_ref;
9897         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
9898         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
9899         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9900         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9901         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
9902         return (uint64_t)ret_conv;
9903 }
9904
9905 typedef struct LDKCustomMessageHandler_JCalls {
9906         atomic_size_t refcnt;
9907         JavaVM *vm;
9908         jweak o;
9909         LDKCustomMessageReader_JCalls* CustomMessageReader;
9910         jmethodID handle_custom_message_meth;
9911         jmethodID get_and_clear_pending_msg_meth;
9912 } LDKCustomMessageHandler_JCalls;
9913 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9914         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9915         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9916                 JNIEnv *env;
9917                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9918                 if (get_jenv_res == JNI_EDETACHED) {
9919                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9920                 } else {
9921                         DO_ASSERT(get_jenv_res == JNI_OK);
9922                 }
9923                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9924                 if (get_jenv_res == JNI_EDETACHED) {
9925                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9926                 }
9927                 FREE(j_calls);
9928         }
9929 }
9930 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9931         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9932         JNIEnv *env;
9933         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9934         if (get_jenv_res == JNI_EDETACHED) {
9935                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9936         } else {
9937                 DO_ASSERT(get_jenv_res == JNI_OK);
9938         }
9939         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9940         *msg_ret = msg;
9941         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
9942         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
9943         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9944         CHECK(obj != NULL);
9945         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
9946         if ((*env)->ExceptionCheck(env)) {
9947                 (*env)->ExceptionDescribe(env);
9948                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
9949         }
9950         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9951         CHECK_ACCESS(ret_ptr);
9952         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9953         FREE((void*)ret);
9954         if (get_jenv_res == JNI_EDETACHED) {
9955                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9956         }
9957         return ret_conv;
9958 }
9959 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9960         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9961         JNIEnv *env;
9962         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9963         if (get_jenv_res == JNI_EDETACHED) {
9964                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9965         } else {
9966                 DO_ASSERT(get_jenv_res == JNI_OK);
9967         }
9968         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9969         CHECK(obj != NULL);
9970         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
9971         if ((*env)->ExceptionCheck(env)) {
9972                 (*env)->ExceptionDescribe(env);
9973                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
9974         }
9975         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9976         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9977         if (ret_constr.datalen > 0)
9978                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9979         else
9980                 ret_constr.data = NULL;
9981         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9982         for (size_t z = 0; z < ret_constr.datalen; z++) {
9983                 int64_t ret_conv_25 = ret_vals[z];
9984                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
9985                 CHECK_ACCESS(ret_conv_25_ptr);
9986                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9987                 FREE((void*)ret_conv_25);
9988                 ret_constr.data[z] = ret_conv_25_conv;
9989         }
9990         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9991         if (get_jenv_res == JNI_EDETACHED) {
9992                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9993         }
9994         return ret_constr;
9995 }
9996 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9997         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
9998         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9999         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10000 }
10001 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10002         jclass c = (*env)->GetObjectClass(env, o);
10003         CHECK(c != NULL);
10004         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10005         atomic_init(&calls->refcnt, 1);
10006         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10007         calls->o = (*env)->NewWeakGlobalRef(env, o);
10008         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
10009         CHECK(calls->handle_custom_message_meth != NULL);
10010         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
10011         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
10012
10013         LDKCustomMessageHandler ret = {
10014                 .this_arg = (void*) calls,
10015                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10016                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10017                 .free = LDKCustomMessageHandler_JCalls_free,
10018                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
10019         };
10020         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10021         return ret;
10022 }
10023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10024         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10025         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
10026         return (uint64_t)res_ptr;
10027 }
10028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
10029         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
10030         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
10031         DO_ASSERT((res_ptr & 1) == 0);
10032         return (int64_t)(res_ptr | 1);
10033 }
10034 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) {
10035         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10036         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10037         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10038         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
10039         CHECK_ACCESS(msg_ptr);
10040         LDKType msg_conv = *(LDKType*)(msg_ptr);
10041         if (msg_conv.free == LDKType_JCalls_free) {
10042                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10043                 LDKType_JCalls_cloned(&msg_conv);
10044         }
10045         LDKPublicKey sender_node_id_ref;
10046         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
10047         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
10048         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10049         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10050         return (uint64_t)ret_conv;
10051 }
10052
10053 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
10054         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10055         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10056         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10057         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10058         int64_tArray ret_arr = NULL;
10059         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10060         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10061         for (size_t z = 0; z < ret_var.datalen; z++) {
10062                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10063                 *ret_conv_25_conv = ret_var.data[z];
10064                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
10065         }
10066         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10067         FREE(ret_var.data);
10068         return ret_arr;
10069 }
10070
10071 typedef struct LDKSocketDescriptor_JCalls {
10072         atomic_size_t refcnt;
10073         JavaVM *vm;
10074         jweak o;
10075         jmethodID send_data_meth;
10076         jmethodID disconnect_socket_meth;
10077         jmethodID eq_meth;
10078         jmethodID hash_meth;
10079 } LDKSocketDescriptor_JCalls;
10080 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10081         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10082         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10083                 JNIEnv *env;
10084                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10085                 if (get_jenv_res == JNI_EDETACHED) {
10086                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10087                 } else {
10088                         DO_ASSERT(get_jenv_res == JNI_OK);
10089                 }
10090                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10091                 if (get_jenv_res == JNI_EDETACHED) {
10092                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10093                 }
10094                 FREE(j_calls);
10095         }
10096 }
10097 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10098         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10099         JNIEnv *env;
10100         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10101         if (get_jenv_res == JNI_EDETACHED) {
10102                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10103         } else {
10104                 DO_ASSERT(get_jenv_res == JNI_OK);
10105         }
10106         LDKu8slice data_var = data;
10107         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
10108         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
10109         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10110         CHECK(obj != NULL);
10111         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
10112         if ((*env)->ExceptionCheck(env)) {
10113                 (*env)->ExceptionDescribe(env);
10114                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
10115         }
10116         if (get_jenv_res == JNI_EDETACHED) {
10117                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10118         }
10119         return ret;
10120 }
10121 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10122         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10123         JNIEnv *env;
10124         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10125         if (get_jenv_res == JNI_EDETACHED) {
10126                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10127         } else {
10128                 DO_ASSERT(get_jenv_res == JNI_OK);
10129         }
10130         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10131         CHECK(obj != NULL);
10132         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
10133         if ((*env)->ExceptionCheck(env)) {
10134                 (*env)->ExceptionDescribe(env);
10135                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
10136         }
10137         if (get_jenv_res == JNI_EDETACHED) {
10138                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10139         }
10140 }
10141 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10142         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10143         JNIEnv *env;
10144         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10145         if (get_jenv_res == JNI_EDETACHED) {
10146                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10147         } else {
10148                 DO_ASSERT(get_jenv_res == JNI_OK);
10149         }
10150         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10151         *other_arg_clone = SocketDescriptor_clone(other_arg);
10152         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10153         CHECK(obj != NULL);
10154         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
10155         if ((*env)->ExceptionCheck(env)) {
10156                 (*env)->ExceptionDescribe(env);
10157                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
10158         }
10159         if (get_jenv_res == JNI_EDETACHED) {
10160                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10161         }
10162         return ret;
10163 }
10164 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10165         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10166         JNIEnv *env;
10167         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10168         if (get_jenv_res == JNI_EDETACHED) {
10169                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10170         } else {
10171                 DO_ASSERT(get_jenv_res == JNI_OK);
10172         }
10173         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10174         CHECK(obj != NULL);
10175         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
10176         if ((*env)->ExceptionCheck(env)) {
10177                 (*env)->ExceptionDescribe(env);
10178                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
10179         }
10180         if (get_jenv_res == JNI_EDETACHED) {
10181                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10182         }
10183         return ret;
10184 }
10185 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10186         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10187         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10188 }
10189 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
10190         jclass c = (*env)->GetObjectClass(env, o);
10191         CHECK(c != NULL);
10192         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10193         atomic_init(&calls->refcnt, 1);
10194         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10195         calls->o = (*env)->NewWeakGlobalRef(env, o);
10196         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
10197         CHECK(calls->send_data_meth != NULL);
10198         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
10199         CHECK(calls->disconnect_socket_meth != NULL);
10200         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
10201         CHECK(calls->eq_meth != NULL);
10202         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
10203         CHECK(calls->hash_meth != NULL);
10204
10205         LDKSocketDescriptor ret = {
10206                 .this_arg = (void*) calls,
10207                 .send_data = send_data_LDKSocketDescriptor_jcall,
10208                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10209                 .eq = eq_LDKSocketDescriptor_jcall,
10210                 .hash = hash_LDKSocketDescriptor_jcall,
10211                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10212                 .free = LDKSocketDescriptor_JCalls_free,
10213         };
10214         return ret;
10215 }
10216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
10217         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10218         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
10219         return (uint64_t)res_ptr;
10220 }
10221 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) {
10222         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10223         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10224         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10225         LDKu8slice data_ref;
10226         data_ref.datalen = (*env)->GetArrayLength(env, data);
10227         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
10228         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10229         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
10230         return ret_val;
10231 }
10232
10233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
10234         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10235         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10236         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10237         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10238 }
10239
10240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
10241         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10242         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10243         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10244         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
10245         return ret_val;
10246 }
10247
10248 typedef struct LDKScore_JCalls {
10249         atomic_size_t refcnt;
10250         JavaVM *vm;
10251         jweak o;
10252         jmethodID channel_penalty_msat_meth;
10253         jmethodID payment_path_failed_meth;
10254         jmethodID write_meth;
10255 } LDKScore_JCalls;
10256 static void LDKScore_JCalls_free(void* this_arg) {
10257         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10258         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10259                 JNIEnv *env;
10260                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10261                 if (get_jenv_res == JNI_EDETACHED) {
10262                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10263                 } else {
10264                         DO_ASSERT(get_jenv_res == JNI_OK);
10265                 }
10266                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10267                 if (get_jenv_res == JNI_EDETACHED) {
10268                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10269                 }
10270                 FREE(j_calls);
10271         }
10272 }
10273 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
10274         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10275         JNIEnv *env;
10276         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10277         if (get_jenv_res == JNI_EDETACHED) {
10278                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10279         } else {
10280                 DO_ASSERT(get_jenv_res == JNI_OK);
10281         }
10282         LDKNodeId source_var = *source;
10283         uint64_t source_ref = 0;
10284         source_var = NodeId_clone(source);
10285         CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10286         CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10287         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10288         source_ref = (uint64_t)source_var.inner;
10289         if (source_var.is_owned) {
10290                 source_ref |= 1;
10291         }
10292         LDKNodeId target_var = *target;
10293         uint64_t target_ref = 0;
10294         target_var = NodeId_clone(target);
10295         CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10296         CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10297         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10298         target_ref = (uint64_t)target_var.inner;
10299         if (target_var.is_owned) {
10300                 target_ref |= 1;
10301         }
10302         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10303         CHECK(obj != NULL);
10304         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
10305         if ((*env)->ExceptionCheck(env)) {
10306                 (*env)->ExceptionDescribe(env);
10307                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10308         }
10309         if (get_jenv_res == JNI_EDETACHED) {
10310                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10311         }
10312         return ret;
10313 }
10314 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10315         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10316         JNIEnv *env;
10317         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10318         if (get_jenv_res == JNI_EDETACHED) {
10319                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10320         } else {
10321                 DO_ASSERT(get_jenv_res == JNI_OK);
10322         }
10323         LDKCVec_RouteHopZ path_var = path;
10324         int64_tArray path_arr = NULL;
10325         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10326         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10327         for (size_t k = 0; k < path_var.datalen; k++) {
10328                 LDKRouteHop path_conv_10_var = path_var.data[k];
10329                 uint64_t path_conv_10_ref = 0;
10330                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10331                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10332                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10333                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
10334                 if (path_conv_10_var.is_owned) {
10335                         path_conv_10_ref |= 1;
10336                 }
10337                 path_arr_ptr[k] = path_conv_10_ref;
10338         }
10339         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10340         FREE(path_var.data);
10341         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10342         CHECK(obj != NULL);
10343         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
10344         if ((*env)->ExceptionCheck(env)) {
10345                 (*env)->ExceptionDescribe(env);
10346                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10347         }
10348         if (get_jenv_res == JNI_EDETACHED) {
10349                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10350         }
10351 }
10352 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10353         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10354         JNIEnv *env;
10355         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10356         if (get_jenv_res == JNI_EDETACHED) {
10357                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10358         } else {
10359                 DO_ASSERT(get_jenv_res == JNI_OK);
10360         }
10361         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10362         CHECK(obj != NULL);
10363         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10364         if ((*env)->ExceptionCheck(env)) {
10365                 (*env)->ExceptionDescribe(env);
10366                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10367         }
10368         LDKCVec_u8Z ret_ref;
10369         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10370         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10371         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10372         if (get_jenv_res == JNI_EDETACHED) {
10373                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10374         }
10375         return ret_ref;
10376 }
10377 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10378         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10379         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10380 }
10381 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10382         jclass c = (*env)->GetObjectClass(env, o);
10383         CHECK(c != NULL);
10384         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10385         atomic_init(&calls->refcnt, 1);
10386         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10387         calls->o = (*env)->NewWeakGlobalRef(env, o);
10388         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJ)J");
10389         CHECK(calls->channel_penalty_msat_meth != NULL);
10390         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10391         CHECK(calls->payment_path_failed_meth != NULL);
10392         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10393         CHECK(calls->write_meth != NULL);
10394
10395         LDKScore ret = {
10396                 .this_arg = (void*) calls,
10397                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10398                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10399                 .write = write_LDKScore_jcall,
10400                 .free = LDKScore_JCalls_free,
10401         };
10402         return ret;
10403 }
10404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10405         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10406         *res_ptr = LDKScore_init(env, clz, o);
10407         return (uint64_t)res_ptr;
10408 }
10409 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) {
10410         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10411         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10412         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10413         LDKNodeId source_conv;
10414         source_conv.inner = (void*)(source & (~1));
10415         source_conv.is_owned = false;
10416         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10417         LDKNodeId target_conv;
10418         target_conv.inner = (void*)(target & (~1));
10419         target_conv.is_owned = false;
10420         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10421         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
10422         return ret_val;
10423 }
10424
10425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1payment_1path_1failed(JNIEnv *env, jclass clz, int64_t this_arg, int64_tArray path, int64_t short_channel_id) {
10426         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10427         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10428         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10429         LDKCVec_RouteHopZ path_constr;
10430         path_constr.datalen = (*env)->GetArrayLength(env, path);
10431         if (path_constr.datalen > 0)
10432                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10433         else
10434                 path_constr.data = NULL;
10435         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10436         for (size_t k = 0; k < path_constr.datalen; k++) {
10437                 int64_t path_conv_10 = path_vals[k];
10438                 LDKRouteHop path_conv_10_conv;
10439                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10440                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10441                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10442                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10443                 path_constr.data[k] = path_conv_10_conv;
10444         }
10445         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10446         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10447 }
10448
10449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
10450         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10451         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10452         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10453         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10454         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10455         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10456         CVec_u8Z_free(ret_var);
10457         return ret_arr;
10458 }
10459
10460 typedef struct LDKChannelManagerPersister_JCalls {
10461         atomic_size_t refcnt;
10462         JavaVM *vm;
10463         jweak o;
10464         jmethodID persist_manager_meth;
10465 } LDKChannelManagerPersister_JCalls;
10466 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
10467         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10468         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10469                 JNIEnv *env;
10470                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10471                 if (get_jenv_res == JNI_EDETACHED) {
10472                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10473                 } else {
10474                         DO_ASSERT(get_jenv_res == JNI_OK);
10475                 }
10476                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10477                 if (get_jenv_res == JNI_EDETACHED) {
10478                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10479                 }
10480                 FREE(j_calls);
10481         }
10482 }
10483 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10484         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10485         JNIEnv *env;
10486         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10487         if (get_jenv_res == JNI_EDETACHED) {
10488                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10489         } else {
10490                 DO_ASSERT(get_jenv_res == JNI_OK);
10491         }
10492         LDKChannelManager channel_manager_var = *channel_manager;
10493         uint64_t channel_manager_ref = 0;
10494         // Warning: we may need a move here but no clone is available for LDKChannelManager
10495         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10496         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10497         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
10498         channel_manager_ref = (uint64_t)channel_manager_var.inner;
10499         if (channel_manager_var.is_owned) {
10500                 channel_manager_ref |= 1;
10501         }
10502         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10503         CHECK(obj != NULL);
10504         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10505         if ((*env)->ExceptionCheck(env)) {
10506                 (*env)->ExceptionDescribe(env);
10507                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
10508         }
10509         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10510         CHECK_ACCESS(ret_ptr);
10511         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10512         FREE((void*)ret);
10513         if (get_jenv_res == JNI_EDETACHED) {
10514                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10515         }
10516         return ret_conv;
10517 }
10518 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
10519         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
10520         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10521 }
10522 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
10523         jclass c = (*env)->GetObjectClass(env, o);
10524         CHECK(c != NULL);
10525         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
10526         atomic_init(&calls->refcnt, 1);
10527         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10528         calls->o = (*env)->NewWeakGlobalRef(env, o);
10529         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10530         CHECK(calls->persist_manager_meth != NULL);
10531
10532         LDKChannelManagerPersister ret = {
10533                 .this_arg = (void*) calls,
10534                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
10535                 .free = LDKChannelManagerPersister_JCalls_free,
10536         };
10537         return ret;
10538 }
10539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10540         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
10541         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
10542         return (uint64_t)res_ptr;
10543 }
10544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10545         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10546         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10547         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
10548         LDKChannelManager channel_manager_conv;
10549         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10550         channel_manager_conv.is_owned = false;
10551         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
10552         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10553         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10554         return (uint64_t)ret_conv;
10555 }
10556
10557 static jclass LDKFallback_SegWitProgram_class = NULL;
10558 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
10559 static jclass LDKFallback_PubKeyHash_class = NULL;
10560 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
10561 static jclass LDKFallback_ScriptHash_class = NULL;
10562 static jmethodID LDKFallback_ScriptHash_meth = NULL;
10563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
10564         LDKFallback_SegWitProgram_class =
10565                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
10566         CHECK(LDKFallback_SegWitProgram_class != NULL);
10567         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
10568         CHECK(LDKFallback_SegWitProgram_meth != NULL);
10569         LDKFallback_PubKeyHash_class =
10570                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
10571         CHECK(LDKFallback_PubKeyHash_class != NULL);
10572         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
10573         CHECK(LDKFallback_PubKeyHash_meth != NULL);
10574         LDKFallback_ScriptHash_class =
10575                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
10576         CHECK(LDKFallback_ScriptHash_class != NULL);
10577         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
10578         CHECK(LDKFallback_ScriptHash_meth != NULL);
10579 }
10580 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10581         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10582         switch(obj->tag) {
10583                 case LDKFallback_SegWitProgram: {
10584                         uint8_t version_val = obj->seg_wit_program.version._0;
10585                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10586                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
10587                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
10588                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
10589                 }
10590                 case LDKFallback_PubKeyHash: {
10591                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
10592                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
10593                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
10594                 }
10595                 case LDKFallback_ScriptHash: {
10596                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
10597                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
10598                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
10599                 }
10600                 default: abort();
10601         }
10602 }
10603 typedef struct LDKPayer_JCalls {
10604         atomic_size_t refcnt;
10605         JavaVM *vm;
10606         jweak o;
10607         jmethodID node_id_meth;
10608         jmethodID first_hops_meth;
10609         jmethodID send_payment_meth;
10610         jmethodID retry_payment_meth;
10611 } LDKPayer_JCalls;
10612 static void LDKPayer_JCalls_free(void* this_arg) {
10613         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10614         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10615                 JNIEnv *env;
10616                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10617                 if (get_jenv_res == JNI_EDETACHED) {
10618                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10619                 } else {
10620                         DO_ASSERT(get_jenv_res == JNI_OK);
10621                 }
10622                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10623                 if (get_jenv_res == JNI_EDETACHED) {
10624                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10625                 }
10626                 FREE(j_calls);
10627         }
10628 }
10629 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10630         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10631         JNIEnv *env;
10632         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10633         if (get_jenv_res == JNI_EDETACHED) {
10634                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10635         } else {
10636                 DO_ASSERT(get_jenv_res == JNI_OK);
10637         }
10638         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10639         CHECK(obj != NULL);
10640         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
10641         if ((*env)->ExceptionCheck(env)) {
10642                 (*env)->ExceptionDescribe(env);
10643                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
10644         }
10645         LDKPublicKey ret_ref;
10646         CHECK((*env)->GetArrayLength(env, ret) == 33);
10647         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
10648         if (get_jenv_res == JNI_EDETACHED) {
10649                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10650         }
10651         return ret_ref;
10652 }
10653 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10654         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10655         JNIEnv *env;
10656         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10657         if (get_jenv_res == JNI_EDETACHED) {
10658                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10659         } else {
10660                 DO_ASSERT(get_jenv_res == JNI_OK);
10661         }
10662         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10663         CHECK(obj != NULL);
10664         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
10665         if ((*env)->ExceptionCheck(env)) {
10666                 (*env)->ExceptionDescribe(env);
10667                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
10668         }
10669         LDKCVec_ChannelDetailsZ ret_constr;
10670         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10671         if (ret_constr.datalen > 0)
10672                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10673         else
10674                 ret_constr.data = NULL;
10675         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10676         for (size_t q = 0; q < ret_constr.datalen; q++) {
10677                 int64_t ret_conv_16 = ret_vals[q];
10678                 LDKChannelDetails ret_conv_16_conv;
10679                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10680                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10681                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10682                 ret_constr.data[q] = ret_conv_16_conv;
10683         }
10684         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10685         if (get_jenv_res == JNI_EDETACHED) {
10686                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10687         }
10688         return ret_constr;
10689 }
10690 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10691         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10692         JNIEnv *env;
10693         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10694         if (get_jenv_res == JNI_EDETACHED) {
10695                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10696         } else {
10697                 DO_ASSERT(get_jenv_res == JNI_OK);
10698         }
10699         LDKRoute route_var = *route;
10700         uint64_t route_ref = 0;
10701         route_var = Route_clone(route);
10702         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10703         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10704         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10705         route_ref = (uint64_t)route_var.inner;
10706         if (route_var.is_owned) {
10707                 route_ref |= 1;
10708         }
10709         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
10710         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
10711         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
10712         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
10713         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10714         CHECK(obj != NULL);
10715         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
10716         if ((*env)->ExceptionCheck(env)) {
10717                 (*env)->ExceptionDescribe(env);
10718                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
10719         }
10720         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10721         CHECK_ACCESS(ret_ptr);
10722         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10723         FREE((void*)ret);
10724         if (get_jenv_res == JNI_EDETACHED) {
10725                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10726         }
10727         return ret_conv;
10728 }
10729 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10730         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10731         JNIEnv *env;
10732         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10733         if (get_jenv_res == JNI_EDETACHED) {
10734                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10735         } else {
10736                 DO_ASSERT(get_jenv_res == JNI_OK);
10737         }
10738         LDKRoute route_var = *route;
10739         uint64_t route_ref = 0;
10740         route_var = Route_clone(route);
10741         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10742         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10743         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10744         route_ref = (uint64_t)route_var.inner;
10745         if (route_var.is_owned) {
10746                 route_ref |= 1;
10747         }
10748         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
10749         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
10750         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10751         CHECK(obj != NULL);
10752         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
10753         if ((*env)->ExceptionCheck(env)) {
10754                 (*env)->ExceptionDescribe(env);
10755                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
10756         }
10757         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10758         CHECK_ACCESS(ret_ptr);
10759         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10760         FREE((void*)ret);
10761         if (get_jenv_res == JNI_EDETACHED) {
10762                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10763         }
10764         return ret_conv;
10765 }
10766 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10767         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10768         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10769 }
10770 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
10771         jclass c = (*env)->GetObjectClass(env, o);
10772         CHECK(c != NULL);
10773         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10774         atomic_init(&calls->refcnt, 1);
10775         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10776         calls->o = (*env)->NewWeakGlobalRef(env, o);
10777         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
10778         CHECK(calls->node_id_meth != NULL);
10779         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
10780         CHECK(calls->first_hops_meth != NULL);
10781         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
10782         CHECK(calls->send_payment_meth != NULL);
10783         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
10784         CHECK(calls->retry_payment_meth != NULL);
10785
10786         LDKPayer ret = {
10787                 .this_arg = (void*) calls,
10788                 .node_id = node_id_LDKPayer_jcall,
10789                 .first_hops = first_hops_LDKPayer_jcall,
10790                 .send_payment = send_payment_LDKPayer_jcall,
10791                 .retry_payment = retry_payment_LDKPayer_jcall,
10792                 .free = LDKPayer_JCalls_free,
10793         };
10794         return ret;
10795 }
10796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
10797         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10798         *res_ptr = LDKPayer_init(env, clz, o);
10799         return (uint64_t)res_ptr;
10800 }
10801 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
10802         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10803         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10804         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10805         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
10806         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
10807         return ret_arr;
10808 }
10809
10810 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
10811         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10812         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10813         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10814         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10815         int64_tArray ret_arr = NULL;
10816         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10817         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10818         for (size_t q = 0; q < ret_var.datalen; q++) {
10819                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10820                 uint64_t ret_conv_16_ref = 0;
10821                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10822                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10823                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10824                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
10825                 if (ret_conv_16_var.is_owned) {
10826                         ret_conv_16_ref |= 1;
10827                 }
10828                 ret_arr_ptr[q] = ret_conv_16_ref;
10829         }
10830         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10831         FREE(ret_var.data);
10832         return ret_arr;
10833 }
10834
10835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
10836         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10837         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10838         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10839         LDKRoute route_conv;
10840         route_conv.inner = (void*)(route & (~1));
10841         route_conv.is_owned = false;
10842         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10843         LDKThirtyTwoBytes payment_hash_ref;
10844         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
10845         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
10846         LDKThirtyTwoBytes payment_secret_ref;
10847         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
10848         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
10849         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10850         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10851         return (uint64_t)ret_conv;
10852 }
10853
10854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payer_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
10855         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10856         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10857         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10858         LDKRoute route_conv;
10859         route_conv.inner = (void*)(route & (~1));
10860         route_conv.is_owned = false;
10861         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10862         LDKThirtyTwoBytes payment_id_ref;
10863         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
10864         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
10865         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10866         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10867         return (uint64_t)ret_conv;
10868 }
10869
10870 typedef struct LDKRouter_JCalls {
10871         atomic_size_t refcnt;
10872         JavaVM *vm;
10873         jweak o;
10874         jmethodID find_route_meth;
10875 } LDKRouter_JCalls;
10876 static void LDKRouter_JCalls_free(void* this_arg) {
10877         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10878         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10879                 JNIEnv *env;
10880                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10881                 if (get_jenv_res == JNI_EDETACHED) {
10882                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10883                 } else {
10884                         DO_ASSERT(get_jenv_res == JNI_OK);
10885                 }
10886                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10887                 if (get_jenv_res == JNI_EDETACHED) {
10888                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10889                 }
10890                 FREE(j_calls);
10891         }
10892 }
10893 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
10894         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10895         JNIEnv *env;
10896         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10897         if (get_jenv_res == JNI_EDETACHED) {
10898                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10899         } else {
10900                 DO_ASSERT(get_jenv_res == JNI_OK);
10901         }
10902         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
10903         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
10904         LDKRouteParameters params_var = *params;
10905         uint64_t params_ref = 0;
10906         params_var = RouteParameters_clone(params);
10907         CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10908         CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10909         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_var);
10910         params_ref = (uint64_t)params_var.inner;
10911         if (params_var.is_owned) {
10912                 params_ref |= 1;
10913         }
10914         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10915         int64_tArray first_hops_arr = NULL;
10916         if (first_hops != NULL) {
10917                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10918                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
10919                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
10920                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10921                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10922                         uint64_t first_hops_conv_16_ref = 0;
10923                         CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10924                         CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10925                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10926                         first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
10927                         if (first_hops_conv_16_var.is_owned) {
10928                                 first_hops_conv_16_ref |= 1;
10929                         }
10930                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10931                 }
10932                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
10933         }
10934         // WARNING: This object doesn't live past this scope, needs clone!
10935         uint64_t ret_scorer = ((uint64_t)scorer) | 1;
10936         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10937         CHECK(obj != NULL);
10938         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
10939         if ((*env)->ExceptionCheck(env)) {
10940                 (*env)->ExceptionDescribe(env);
10941                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
10942         }
10943         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10944         CHECK_ACCESS(ret_ptr);
10945         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10946         FREE((void*)ret);
10947         if (get_jenv_res == JNI_EDETACHED) {
10948                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10949         }
10950         return ret_conv;
10951 }
10952 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10953         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10954         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10955 }
10956 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
10957         jclass c = (*env)->GetObjectClass(env, o);
10958         CHECK(c != NULL);
10959         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10960         atomic_init(&calls->refcnt, 1);
10961         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10962         calls->o = (*env)->NewWeakGlobalRef(env, o);
10963         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
10964         CHECK(calls->find_route_meth != NULL);
10965
10966         LDKRouter ret = {
10967                 .this_arg = (void*) calls,
10968                 .find_route = find_route_LDKRouter_jcall,
10969                 .free = LDKRouter_JCalls_free,
10970         };
10971         return ret;
10972 }
10973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
10974         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10975         *res_ptr = LDKRouter_init(env, clz, o);
10976         return (uint64_t)res_ptr;
10977 }
10978 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 params, int64_tArray first_hops, int64_t scorer) {
10979         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10980         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10981         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10982         LDKPublicKey payer_ref;
10983         CHECK((*env)->GetArrayLength(env, payer) == 33);
10984         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
10985         LDKRouteParameters params_conv;
10986         params_conv.inner = (void*)(params & (~1));
10987         params_conv.is_owned = false;
10988         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
10989         LDKCVec_ChannelDetailsZ first_hops_constr;
10990         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10991         if (first_hops != NULL) {
10992                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
10993                 if (first_hops_constr.datalen > 0)
10994                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10995                 else
10996                         first_hops_constr.data = NULL;
10997                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
10998                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
10999                         int64_t first_hops_conv_16 = first_hops_vals[q];
11000                         LDKChannelDetails first_hops_conv_16_conv;
11001                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
11002                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
11003                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
11004                         first_hops_constr.data[q] = first_hops_conv_16_conv;
11005                 }
11006                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
11007                 first_hops_ptr = &first_hops_constr;
11008         }
11009         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
11010         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
11011         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
11012         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11013         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
11014         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
11015         return (uint64_t)ret_conv;
11016 }
11017
11018 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
11019         LDKStr ret_str = _ldk_get_compiled_version();
11020         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
11021         Str_free(ret_str);
11022         return ret_conv;
11023 }
11024
11025 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
11026         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11027         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
11028         Str_free(ret_str);
11029         return ret_conv;
11030 }
11031
11032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
11033         LDKTransaction _res_ref;
11034         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
11035         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11036         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
11037         _res_ref.data_is_owned = true;
11038         Transaction_free(_res_ref);
11039 }
11040
11041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
11042         LDKCVec_u8Z script_pubkey_ref;
11043         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
11044         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11045         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
11046         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11047         *ret_ref = TxOut_new(script_pubkey_ref, value);
11048         return (uint64_t)ret_ref;
11049 }
11050
11051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
11052         if ((_res & 1) != 0) return;
11053         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11054         CHECK_ACCESS(_res_ptr);
11055         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11056         FREE((void*)_res);
11057         TxOut_free(_res_conv);
11058 }
11059
11060 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11061         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11062         *ret_ref = TxOut_clone(arg);
11063         return (uint64_t)ret_ref;
11064 }
11065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11066         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
11067         int64_t ret_val = TxOut_clone_ptr(arg_conv);
11068         return ret_val;
11069 }
11070
11071 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11072         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11073         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11074         *ret_ref = TxOut_clone(orig_conv);
11075         return (uint64_t)ret_ref;
11076 }
11077
11078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
11079         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11080         Str_free(dummy);
11081 }
11082
11083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11084         LDKSecretKey o_ref;
11085         CHECK((*env)->GetArrayLength(env, o) == 32);
11086         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
11087         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11088         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11089         return (uint64_t)ret_conv;
11090 }
11091
11092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11093         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11094         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11095         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11096         return (uint64_t)ret_conv;
11097 }
11098
11099 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11100         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11101         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
11102         return ret_val;
11103 }
11104
11105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11106         if ((_res & 1) != 0) return;
11107         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11108         CHECK_ACCESS(_res_ptr);
11109         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11110         FREE((void*)_res);
11111         CResult_SecretKeyErrorZ_free(_res_conv);
11112 }
11113
11114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11115         LDKPublicKey o_ref;
11116         CHECK((*env)->GetArrayLength(env, o) == 33);
11117         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
11118         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11119         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11120         return (uint64_t)ret_conv;
11121 }
11122
11123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11124         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11125         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11126         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11127         return (uint64_t)ret_conv;
11128 }
11129
11130 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11131         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11132         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
11133         return ret_val;
11134 }
11135
11136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11137         if ((_res & 1) != 0) return;
11138         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11139         CHECK_ACCESS(_res_ptr);
11140         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11141         FREE((void*)_res);
11142         CResult_PublicKeyErrorZ_free(_res_conv);
11143 }
11144
11145 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11146         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11147         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11148         return (uint64_t)ret_conv;
11149 }
11150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11151         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11152         int64_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11153         return ret_val;
11154 }
11155
11156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11157         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11158         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11159         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11160         return (uint64_t)ret_conv;
11161 }
11162
11163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11164         LDKTxCreationKeys o_conv;
11165         o_conv.inner = (void*)(o & (~1));
11166         o_conv.is_owned = (o & 1) || (o == 0);
11167         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11168         o_conv = TxCreationKeys_clone(&o_conv);
11169         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11170         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11171         return (uint64_t)ret_conv;
11172 }
11173
11174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11175         LDKDecodeError e_conv;
11176         e_conv.inner = (void*)(e & (~1));
11177         e_conv.is_owned = (e & 1) || (e == 0);
11178         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11179         e_conv = DecodeError_clone(&e_conv);
11180         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11181         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11182         return (uint64_t)ret_conv;
11183 }
11184
11185 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11186         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11187         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11188         return ret_val;
11189 }
11190
11191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11192         if ((_res & 1) != 0) return;
11193         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11194         CHECK_ACCESS(_res_ptr);
11195         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11196         FREE((void*)_res);
11197         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11198 }
11199
11200 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11201         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11202         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11203         return (uint64_t)ret_conv;
11204 }
11205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11206         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11207         int64_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11208         return ret_val;
11209 }
11210
11211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11212         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11213         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11214         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11215         return (uint64_t)ret_conv;
11216 }
11217
11218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11219         LDKChannelPublicKeys o_conv;
11220         o_conv.inner = (void*)(o & (~1));
11221         o_conv.is_owned = (o & 1) || (o == 0);
11222         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11223         o_conv = ChannelPublicKeys_clone(&o_conv);
11224         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11225         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11226         return (uint64_t)ret_conv;
11227 }
11228
11229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11230         LDKDecodeError e_conv;
11231         e_conv.inner = (void*)(e & (~1));
11232         e_conv.is_owned = (e & 1) || (e == 0);
11233         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11234         e_conv = DecodeError_clone(&e_conv);
11235         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11236         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11237         return (uint64_t)ret_conv;
11238 }
11239
11240 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11241         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11242         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11243         return ret_val;
11244 }
11245
11246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11247         if ((_res & 1) != 0) return;
11248         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11249         CHECK_ACCESS(_res_ptr);
11250         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11251         FREE((void*)_res);
11252         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11253 }
11254
11255 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11256         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11257         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11258         return (uint64_t)ret_conv;
11259 }
11260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11261         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11262         int64_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11263         return ret_val;
11264 }
11265
11266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11267         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11268         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11269         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11270         return (uint64_t)ret_conv;
11271 }
11272
11273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11274         LDKTxCreationKeys o_conv;
11275         o_conv.inner = (void*)(o & (~1));
11276         o_conv.is_owned = (o & 1) || (o == 0);
11277         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11278         o_conv = TxCreationKeys_clone(&o_conv);
11279         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11280         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11281         return (uint64_t)ret_conv;
11282 }
11283
11284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11285         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11286         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11287         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11288         return (uint64_t)ret_conv;
11289 }
11290
11291 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11292         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11293         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11294         return ret_val;
11295 }
11296
11297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11298         if ((_res & 1) != 0) return;
11299         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11300         CHECK_ACCESS(_res_ptr);
11301         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11302         FREE((void*)_res);
11303         CResult_TxCreationKeysErrorZ_free(_res_conv);
11304 }
11305
11306 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11307         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11308         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11309         return (uint64_t)ret_conv;
11310 }
11311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11312         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11313         int64_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11314         return ret_val;
11315 }
11316
11317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11318         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11319         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11320         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11321         return (uint64_t)ret_conv;
11322 }
11323
11324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
11325         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11326         *ret_copy = COption_u32Z_some(o);
11327         uint64_t ret_ref = (uint64_t)ret_copy;
11328         return ret_ref;
11329 }
11330
11331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
11332         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11333         *ret_copy = COption_u32Z_none();
11334         uint64_t ret_ref = (uint64_t)ret_copy;
11335         return ret_ref;
11336 }
11337
11338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11339         if ((_res & 1) != 0) return;
11340         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11341         CHECK_ACCESS(_res_ptr);
11342         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11343         FREE((void*)_res);
11344         COption_u32Z_free(_res_conv);
11345 }
11346
11347 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11348         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11349         *ret_copy = COption_u32Z_clone(arg);
11350 uint64_t ret_ref = (uint64_t)ret_copy;
11351         return ret_ref;
11352 }
11353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11354         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11355         int64_t ret_val = COption_u32Z_clone_ptr(arg_conv);
11356         return ret_val;
11357 }
11358
11359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11360         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11361         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11362         *ret_copy = COption_u32Z_clone(orig_conv);
11363         uint64_t ret_ref = (uint64_t)ret_copy;
11364         return ret_ref;
11365 }
11366
11367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11368         LDKHTLCOutputInCommitment o_conv;
11369         o_conv.inner = (void*)(o & (~1));
11370         o_conv.is_owned = (o & 1) || (o == 0);
11371         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11372         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11373         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11374         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11375         return (uint64_t)ret_conv;
11376 }
11377
11378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11379         LDKDecodeError e_conv;
11380         e_conv.inner = (void*)(e & (~1));
11381         e_conv.is_owned = (e & 1) || (e == 0);
11382         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11383         e_conv = DecodeError_clone(&e_conv);
11384         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11385         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11386         return (uint64_t)ret_conv;
11387 }
11388
11389 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11390         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11391         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11392         return ret_val;
11393 }
11394
11395 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11396         if ((_res & 1) != 0) return;
11397         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11398         CHECK_ACCESS(_res_ptr);
11399         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11400         FREE((void*)_res);
11401         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11402 }
11403
11404 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11405         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11406         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11407         return (uint64_t)ret_conv;
11408 }
11409 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11410         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11411         int64_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11412         return ret_val;
11413 }
11414
11415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11416         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11417         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11418         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11419         return (uint64_t)ret_conv;
11420 }
11421
11422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11423         LDKCounterpartyChannelTransactionParameters o_conv;
11424         o_conv.inner = (void*)(o & (~1));
11425         o_conv.is_owned = (o & 1) || (o == 0);
11426         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11427         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11428         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11429         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11430         return (uint64_t)ret_conv;
11431 }
11432
11433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11434         LDKDecodeError e_conv;
11435         e_conv.inner = (void*)(e & (~1));
11436         e_conv.is_owned = (e & 1) || (e == 0);
11437         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11438         e_conv = DecodeError_clone(&e_conv);
11439         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11440         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11441         return (uint64_t)ret_conv;
11442 }
11443
11444 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11445         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11446         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11447         return ret_val;
11448 }
11449
11450 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11451         if ((_res & 1) != 0) return;
11452         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11453         CHECK_ACCESS(_res_ptr);
11454         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11455         FREE((void*)_res);
11456         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11457 }
11458
11459 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11460         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11461         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11462         return (uint64_t)ret_conv;
11463 }
11464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11465         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11466         int64_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11467         return ret_val;
11468 }
11469
11470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11471         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11472         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11473         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11474         return (uint64_t)ret_conv;
11475 }
11476
11477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11478         LDKChannelTransactionParameters o_conv;
11479         o_conv.inner = (void*)(o & (~1));
11480         o_conv.is_owned = (o & 1) || (o == 0);
11481         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11482         o_conv = ChannelTransactionParameters_clone(&o_conv);
11483         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11484         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11485         return (uint64_t)ret_conv;
11486 }
11487
11488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11489         LDKDecodeError e_conv;
11490         e_conv.inner = (void*)(e & (~1));
11491         e_conv.is_owned = (e & 1) || (e == 0);
11492         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11493         e_conv = DecodeError_clone(&e_conv);
11494         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11495         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11496         return (uint64_t)ret_conv;
11497 }
11498
11499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11500         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11501         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11502         return ret_val;
11503 }
11504
11505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11506         if ((_res & 1) != 0) return;
11507         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11508         CHECK_ACCESS(_res_ptr);
11509         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11510         FREE((void*)_res);
11511         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11512 }
11513
11514 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11515         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11516         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11517         return (uint64_t)ret_conv;
11518 }
11519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11520         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11521         int64_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11522         return ret_val;
11523 }
11524
11525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11526         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11527         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11528         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11529         return (uint64_t)ret_conv;
11530 }
11531
11532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11533         LDKCVec_SignatureZ _res_constr;
11534         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11535         if (_res_constr.datalen > 0)
11536                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11537         else
11538                 _res_constr.data = NULL;
11539         for (size_t i = 0; i < _res_constr.datalen; i++) {
11540                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11541                 LDKSignature _res_conv_8_ref;
11542                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
11543                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
11544                 _res_constr.data[i] = _res_conv_8_ref;
11545         }
11546         CVec_SignatureZ_free(_res_constr);
11547 }
11548
11549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11550         LDKHolderCommitmentTransaction o_conv;
11551         o_conv.inner = (void*)(o & (~1));
11552         o_conv.is_owned = (o & 1) || (o == 0);
11553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11554         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11555         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11556         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11557         return (uint64_t)ret_conv;
11558 }
11559
11560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11561         LDKDecodeError e_conv;
11562         e_conv.inner = (void*)(e & (~1));
11563         e_conv.is_owned = (e & 1) || (e == 0);
11564         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11565         e_conv = DecodeError_clone(&e_conv);
11566         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11567         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11568         return (uint64_t)ret_conv;
11569 }
11570
11571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11572         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11573         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11574         return ret_val;
11575 }
11576
11577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11578         if ((_res & 1) != 0) return;
11579         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11580         CHECK_ACCESS(_res_ptr);
11581         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11582         FREE((void*)_res);
11583         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11584 }
11585
11586 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11587         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11588         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11589         return (uint64_t)ret_conv;
11590 }
11591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11592         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11593         int64_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11594         return ret_val;
11595 }
11596
11597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11598         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11599         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11600         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11601         return (uint64_t)ret_conv;
11602 }
11603
11604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11605         LDKBuiltCommitmentTransaction o_conv;
11606         o_conv.inner = (void*)(o & (~1));
11607         o_conv.is_owned = (o & 1) || (o == 0);
11608         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11609         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11610         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11611         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11612         return (uint64_t)ret_conv;
11613 }
11614
11615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11616         LDKDecodeError e_conv;
11617         e_conv.inner = (void*)(e & (~1));
11618         e_conv.is_owned = (e & 1) || (e == 0);
11619         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11620         e_conv = DecodeError_clone(&e_conv);
11621         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11622         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11623         return (uint64_t)ret_conv;
11624 }
11625
11626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11627         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11628         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11629         return ret_val;
11630 }
11631
11632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11633         if ((_res & 1) != 0) return;
11634         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11635         CHECK_ACCESS(_res_ptr);
11636         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11637         FREE((void*)_res);
11638         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11639 }
11640
11641 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11642         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11643         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11644         return (uint64_t)ret_conv;
11645 }
11646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11647         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11648         int64_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11649         return ret_val;
11650 }
11651
11652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11653         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11654         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11655         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11656         return (uint64_t)ret_conv;
11657 }
11658
11659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11660         LDKTrustedClosingTransaction o_conv;
11661         o_conv.inner = (void*)(o & (~1));
11662         o_conv.is_owned = (o & 1) || (o == 0);
11663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11664         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
11665         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11666         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11667         return (uint64_t)ret_conv;
11668 }
11669
11670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
11671         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11672         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11673         return (uint64_t)ret_conv;
11674 }
11675
11676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11677         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11678         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11679         return ret_val;
11680 }
11681
11682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11683         if ((_res & 1) != 0) return;
11684         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11685         CHECK_ACCESS(_res_ptr);
11686         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11687         FREE((void*)_res);
11688         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11689 }
11690
11691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11692         LDKCommitmentTransaction o_conv;
11693         o_conv.inner = (void*)(o & (~1));
11694         o_conv.is_owned = (o & 1) || (o == 0);
11695         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11696         o_conv = CommitmentTransaction_clone(&o_conv);
11697         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11698         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11699         return (uint64_t)ret_conv;
11700 }
11701
11702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11703         LDKDecodeError e_conv;
11704         e_conv.inner = (void*)(e & (~1));
11705         e_conv.is_owned = (e & 1) || (e == 0);
11706         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11707         e_conv = DecodeError_clone(&e_conv);
11708         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11709         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11710         return (uint64_t)ret_conv;
11711 }
11712
11713 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11714         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11715         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11716         return ret_val;
11717 }
11718
11719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11720         if ((_res & 1) != 0) return;
11721         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11722         CHECK_ACCESS(_res_ptr);
11723         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11724         FREE((void*)_res);
11725         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11726 }
11727
11728 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11729         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11730         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11731         return (uint64_t)ret_conv;
11732 }
11733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11734         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11735         int64_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11736         return ret_val;
11737 }
11738
11739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11740         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11741         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11742         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11743         return (uint64_t)ret_conv;
11744 }
11745
11746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11747         LDKTrustedCommitmentTransaction o_conv;
11748         o_conv.inner = (void*)(o & (~1));
11749         o_conv.is_owned = (o & 1) || (o == 0);
11750         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11751         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11752         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11753         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11754         return (uint64_t)ret_conv;
11755 }
11756
11757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
11758         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11759         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11760         return (uint64_t)ret_conv;
11761 }
11762
11763 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11764         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11765         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11766         return ret_val;
11767 }
11768
11769 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11770         if ((_res & 1) != 0) return;
11771         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11772         CHECK_ACCESS(_res_ptr);
11773         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11774         FREE((void*)_res);
11775         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11776 }
11777
11778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
11779         LDKCVec_SignatureZ o_constr;
11780         o_constr.datalen = (*env)->GetArrayLength(env, o);
11781         if (o_constr.datalen > 0)
11782                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11783         else
11784                 o_constr.data = NULL;
11785         for (size_t i = 0; i < o_constr.datalen; i++) {
11786                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
11787                 LDKSignature o_conv_8_ref;
11788                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
11789                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
11790                 o_constr.data[i] = o_conv_8_ref;
11791         }
11792         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11793         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11794         return (uint64_t)ret_conv;
11795 }
11796
11797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
11798         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11799         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11800         return (uint64_t)ret_conv;
11801 }
11802
11803 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11804         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11805         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11806         return ret_val;
11807 }
11808
11809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11810         if ((_res & 1) != 0) return;
11811         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11812         CHECK_ACCESS(_res_ptr);
11813         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11814         FREE((void*)_res);
11815         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11816 }
11817
11818 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11819         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11820         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11821         return (uint64_t)ret_conv;
11822 }
11823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11824         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11825         int64_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11826         return ret_val;
11827 }
11828
11829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11830         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11831         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11832         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11833         return (uint64_t)ret_conv;
11834 }
11835
11836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11837         LDKShutdownScript o_conv;
11838         o_conv.inner = (void*)(o & (~1));
11839         o_conv.is_owned = (o & 1) || (o == 0);
11840         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11841         o_conv = ShutdownScript_clone(&o_conv);
11842         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11843         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11844         return (uint64_t)ret_conv;
11845 }
11846
11847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11848         LDKDecodeError e_conv;
11849         e_conv.inner = (void*)(e & (~1));
11850         e_conv.is_owned = (e & 1) || (e == 0);
11851         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11852         e_conv = DecodeError_clone(&e_conv);
11853         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11854         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11855         return (uint64_t)ret_conv;
11856 }
11857
11858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11859         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11860         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11861         return ret_val;
11862 }
11863
11864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11865         if ((_res & 1) != 0) return;
11866         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11867         CHECK_ACCESS(_res_ptr);
11868         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11869         FREE((void*)_res);
11870         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11871 }
11872
11873 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11874         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11875         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11876         return (uint64_t)ret_conv;
11877 }
11878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11879         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11880         int64_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11881         return ret_val;
11882 }
11883
11884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11885         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11886         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11887         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11888         return (uint64_t)ret_conv;
11889 }
11890
11891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11892         LDKShutdownScript o_conv;
11893         o_conv.inner = (void*)(o & (~1));
11894         o_conv.is_owned = (o & 1) || (o == 0);
11895         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11896         o_conv = ShutdownScript_clone(&o_conv);
11897         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11898         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11899         return (uint64_t)ret_conv;
11900 }
11901
11902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11903         LDKInvalidShutdownScript e_conv;
11904         e_conv.inner = (void*)(e & (~1));
11905         e_conv.is_owned = (e & 1) || (e == 0);
11906         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11907         e_conv = InvalidShutdownScript_clone(&e_conv);
11908         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11909         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11910         return (uint64_t)ret_conv;
11911 }
11912
11913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11914         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11915         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11916         return ret_val;
11917 }
11918
11919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11920         if ((_res & 1) != 0) return;
11921         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11922         CHECK_ACCESS(_res_ptr);
11923         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11924         FREE((void*)_res);
11925         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11926 }
11927
11928 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11929         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11930         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11931         return (uint64_t)ret_conv;
11932 }
11933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11934         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11935         int64_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11936         return ret_val;
11937 }
11938
11939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11940         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11941         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11942         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11943         return (uint64_t)ret_conv;
11944 }
11945
11946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
11947         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11948         *ret_conv = CResult_NoneErrorZ_ok();
11949         return (uint64_t)ret_conv;
11950 }
11951
11952 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11953         LDKIOError e_conv = LDKIOError_from_java(env, e);
11954         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11955         *ret_conv = CResult_NoneErrorZ_err(e_conv);
11956         return (uint64_t)ret_conv;
11957 }
11958
11959 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11960         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
11961         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
11962         return ret_val;
11963 }
11964
11965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11966         if ((_res & 1) != 0) return;
11967         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11968         CHECK_ACCESS(_res_ptr);
11969         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
11970         FREE((void*)_res);
11971         CResult_NoneErrorZ_free(_res_conv);
11972 }
11973
11974 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
11975         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11976         *ret_conv = CResult_NoneErrorZ_clone(arg);
11977         return (uint64_t)ret_conv;
11978 }
11979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11980         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
11981         int64_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
11982         return ret_val;
11983 }
11984
11985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11986         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
11987         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11988         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
11989         return (uint64_t)ret_conv;
11990 }
11991
11992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11993         LDKRouteHop o_conv;
11994         o_conv.inner = (void*)(o & (~1));
11995         o_conv.is_owned = (o & 1) || (o == 0);
11996         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11997         o_conv = RouteHop_clone(&o_conv);
11998         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
11999         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12000         return (uint64_t)ret_conv;
12001 }
12002
12003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12004         LDKDecodeError e_conv;
12005         e_conv.inner = (void*)(e & (~1));
12006         e_conv.is_owned = (e & 1) || (e == 0);
12007         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12008         e_conv = DecodeError_clone(&e_conv);
12009         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12010         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12011         return (uint64_t)ret_conv;
12012 }
12013
12014 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12015         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
12016         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12017         return ret_val;
12018 }
12019
12020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12021         if ((_res & 1) != 0) return;
12022         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12023         CHECK_ACCESS(_res_ptr);
12024         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12025         FREE((void*)_res);
12026         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12027 }
12028
12029 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12030         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12031         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12032         return (uint64_t)ret_conv;
12033 }
12034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12035         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12036         int64_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12037         return ret_val;
12038 }
12039
12040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12041         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12042         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12043         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12044         return (uint64_t)ret_conv;
12045 }
12046
12047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12048         LDKCVec_RouteHopZ _res_constr;
12049         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12050         if (_res_constr.datalen > 0)
12051                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12052         else
12053                 _res_constr.data = NULL;
12054         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12055         for (size_t k = 0; k < _res_constr.datalen; k++) {
12056                 int64_t _res_conv_10 = _res_vals[k];
12057                 LDKRouteHop _res_conv_10_conv;
12058                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12059                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12060                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12061                 _res_constr.data[k] = _res_conv_10_conv;
12062         }
12063         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12064         CVec_RouteHopZ_free(_res_constr);
12065 }
12066
12067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12068         LDKCVec_CVec_RouteHopZZ _res_constr;
12069         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12070         if (_res_constr.datalen > 0)
12071                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12072         else
12073                 _res_constr.data = NULL;
12074         for (size_t m = 0; m < _res_constr.datalen; m++) {
12075                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
12076                 LDKCVec_RouteHopZ _res_conv_12_constr;
12077                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
12078                 if (_res_conv_12_constr.datalen > 0)
12079                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12080                 else
12081                         _res_conv_12_constr.data = NULL;
12082                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
12083                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12084                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12085                         LDKRouteHop _res_conv_12_conv_10_conv;
12086                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12087                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12088                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12089                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12090                 }
12091                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
12092                 _res_constr.data[m] = _res_conv_12_constr;
12093         }
12094         CVec_CVec_RouteHopZZ_free(_res_constr);
12095 }
12096
12097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12098         LDKRoute o_conv;
12099         o_conv.inner = (void*)(o & (~1));
12100         o_conv.is_owned = (o & 1) || (o == 0);
12101         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12102         o_conv = Route_clone(&o_conv);
12103         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12104         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12105         return (uint64_t)ret_conv;
12106 }
12107
12108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12109         LDKDecodeError e_conv;
12110         e_conv.inner = (void*)(e & (~1));
12111         e_conv.is_owned = (e & 1) || (e == 0);
12112         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12113         e_conv = DecodeError_clone(&e_conv);
12114         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12115         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12116         return (uint64_t)ret_conv;
12117 }
12118
12119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12120         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12121         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12122         return ret_val;
12123 }
12124
12125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12126         if ((_res & 1) != 0) return;
12127         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12128         CHECK_ACCESS(_res_ptr);
12129         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12130         FREE((void*)_res);
12131         CResult_RouteDecodeErrorZ_free(_res_conv);
12132 }
12133
12134 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12135         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12136         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12137         return (uint64_t)ret_conv;
12138 }
12139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12140         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12141         int64_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12142         return ret_val;
12143 }
12144
12145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12146         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12147         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12148         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12149         return (uint64_t)ret_conv;
12150 }
12151
12152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12153         LDKRouteParameters o_conv;
12154         o_conv.inner = (void*)(o & (~1));
12155         o_conv.is_owned = (o & 1) || (o == 0);
12156         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12157         o_conv = RouteParameters_clone(&o_conv);
12158         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12159         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12160         return (uint64_t)ret_conv;
12161 }
12162
12163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12164         LDKDecodeError e_conv;
12165         e_conv.inner = (void*)(e & (~1));
12166         e_conv.is_owned = (e & 1) || (e == 0);
12167         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12168         e_conv = DecodeError_clone(&e_conv);
12169         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12170         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12171         return (uint64_t)ret_conv;
12172 }
12173
12174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12175         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12176         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12177         return ret_val;
12178 }
12179
12180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12181         if ((_res & 1) != 0) return;
12182         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12183         CHECK_ACCESS(_res_ptr);
12184         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12185         FREE((void*)_res);
12186         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12187 }
12188
12189 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12190         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12191         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12192         return (uint64_t)ret_conv;
12193 }
12194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12195         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12196         int64_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12197         return ret_val;
12198 }
12199
12200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12201         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12202         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12203         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12204         return (uint64_t)ret_conv;
12205 }
12206
12207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12208         LDKCVec_RouteHintZ _res_constr;
12209         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12210         if (_res_constr.datalen > 0)
12211                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12212         else
12213                 _res_constr.data = NULL;
12214         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12215         for (size_t l = 0; l < _res_constr.datalen; l++) {
12216                 int64_t _res_conv_11 = _res_vals[l];
12217                 LDKRouteHint _res_conv_11_conv;
12218                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12219                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12220                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12221                 _res_constr.data[l] = _res_conv_11_conv;
12222         }
12223         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12224         CVec_RouteHintZ_free(_res_constr);
12225 }
12226
12227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
12228         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12229         *ret_copy = COption_u64Z_some(o);
12230         uint64_t ret_ref = (uint64_t)ret_copy;
12231         return ret_ref;
12232 }
12233
12234 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
12235         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12236         *ret_copy = COption_u64Z_none();
12237         uint64_t ret_ref = (uint64_t)ret_copy;
12238         return ret_ref;
12239 }
12240
12241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12242         if ((_res & 1) != 0) return;
12243         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12244         CHECK_ACCESS(_res_ptr);
12245         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12246         FREE((void*)_res);
12247         COption_u64Z_free(_res_conv);
12248 }
12249
12250 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12251         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12252         *ret_copy = COption_u64Z_clone(arg);
12253 uint64_t ret_ref = (uint64_t)ret_copy;
12254         return ret_ref;
12255 }
12256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12257         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12258         int64_t ret_val = COption_u64Z_clone_ptr(arg_conv);
12259         return ret_val;
12260 }
12261
12262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12263         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12264         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12265         *ret_copy = COption_u64Z_clone(orig_conv);
12266         uint64_t ret_ref = (uint64_t)ret_copy;
12267         return ret_ref;
12268 }
12269
12270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12271         LDKPayee o_conv;
12272         o_conv.inner = (void*)(o & (~1));
12273         o_conv.is_owned = (o & 1) || (o == 0);
12274         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12275         o_conv = Payee_clone(&o_conv);
12276         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12277         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
12278         return (uint64_t)ret_conv;
12279 }
12280
12281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12282         LDKDecodeError e_conv;
12283         e_conv.inner = (void*)(e & (~1));
12284         e_conv.is_owned = (e & 1) || (e == 0);
12285         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12286         e_conv = DecodeError_clone(&e_conv);
12287         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12288         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
12289         return (uint64_t)ret_conv;
12290 }
12291
12292 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12293         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
12294         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
12295         return ret_val;
12296 }
12297
12298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12299         if ((_res & 1) != 0) return;
12300         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12301         CHECK_ACCESS(_res_ptr);
12302         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
12303         FREE((void*)_res);
12304         CResult_PayeeDecodeErrorZ_free(_res_conv);
12305 }
12306
12307 static inline uint64_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
12308         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12309         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
12310         return (uint64_t)ret_conv;
12311 }
12312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12313         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
12314         int64_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
12315         return ret_val;
12316 }
12317
12318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12319         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
12320         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12321         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
12322         return (uint64_t)ret_conv;
12323 }
12324
12325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12326         LDKCVec_RouteHintHopZ _res_constr;
12327         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12328         if (_res_constr.datalen > 0)
12329                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12330         else
12331                 _res_constr.data = NULL;
12332         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12333         for (size_t o = 0; o < _res_constr.datalen; o++) {
12334                 int64_t _res_conv_14 = _res_vals[o];
12335                 LDKRouteHintHop _res_conv_14_conv;
12336                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12337                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12338                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12339                 _res_constr.data[o] = _res_conv_14_conv;
12340         }
12341         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12342         CVec_RouteHintHopZ_free(_res_constr);
12343 }
12344
12345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12346         LDKRouteHint o_conv;
12347         o_conv.inner = (void*)(o & (~1));
12348         o_conv.is_owned = (o & 1) || (o == 0);
12349         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12350         o_conv = RouteHint_clone(&o_conv);
12351         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12352         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12353         return (uint64_t)ret_conv;
12354 }
12355
12356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12357         LDKDecodeError e_conv;
12358         e_conv.inner = (void*)(e & (~1));
12359         e_conv.is_owned = (e & 1) || (e == 0);
12360         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12361         e_conv = DecodeError_clone(&e_conv);
12362         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12363         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12364         return (uint64_t)ret_conv;
12365 }
12366
12367 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12368         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12369         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12370         return ret_val;
12371 }
12372
12373 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12374         if ((_res & 1) != 0) return;
12375         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12376         CHECK_ACCESS(_res_ptr);
12377         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12378         FREE((void*)_res);
12379         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12380 }
12381
12382 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12383         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12384         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12385         return (uint64_t)ret_conv;
12386 }
12387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12388         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12389         int64_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12390         return ret_val;
12391 }
12392
12393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12394         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12395         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12396         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12397         return (uint64_t)ret_conv;
12398 }
12399
12400 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12401         LDKRouteHintHop o_conv;
12402         o_conv.inner = (void*)(o & (~1));
12403         o_conv.is_owned = (o & 1) || (o == 0);
12404         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12405         o_conv = RouteHintHop_clone(&o_conv);
12406         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12407         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12408         return (uint64_t)ret_conv;
12409 }
12410
12411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12412         LDKDecodeError e_conv;
12413         e_conv.inner = (void*)(e & (~1));
12414         e_conv.is_owned = (e & 1) || (e == 0);
12415         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12416         e_conv = DecodeError_clone(&e_conv);
12417         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12418         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12419         return (uint64_t)ret_conv;
12420 }
12421
12422 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12423         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12424         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12425         return ret_val;
12426 }
12427
12428 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12429         if ((_res & 1) != 0) return;
12430         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12431         CHECK_ACCESS(_res_ptr);
12432         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12433         FREE((void*)_res);
12434         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12435 }
12436
12437 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12438         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12439         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12440         return (uint64_t)ret_conv;
12441 }
12442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12443         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12444         int64_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12445         return ret_val;
12446 }
12447
12448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12449         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12450         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12451         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12452         return (uint64_t)ret_conv;
12453 }
12454
12455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12456         LDKCVec_ChannelDetailsZ _res_constr;
12457         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12458         if (_res_constr.datalen > 0)
12459                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12460         else
12461                 _res_constr.data = NULL;
12462         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12463         for (size_t q = 0; q < _res_constr.datalen; q++) {
12464                 int64_t _res_conv_16 = _res_vals[q];
12465                 LDKChannelDetails _res_conv_16_conv;
12466                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12467                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12468                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12469                 _res_constr.data[q] = _res_conv_16_conv;
12470         }
12471         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12472         CVec_ChannelDetailsZ_free(_res_constr);
12473 }
12474
12475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12476         LDKRoute o_conv;
12477         o_conv.inner = (void*)(o & (~1));
12478         o_conv.is_owned = (o & 1) || (o == 0);
12479         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12480         o_conv = Route_clone(&o_conv);
12481         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12482         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12483         return (uint64_t)ret_conv;
12484 }
12485
12486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12487         LDKLightningError e_conv;
12488         e_conv.inner = (void*)(e & (~1));
12489         e_conv.is_owned = (e & 1) || (e == 0);
12490         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12491         e_conv = LightningError_clone(&e_conv);
12492         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12493         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12494         return (uint64_t)ret_conv;
12495 }
12496
12497 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12498         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12499         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
12500         return ret_val;
12501 }
12502
12503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12504         if ((_res & 1) != 0) return;
12505         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12506         CHECK_ACCESS(_res_ptr);
12507         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12508         FREE((void*)_res);
12509         CResult_RouteLightningErrorZ_free(_res_conv);
12510 }
12511
12512 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12513         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12514         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12515         return (uint64_t)ret_conv;
12516 }
12517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12518         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12519         int64_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12520         return ret_val;
12521 }
12522
12523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12524         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12525         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12526         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12527         return (uint64_t)ret_conv;
12528 }
12529
12530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12531         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12532         CHECK_ACCESS(o_ptr);
12533         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12534         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
12535         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12536         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12537         return (uint64_t)ret_conv;
12538 }
12539
12540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12541         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
12542         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12543         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12544         return (uint64_t)ret_conv;
12545 }
12546
12547 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12548         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
12549         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
12550         return ret_val;
12551 }
12552
12553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12554         if ((_res & 1) != 0) return;
12555         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12556         CHECK_ACCESS(_res_ptr);
12557         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12558         FREE((void*)_res);
12559         CResult_TxOutAccessErrorZ_free(_res_conv);
12560 }
12561
12562 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
12563         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12564         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
12565         return (uint64_t)ret_conv;
12566 }
12567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12568         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
12569         int64_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
12570         return ret_val;
12571 }
12572
12573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12574         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12575         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12576         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12577         return (uint64_t)ret_conv;
12578 }
12579
12580 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
12581         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12582         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
12583         return ((uint64_t)ret_conv);
12584 }
12585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12586         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
12587         int64_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
12588         return ret_val;
12589 }
12590
12591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12592         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12593         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12594         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12595         return ((uint64_t)ret_conv);
12596 }
12597
12598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
12599         LDKTransaction b_ref;
12600         b_ref.datalen = (*env)->GetArrayLength(env, b);
12601         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12602         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
12603         b_ref.data_is_owned = true;
12604         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12605         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12606         return ((uint64_t)ret_conv);
12607 }
12608
12609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12610         if ((_res & 1) != 0) return;
12611         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12612         CHECK_ACCESS(_res_ptr);
12613         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12614         FREE((void*)_res);
12615         C2Tuple_usizeTransactionZ_free(_res_conv);
12616 }
12617
12618 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12619         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12620         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12621         if (_res_constr.datalen > 0)
12622                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12623         else
12624                 _res_constr.data = NULL;
12625         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12626         for (size_t c = 0; c < _res_constr.datalen; c++) {
12627                 int64_t _res_conv_28 = _res_vals[c];
12628                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
12629                 CHECK_ACCESS(_res_conv_28_ptr);
12630                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12631                 FREE((void*)_res_conv_28);
12632                 _res_constr.data[c] = _res_conv_28_conv;
12633         }
12634         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12635         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12636 }
12637
12638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12639         LDKCVec_TxidZ _res_constr;
12640         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12641         if (_res_constr.datalen > 0)
12642                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12643         else
12644                 _res_constr.data = NULL;
12645         for (size_t i = 0; i < _res_constr.datalen; i++) {
12646                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
12647                 LDKThirtyTwoBytes _res_conv_8_ref;
12648                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
12649                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
12650                 _res_constr.data[i] = _res_conv_8_ref;
12651         }
12652         CVec_TxidZ_free(_res_constr);
12653 }
12654
12655 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
12656         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12657         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12658         return (uint64_t)ret_conv;
12659 }
12660
12661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
12662         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
12663         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12664         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12665         return (uint64_t)ret_conv;
12666 }
12667
12668 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12669         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12670         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12671         return ret_val;
12672 }
12673
12674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12675         if ((_res & 1) != 0) return;
12676         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12677         CHECK_ACCESS(_res_ptr);
12678         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12679         FREE((void*)_res);
12680         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12681 }
12682
12683 static inline uint64_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12684         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12685         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12686         return (uint64_t)ret_conv;
12687 }
12688 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12689         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12690         int64_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12691         return ret_val;
12692 }
12693
12694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12695         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12696         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12697         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12698         return (uint64_t)ret_conv;
12699 }
12700
12701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12702         LDKCVec_MonitorEventZ _res_constr;
12703         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12704         if (_res_constr.datalen > 0)
12705                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12706         else
12707                 _res_constr.data = NULL;
12708         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12709         for (size_t o = 0; o < _res_constr.datalen; o++) {
12710                 int64_t _res_conv_14 = _res_vals[o];
12711                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
12712                 CHECK_ACCESS(_res_conv_14_ptr);
12713                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12714                 FREE((void*)_res_conv_14);
12715                 _res_constr.data[o] = _res_conv_14_conv;
12716         }
12717         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12718         CVec_MonitorEventZ_free(_res_constr);
12719 }
12720
12721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12722         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12723         CHECK_ACCESS(o_ptr);
12724         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12725         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
12726         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12727         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12728         uint64_t ret_ref = (uint64_t)ret_copy;
12729         return ret_ref;
12730 }
12731
12732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
12733         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12734         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12735         uint64_t ret_ref = (uint64_t)ret_copy;
12736         return ret_ref;
12737 }
12738
12739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12740         if ((_res & 1) != 0) return;
12741         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12742         CHECK_ACCESS(_res_ptr);
12743         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12744         FREE((void*)_res);
12745         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12746 }
12747
12748 static inline uint64_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12749         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12750         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12751 uint64_t ret_ref = (uint64_t)ret_copy;
12752         return ret_ref;
12753 }
12754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12755         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12756         int64_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12757         return ret_val;
12758 }
12759
12760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12761         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12762         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12763         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12764         uint64_t ret_ref = (uint64_t)ret_copy;
12765         return ret_ref;
12766 }
12767
12768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12769         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12770         CHECK_ACCESS(o_ptr);
12771         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12772         o_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)o) & ~1));
12773         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12774         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12775         uint64_t ret_ref = (uint64_t)ret_copy;
12776         return ret_ref;
12777 }
12778
12779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
12780         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12781         *ret_copy = COption_ClosureReasonZ_none();
12782         uint64_t ret_ref = (uint64_t)ret_copy;
12783         return ret_ref;
12784 }
12785
12786 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12787         if ((_res & 1) != 0) return;
12788         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12789         CHECK_ACCESS(_res_ptr);
12790         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12791         FREE((void*)_res);
12792         COption_ClosureReasonZ_free(_res_conv);
12793 }
12794
12795 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12796         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12797         *ret_copy = COption_ClosureReasonZ_clone(arg);
12798 uint64_t ret_ref = (uint64_t)ret_copy;
12799         return ret_ref;
12800 }
12801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12802         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12803         int64_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12804         return ret_val;
12805 }
12806
12807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12808         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12809         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12810         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12811         uint64_t ret_ref = (uint64_t)ret_copy;
12812         return ret_ref;
12813 }
12814
12815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12816         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12817         CHECK_ACCESS(o_ptr);
12818         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12819         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uint64_t)o) & ~1));
12820         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12821         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12822         return (uint64_t)ret_conv;
12823 }
12824
12825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12826         LDKDecodeError e_conv;
12827         e_conv.inner = (void*)(e & (~1));
12828         e_conv.is_owned = (e & 1) || (e == 0);
12829         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12830         e_conv = DecodeError_clone(&e_conv);
12831         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12832         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12833         return (uint64_t)ret_conv;
12834 }
12835
12836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12837         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12838         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12839         return ret_val;
12840 }
12841
12842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12843         if ((_res & 1) != 0) return;
12844         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12845         CHECK_ACCESS(_res_ptr);
12846         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12847         FREE((void*)_res);
12848         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12849 }
12850
12851 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12852         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12853         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12854         return (uint64_t)ret_conv;
12855 }
12856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12857         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12858         int64_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12859         return ret_val;
12860 }
12861
12862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12863         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12864         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12865         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12866         return (uint64_t)ret_conv;
12867 }
12868
12869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12870         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12871         CHECK_ACCESS(o_ptr);
12872         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12873         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
12874         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12875         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12876         uint64_t ret_ref = (uint64_t)ret_copy;
12877         return ret_ref;
12878 }
12879
12880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
12881         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12882         *ret_copy = COption_NetworkUpdateZ_none();
12883         uint64_t ret_ref = (uint64_t)ret_copy;
12884         return ret_ref;
12885 }
12886
12887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12888         if ((_res & 1) != 0) return;
12889         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12890         CHECK_ACCESS(_res_ptr);
12891         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12892         FREE((void*)_res);
12893         COption_NetworkUpdateZ_free(_res_conv);
12894 }
12895
12896 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12897         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12898         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12899 uint64_t ret_ref = (uint64_t)ret_copy;
12900         return ret_ref;
12901 }
12902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12903         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12904         int64_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12905         return ret_val;
12906 }
12907
12908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12909         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12910         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12911         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12912         uint64_t ret_ref = (uint64_t)ret_copy;
12913         return ret_ref;
12914 }
12915
12916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12917         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12918         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12919         if (_res_constr.datalen > 0)
12920                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12921         else
12922                 _res_constr.data = NULL;
12923         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12924         for (size_t b = 0; b < _res_constr.datalen; b++) {
12925                 int64_t _res_conv_27 = _res_vals[b];
12926                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
12927                 CHECK_ACCESS(_res_conv_27_ptr);
12928                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12929                 FREE((void*)_res_conv_27);
12930                 _res_constr.data[b] = _res_conv_27_conv;
12931         }
12932         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12933         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12934 }
12935
12936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12937         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12938         CHECK_ACCESS(o_ptr);
12939         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12940         o_conv = Event_clone((LDKEvent*)(((uint64_t)o) & ~1));
12941         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12942         *ret_copy = COption_EventZ_some(o_conv);
12943         uint64_t ret_ref = (uint64_t)ret_copy;
12944         return ret_ref;
12945 }
12946
12947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
12948         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12949         *ret_copy = COption_EventZ_none();
12950         uint64_t ret_ref = (uint64_t)ret_copy;
12951         return ret_ref;
12952 }
12953
12954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12955         if ((_res & 1) != 0) return;
12956         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12957         CHECK_ACCESS(_res_ptr);
12958         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12959         FREE((void*)_res);
12960         COption_EventZ_free(_res_conv);
12961 }
12962
12963 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12964         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12965         *ret_copy = COption_EventZ_clone(arg);
12966 uint64_t ret_ref = (uint64_t)ret_copy;
12967         return ret_ref;
12968 }
12969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12970         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12971         int64_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12972         return ret_val;
12973 }
12974
12975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12976         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12977         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12978         *ret_copy = COption_EventZ_clone(orig_conv);
12979         uint64_t ret_ref = (uint64_t)ret_copy;
12980         return ret_ref;
12981 }
12982
12983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12984         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12985         CHECK_ACCESS(o_ptr);
12986         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12987         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uint64_t)o) & ~1));
12988         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12989         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12990         return (uint64_t)ret_conv;
12991 }
12992
12993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12994         LDKDecodeError e_conv;
12995         e_conv.inner = (void*)(e & (~1));
12996         e_conv.is_owned = (e & 1) || (e == 0);
12997         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12998         e_conv = DecodeError_clone(&e_conv);
12999         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13000         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
13001         return (uint64_t)ret_conv;
13002 }
13003
13004 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13005         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
13006         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
13007         return ret_val;
13008 }
13009
13010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13011         if ((_res & 1) != 0) return;
13012         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13013         CHECK_ACCESS(_res_ptr);
13014         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
13015         FREE((void*)_res);
13016         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
13017 }
13018
13019 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
13020         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13021         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
13022         return (uint64_t)ret_conv;
13023 }
13024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13025         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
13026         int64_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
13027         return ret_val;
13028 }
13029
13030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13031         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
13032         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13033         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
13034         return (uint64_t)ret_conv;
13035 }
13036
13037 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13038         LDKCVec_MessageSendEventZ _res_constr;
13039         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13040         if (_res_constr.datalen > 0)
13041                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13042         else
13043                 _res_constr.data = NULL;
13044         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13045         for (size_t s = 0; s < _res_constr.datalen; s++) {
13046                 int64_t _res_conv_18 = _res_vals[s];
13047                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
13048                 CHECK_ACCESS(_res_conv_18_ptr);
13049                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
13050                 FREE((void*)_res_conv_18);
13051                 _res_constr.data[s] = _res_conv_18_conv;
13052         }
13053         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13054         CVec_MessageSendEventZ_free(_res_constr);
13055 }
13056
13057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13058         LDKInitFeatures o_conv;
13059         o_conv.inner = (void*)(o & (~1));
13060         o_conv.is_owned = (o & 1) || (o == 0);
13061         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13062         o_conv = InitFeatures_clone(&o_conv);
13063         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13064         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13065         return (uint64_t)ret_conv;
13066 }
13067
13068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13069         LDKDecodeError e_conv;
13070         e_conv.inner = (void*)(e & (~1));
13071         e_conv.is_owned = (e & 1) || (e == 0);
13072         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13073         e_conv = DecodeError_clone(&e_conv);
13074         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13075         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13076         return (uint64_t)ret_conv;
13077 }
13078
13079 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13080         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13081         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13082         return ret_val;
13083 }
13084
13085 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13086         if ((_res & 1) != 0) return;
13087         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13088         CHECK_ACCESS(_res_ptr);
13089         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13090         FREE((void*)_res);
13091         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13092 }
13093
13094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13095         LDKNodeFeatures o_conv;
13096         o_conv.inner = (void*)(o & (~1));
13097         o_conv.is_owned = (o & 1) || (o == 0);
13098         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13099         o_conv = NodeFeatures_clone(&o_conv);
13100         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13101         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
13102         return (uint64_t)ret_conv;
13103 }
13104
13105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13106         LDKDecodeError e_conv;
13107         e_conv.inner = (void*)(e & (~1));
13108         e_conv.is_owned = (e & 1) || (e == 0);
13109         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13110         e_conv = DecodeError_clone(&e_conv);
13111         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13112         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
13113         return (uint64_t)ret_conv;
13114 }
13115
13116 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13117         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
13118         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13119         return ret_val;
13120 }
13121
13122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13123         if ((_res & 1) != 0) return;
13124         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13125         CHECK_ACCESS(_res_ptr);
13126         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13127         FREE((void*)_res);
13128         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13129 }
13130
13131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13132         LDKChannelFeatures o_conv;
13133         o_conv.inner = (void*)(o & (~1));
13134         o_conv.is_owned = (o & 1) || (o == 0);
13135         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13136         o_conv = ChannelFeatures_clone(&o_conv);
13137         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13138         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13139         return (uint64_t)ret_conv;
13140 }
13141
13142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13143         LDKDecodeError e_conv;
13144         e_conv.inner = (void*)(e & (~1));
13145         e_conv.is_owned = (e & 1) || (e == 0);
13146         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13147         e_conv = DecodeError_clone(&e_conv);
13148         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13149         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13150         return (uint64_t)ret_conv;
13151 }
13152
13153 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13154         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13155         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13156         return ret_val;
13157 }
13158
13159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13160         if ((_res & 1) != 0) return;
13161         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13162         CHECK_ACCESS(_res_ptr);
13163         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13164         FREE((void*)_res);
13165         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13166 }
13167
13168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13169         LDKInvoiceFeatures o_conv;
13170         o_conv.inner = (void*)(o & (~1));
13171         o_conv.is_owned = (o & 1) || (o == 0);
13172         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13173         o_conv = InvoiceFeatures_clone(&o_conv);
13174         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13175         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13176         return (uint64_t)ret_conv;
13177 }
13178
13179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13180         LDKDecodeError e_conv;
13181         e_conv.inner = (void*)(e & (~1));
13182         e_conv.is_owned = (e & 1) || (e == 0);
13183         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13184         e_conv = DecodeError_clone(&e_conv);
13185         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13186         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13187         return (uint64_t)ret_conv;
13188 }
13189
13190 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13191         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
13192         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13193         return ret_val;
13194 }
13195
13196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13197         if ((_res & 1) != 0) return;
13198         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13199         CHECK_ACCESS(_res_ptr);
13200         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13201         FREE((void*)_res);
13202         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13203 }
13204
13205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13206         LDKScoringParameters o_conv;
13207         o_conv.inner = (void*)(o & (~1));
13208         o_conv.is_owned = (o & 1) || (o == 0);
13209         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13210         // Warning: we need a move here but no clone is available for LDKScoringParameters
13211         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
13212         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
13213         return (uint64_t)ret_conv;
13214 }
13215
13216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13217         LDKDecodeError e_conv;
13218         e_conv.inner = (void*)(e & (~1));
13219         e_conv.is_owned = (e & 1) || (e == 0);
13220         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13221         e_conv = DecodeError_clone(&e_conv);
13222         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
13223         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
13224         return (uint64_t)ret_conv;
13225 }
13226
13227 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13228         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
13229         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
13230         return ret_val;
13231 }
13232
13233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13234         if ((_res & 1) != 0) return;
13235         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13236         CHECK_ACCESS(_res_ptr);
13237         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
13238         FREE((void*)_res);
13239         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
13240 }
13241
13242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13243         LDKScorer o_conv;
13244         o_conv.inner = (void*)(o & (~1));
13245         o_conv.is_owned = (o & 1) || (o == 0);
13246         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13247         // Warning: we need a move here but no clone is available for LDKScorer
13248         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
13249         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
13250         return (uint64_t)ret_conv;
13251 }
13252
13253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13254         LDKDecodeError e_conv;
13255         e_conv.inner = (void*)(e & (~1));
13256         e_conv.is_owned = (e & 1) || (e == 0);
13257         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13258         e_conv = DecodeError_clone(&e_conv);
13259         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
13260         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
13261         return (uint64_t)ret_conv;
13262 }
13263
13264 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13265         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
13266         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
13267         return ret_val;
13268 }
13269
13270 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13271         if ((_res & 1) != 0) return;
13272         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13273         CHECK_ACCESS(_res_ptr);
13274         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
13275         FREE((void*)_res);
13276         CResult_ScorerDecodeErrorZ_free(_res_conv);
13277 }
13278
13279 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13280         LDKDelayedPaymentOutputDescriptor o_conv;
13281         o_conv.inner = (void*)(o & (~1));
13282         o_conv.is_owned = (o & 1) || (o == 0);
13283         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13284         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
13285         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13286         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13287         return (uint64_t)ret_conv;
13288 }
13289
13290 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13291         LDKDecodeError e_conv;
13292         e_conv.inner = (void*)(e & (~1));
13293         e_conv.is_owned = (e & 1) || (e == 0);
13294         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13295         e_conv = DecodeError_clone(&e_conv);
13296         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13297         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13298         return (uint64_t)ret_conv;
13299 }
13300
13301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13302         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13303         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13304         return ret_val;
13305 }
13306
13307 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13308         if ((_res & 1) != 0) return;
13309         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13310         CHECK_ACCESS(_res_ptr);
13311         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13312         FREE((void*)_res);
13313         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13314 }
13315
13316 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13317         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13318         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13319         return (uint64_t)ret_conv;
13320 }
13321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13322         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13323         int64_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13324         return ret_val;
13325 }
13326
13327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13328         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13329         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13330         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13331         return (uint64_t)ret_conv;
13332 }
13333
13334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13335         LDKStaticPaymentOutputDescriptor o_conv;
13336         o_conv.inner = (void*)(o & (~1));
13337         o_conv.is_owned = (o & 1) || (o == 0);
13338         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13339         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13340         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13341         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13342         return (uint64_t)ret_conv;
13343 }
13344
13345 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13346         LDKDecodeError e_conv;
13347         e_conv.inner = (void*)(e & (~1));
13348         e_conv.is_owned = (e & 1) || (e == 0);
13349         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13350         e_conv = DecodeError_clone(&e_conv);
13351         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13352         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13353         return (uint64_t)ret_conv;
13354 }
13355
13356 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13357         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13358         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13359         return ret_val;
13360 }
13361
13362 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13363         if ((_res & 1) != 0) return;
13364         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13365         CHECK_ACCESS(_res_ptr);
13366         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13367         FREE((void*)_res);
13368         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13369 }
13370
13371 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13372         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13373         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13374         return (uint64_t)ret_conv;
13375 }
13376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13377         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13378         int64_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13379         return ret_val;
13380 }
13381
13382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13383         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13384         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13385         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13386         return (uint64_t)ret_conv;
13387 }
13388
13389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13390         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13391         CHECK_ACCESS(o_ptr);
13392         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13393         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
13394         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13395         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13396         return (uint64_t)ret_conv;
13397 }
13398
13399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13400         LDKDecodeError e_conv;
13401         e_conv.inner = (void*)(e & (~1));
13402         e_conv.is_owned = (e & 1) || (e == 0);
13403         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13404         e_conv = DecodeError_clone(&e_conv);
13405         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13406         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13407         return (uint64_t)ret_conv;
13408 }
13409
13410 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13411         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
13412         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13413         return ret_val;
13414 }
13415
13416 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13417         if ((_res & 1) != 0) return;
13418         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13419         CHECK_ACCESS(_res_ptr);
13420         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
13421         FREE((void*)_res);
13422         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
13423 }
13424
13425 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13426         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13427         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
13428         return (uint64_t)ret_conv;
13429 }
13430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13431         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13432         int64_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13433         return ret_val;
13434 }
13435
13436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13437         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13438         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13439         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13440         return (uint64_t)ret_conv;
13441 }
13442
13443 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
13444         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13445         *ret_conv = CResult_NoneNoneZ_ok();
13446         return (uint64_t)ret_conv;
13447 }
13448
13449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
13450         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13451         *ret_conv = CResult_NoneNoneZ_err();
13452         return (uint64_t)ret_conv;
13453 }
13454
13455 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13456         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
13457         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
13458         return ret_val;
13459 }
13460
13461 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13462         if ((_res & 1) != 0) return;
13463         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13464         CHECK_ACCESS(_res_ptr);
13465         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
13466         FREE((void*)_res);
13467         CResult_NoneNoneZ_free(_res_conv);
13468 }
13469
13470 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
13471         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13472         *ret_conv = CResult_NoneNoneZ_clone(arg);
13473         return (uint64_t)ret_conv;
13474 }
13475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13476         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
13477         int64_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
13478         return ret_val;
13479 }
13480
13481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13482         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
13483         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13484         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
13485         return (uint64_t)ret_conv;
13486 }
13487
13488 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13489         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13490         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13491         return ((uint64_t)ret_conv);
13492 }
13493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13494         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13495         int64_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13496         return ret_val;
13497 }
13498
13499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13500         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13501         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13502         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13503         return ((uint64_t)ret_conv);
13504 }
13505
13506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
13507         LDKSignature a_ref;
13508         CHECK((*env)->GetArrayLength(env, a) == 64);
13509         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
13510         LDKCVec_SignatureZ b_constr;
13511         b_constr.datalen = (*env)->GetArrayLength(env, b);
13512         if (b_constr.datalen > 0)
13513                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13514         else
13515                 b_constr.data = NULL;
13516         for (size_t i = 0; i < b_constr.datalen; i++) {
13517                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
13518                 LDKSignature b_conv_8_ref;
13519                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
13520                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
13521                 b_constr.data[i] = b_conv_8_ref;
13522         }
13523         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13524         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13525         return ((uint64_t)ret_conv);
13526 }
13527
13528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13529         if ((_res & 1) != 0) return;
13530         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13531         CHECK_ACCESS(_res_ptr);
13532         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13533         FREE((void*)_res);
13534         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13535 }
13536
13537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13538         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13539         CHECK_ACCESS(o_ptr);
13540         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13541         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
13542         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13543         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13544         return (uint64_t)ret_conv;
13545 }
13546
13547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
13548         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13549         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13550         return (uint64_t)ret_conv;
13551 }
13552
13553 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13554         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13555         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13556         return ret_val;
13557 }
13558
13559 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13560         if ((_res & 1) != 0) return;
13561         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13562         CHECK_ACCESS(_res_ptr);
13563         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13564         FREE((void*)_res);
13565         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13566 }
13567
13568 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13569         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13570         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13571         return (uint64_t)ret_conv;
13572 }
13573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13574         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13575         int64_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13576         return ret_val;
13577 }
13578
13579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13580         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13581         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13582         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13583         return (uint64_t)ret_conv;
13584 }
13585
13586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13587         LDKSignature o_ref;
13588         CHECK((*env)->GetArrayLength(env, o) == 64);
13589         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
13590         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13591         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13592         return (uint64_t)ret_conv;
13593 }
13594
13595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
13596         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13597         *ret_conv = CResult_SignatureNoneZ_err();
13598         return (uint64_t)ret_conv;
13599 }
13600
13601 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13602         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13603         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
13604         return ret_val;
13605 }
13606
13607 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13608         if ((_res & 1) != 0) return;
13609         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13610         CHECK_ACCESS(_res_ptr);
13611         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13612         FREE((void*)_res);
13613         CResult_SignatureNoneZ_free(_res_conv);
13614 }
13615
13616 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13617         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13618         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13619         return (uint64_t)ret_conv;
13620 }
13621 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13622         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13623         int64_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13624         return ret_val;
13625 }
13626
13627 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13628         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13629         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13630         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13631         return (uint64_t)ret_conv;
13632 }
13633
13634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13635         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13636         CHECK_ACCESS(o_ptr);
13637         LDKSign o_conv = *(LDKSign*)(o_ptr);
13638         if (o_conv.free == LDKSign_JCalls_free) {
13639                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13640                 LDKSign_JCalls_cloned(&o_conv);
13641         }
13642         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13643         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13644         return (uint64_t)ret_conv;
13645 }
13646
13647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13648         LDKDecodeError e_conv;
13649         e_conv.inner = (void*)(e & (~1));
13650         e_conv.is_owned = (e & 1) || (e == 0);
13651         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13652         e_conv = DecodeError_clone(&e_conv);
13653         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13654         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13655         return (uint64_t)ret_conv;
13656 }
13657
13658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13659         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13660         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
13661         return ret_val;
13662 }
13663
13664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13665         if ((_res & 1) != 0) return;
13666         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13667         CHECK_ACCESS(_res_ptr);
13668         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13669         FREE((void*)_res);
13670         CResult_SignDecodeErrorZ_free(_res_conv);
13671 }
13672
13673 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13674         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13675         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13676         return (uint64_t)ret_conv;
13677 }
13678 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13679         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13680         int64_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13681         return ret_val;
13682 }
13683
13684 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13685         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13686         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13687         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13688         return (uint64_t)ret_conv;
13689 }
13690
13691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
13692         LDKCVec_u8Z _res_ref;
13693         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
13694         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13695         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
13696         CVec_u8Z_free(_res_ref);
13697 }
13698
13699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
13700         LDKRecoverableSignature arg_ref;
13701         CHECK((*env)->GetArrayLength(env, arg) == 68);
13702         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
13703         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13704         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
13705         return (uint64_t)ret_conv;
13706 }
13707
13708 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
13709         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13710         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13711         return (uint64_t)ret_conv;
13712 }
13713
13714 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13715         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13716         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13717         return ret_val;
13718 }
13719
13720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13721         if ((_res & 1) != 0) return;
13722         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13723         CHECK_ACCESS(_res_ptr);
13724         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13725         FREE((void*)_res);
13726         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13727 }
13728
13729 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13730         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13731         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13732         return (uint64_t)ret_conv;
13733 }
13734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13735         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13736         int64_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13737         return ret_val;
13738 }
13739
13740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13741         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13742         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13743         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13744         return (uint64_t)ret_conv;
13745 }
13746
13747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13748         LDKCVec_CVec_u8ZZ _res_constr;
13749         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13750         if (_res_constr.datalen > 0)
13751                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13752         else
13753                 _res_constr.data = NULL;
13754         for (size_t i = 0; i < _res_constr.datalen; i++) {
13755                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13756                 LDKCVec_u8Z _res_conv_8_ref;
13757                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
13758                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
13759                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
13760                 _res_constr.data[i] = _res_conv_8_ref;
13761         }
13762         CVec_CVec_u8ZZ_free(_res_constr);
13763 }
13764
13765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
13766         LDKCVec_CVec_u8ZZ o_constr;
13767         o_constr.datalen = (*env)->GetArrayLength(env, o);
13768         if (o_constr.datalen > 0)
13769                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13770         else
13771                 o_constr.data = NULL;
13772         for (size_t i = 0; i < o_constr.datalen; i++) {
13773                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
13774                 LDKCVec_u8Z o_conv_8_ref;
13775                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
13776                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
13777                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
13778                 o_constr.data[i] = o_conv_8_ref;
13779         }
13780         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13781         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13782         return (uint64_t)ret_conv;
13783 }
13784
13785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
13786         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13787         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13788         return (uint64_t)ret_conv;
13789 }
13790
13791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13792         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13793         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13794         return ret_val;
13795 }
13796
13797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13798         if ((_res & 1) != 0) return;
13799         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13800         CHECK_ACCESS(_res_ptr);
13801         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13802         FREE((void*)_res);
13803         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13804 }
13805
13806 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13807         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13808         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13809         return (uint64_t)ret_conv;
13810 }
13811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13812         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13813         int64_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13814         return ret_val;
13815 }
13816
13817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13818         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13819         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13820         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13821         return (uint64_t)ret_conv;
13822 }
13823
13824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13825         LDKInMemorySigner o_conv;
13826         o_conv.inner = (void*)(o & (~1));
13827         o_conv.is_owned = (o & 1) || (o == 0);
13828         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13829         o_conv = InMemorySigner_clone(&o_conv);
13830         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13831         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13832         return (uint64_t)ret_conv;
13833 }
13834
13835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13836         LDKDecodeError e_conv;
13837         e_conv.inner = (void*)(e & (~1));
13838         e_conv.is_owned = (e & 1) || (e == 0);
13839         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13840         e_conv = DecodeError_clone(&e_conv);
13841         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13842         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13843         return (uint64_t)ret_conv;
13844 }
13845
13846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13847         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13848         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13849         return ret_val;
13850 }
13851
13852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13853         if ((_res & 1) != 0) return;
13854         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13855         CHECK_ACCESS(_res_ptr);
13856         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13857         FREE((void*)_res);
13858         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13859 }
13860
13861 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13862         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13863         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13864         return (uint64_t)ret_conv;
13865 }
13866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13867         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13868         int64_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13869         return ret_val;
13870 }
13871
13872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13873         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13874         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13875         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13876         return (uint64_t)ret_conv;
13877 }
13878
13879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13880         LDKCVec_TxOutZ _res_constr;
13881         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13882         if (_res_constr.datalen > 0)
13883                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13884         else
13885                 _res_constr.data = NULL;
13886         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13887         for (size_t h = 0; h < _res_constr.datalen; h++) {
13888                 int64_t _res_conv_7 = _res_vals[h];
13889                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
13890                 CHECK_ACCESS(_res_conv_7_ptr);
13891                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13892                 FREE((void*)_res_conv_7);
13893                 _res_constr.data[h] = _res_conv_7_conv;
13894         }
13895         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13896         CVec_TxOutZ_free(_res_constr);
13897 }
13898
13899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13900         LDKTransaction o_ref;
13901         o_ref.datalen = (*env)->GetArrayLength(env, o);
13902         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13903         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
13904         o_ref.data_is_owned = true;
13905         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13906         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13907         return (uint64_t)ret_conv;
13908 }
13909
13910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
13911         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13912         *ret_conv = CResult_TransactionNoneZ_err();
13913         return (uint64_t)ret_conv;
13914 }
13915
13916 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13917         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13918         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
13919         return ret_val;
13920 }
13921
13922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13923         if ((_res & 1) != 0) return;
13924         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13925         CHECK_ACCESS(_res_ptr);
13926         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13927         FREE((void*)_res);
13928         CResult_TransactionNoneZ_free(_res_conv);
13929 }
13930
13931 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13932         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13933         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13934         return (uint64_t)ret_conv;
13935 }
13936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13937         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13938         int64_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13939         return ret_val;
13940 }
13941
13942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13943         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13944         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13945         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13946         return (uint64_t)ret_conv;
13947 }
13948
13949 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
13950         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
13951         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
13952         return ((uint64_t)ret_conv);
13953 }
13954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13955         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
13956         int64_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
13957         return ret_val;
13958 }
13959
13960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13961         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
13962         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
13963         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
13964         return ((uint64_t)ret_conv);
13965 }
13966
13967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
13968         LDKThirtyTwoBytes a_ref;
13969         CHECK((*env)->GetArrayLength(env, a) == 32);
13970         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13971         LDKChannelMonitor b_conv;
13972         b_conv.inner = (void*)(b & (~1));
13973         b_conv.is_owned = (b & 1) || (b == 0);
13974         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
13975         b_conv = ChannelMonitor_clone(&b_conv);
13976         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
13977         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
13978         return ((uint64_t)ret_conv);
13979 }
13980
13981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13982         if ((_res & 1) != 0) return;
13983         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13984         CHECK_ACCESS(_res_ptr);
13985         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
13986         FREE((void*)_res);
13987         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
13988 }
13989
13990 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13991         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
13992         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13993         if (_res_constr.datalen > 0)
13994                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
13995         else
13996                 _res_constr.data = NULL;
13997         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13998         for (size_t j = 0; j < _res_constr.datalen; j++) {
13999                 int64_t _res_conv_35 = _res_vals[j];
14000                 void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
14001                 CHECK_ACCESS(_res_conv_35_ptr);
14002                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
14003                 FREE((void*)_res_conv_35);
14004                 _res_constr.data[j] = _res_conv_35_conv;
14005         }
14006         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14007         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
14008 }
14009
14010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
14011         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
14012         o_constr.datalen = (*env)->GetArrayLength(env, o);
14013         if (o_constr.datalen > 0)
14014                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
14015         else
14016                 o_constr.data = NULL;
14017         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
14018         for (size_t j = 0; j < o_constr.datalen; j++) {
14019                 int64_t o_conv_35 = o_vals[j];
14020                 void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
14021                 CHECK_ACCESS(o_conv_35_ptr);
14022                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
14023                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
14024                 o_constr.data[j] = o_conv_35_conv;
14025         }
14026         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
14027         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14028         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
14029         return (uint64_t)ret_conv;
14030 }
14031
14032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14033         LDKIOError e_conv = LDKIOError_from_java(env, e);
14034         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14035         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
14036         return (uint64_t)ret_conv;
14037 }
14038
14039 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14040         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
14041         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
14042         return ret_val;
14043 }
14044
14045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14046         if ((_res & 1) != 0) return;
14047         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14048         CHECK_ACCESS(_res_ptr);
14049         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
14050         FREE((void*)_res);
14051         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
14052 }
14053
14054 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
14055         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14056         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
14057         return (uint64_t)ret_conv;
14058 }
14059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14060         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
14061         int64_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
14062         return ret_val;
14063 }
14064
14065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14066         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
14067         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14068         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
14069         return (uint64_t)ret_conv;
14070 }
14071
14072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
14073         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14074         *ret_copy = COption_u16Z_some(o);
14075         uint64_t ret_ref = (uint64_t)ret_copy;
14076         return ret_ref;
14077 }
14078
14079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
14080         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14081         *ret_copy = COption_u16Z_none();
14082         uint64_t ret_ref = (uint64_t)ret_copy;
14083         return ret_ref;
14084 }
14085
14086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14087         if ((_res & 1) != 0) return;
14088         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14089         CHECK_ACCESS(_res_ptr);
14090         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
14091         FREE((void*)_res);
14092         COption_u16Z_free(_res_conv);
14093 }
14094
14095 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
14096         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14097         *ret_copy = COption_u16Z_clone(arg);
14098 uint64_t ret_ref = (uint64_t)ret_copy;
14099         return ret_ref;
14100 }
14101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14102         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
14103         int64_t ret_val = COption_u16Z_clone_ptr(arg_conv);
14104         return ret_val;
14105 }
14106
14107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14108         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
14109         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14110         *ret_copy = COption_u16Z_clone(orig_conv);
14111         uint64_t ret_ref = (uint64_t)ret_copy;
14112         return ret_ref;
14113 }
14114
14115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
14116         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14117         *ret_conv = CResult_NoneAPIErrorZ_ok();
14118         return (uint64_t)ret_conv;
14119 }
14120
14121 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14122         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14123         CHECK_ACCESS(e_ptr);
14124         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14125         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
14126         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14127         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
14128         return (uint64_t)ret_conv;
14129 }
14130
14131 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14132         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
14133         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
14134         return ret_val;
14135 }
14136
14137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14138         if ((_res & 1) != 0) return;
14139         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14140         CHECK_ACCESS(_res_ptr);
14141         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
14142         FREE((void*)_res);
14143         CResult_NoneAPIErrorZ_free(_res_conv);
14144 }
14145
14146 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
14147         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14148         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
14149         return (uint64_t)ret_conv;
14150 }
14151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14152         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
14153         int64_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
14154         return ret_val;
14155 }
14156
14157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14158         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
14159         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14160         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
14161         return (uint64_t)ret_conv;
14162 }
14163
14164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14165         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
14166         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14167         if (_res_constr.datalen > 0)
14168                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
14169         else
14170                 _res_constr.data = NULL;
14171         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14172         for (size_t w = 0; w < _res_constr.datalen; w++) {
14173                 int64_t _res_conv_22 = _res_vals[w];
14174                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
14175                 CHECK_ACCESS(_res_conv_22_ptr);
14176                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
14177                 FREE((void*)_res_conv_22);
14178                 _res_constr.data[w] = _res_conv_22_conv;
14179         }
14180         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14181         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
14182 }
14183
14184 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14185         LDKCVec_APIErrorZ _res_constr;
14186         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14187         if (_res_constr.datalen > 0)
14188                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
14189         else
14190                 _res_constr.data = NULL;
14191         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14192         for (size_t k = 0; k < _res_constr.datalen; k++) {
14193                 int64_t _res_conv_10 = _res_vals[k];
14194                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
14195                 CHECK_ACCESS(_res_conv_10_ptr);
14196                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
14197                 FREE((void*)_res_conv_10);
14198                 _res_constr.data[k] = _res_conv_10_conv;
14199         }
14200         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14201         CVec_APIErrorZ_free(_res_constr);
14202 }
14203
14204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14205         LDKThirtyTwoBytes o_ref;
14206         CHECK((*env)->GetArrayLength(env, o) == 32);
14207         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14208         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14209         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
14210         return (uint64_t)ret_conv;
14211 }
14212
14213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14214         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14215         CHECK_ACCESS(e_ptr);
14216         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14217         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
14218         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14219         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
14220         return (uint64_t)ret_conv;
14221 }
14222
14223 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14224         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
14225         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
14226         return ret_val;
14227 }
14228
14229 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14230         if ((_res & 1) != 0) return;
14231         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14232         CHECK_ACCESS(_res_ptr);
14233         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
14234         FREE((void*)_res);
14235         CResult__u832APIErrorZ_free(_res_conv);
14236 }
14237
14238 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
14239         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14240         *ret_conv = CResult__u832APIErrorZ_clone(arg);
14241         return (uint64_t)ret_conv;
14242 }
14243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14244         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
14245         int64_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
14246         return ret_val;
14247 }
14248
14249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14250         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
14251         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14252         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
14253         return (uint64_t)ret_conv;
14254 }
14255
14256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14257         LDKThirtyTwoBytes o_ref;
14258         CHECK((*env)->GetArrayLength(env, o) == 32);
14259         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14260         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14261         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
14262         return (uint64_t)ret_conv;
14263 }
14264
14265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14266         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14267         CHECK_ACCESS(e_ptr);
14268         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14269         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14270         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14271         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
14272         return (uint64_t)ret_conv;
14273 }
14274
14275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14276         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
14277         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
14278         return ret_val;
14279 }
14280
14281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14282         if ((_res & 1) != 0) return;
14283         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14284         CHECK_ACCESS(_res_ptr);
14285         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
14286         FREE((void*)_res);
14287         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
14288 }
14289
14290 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
14291         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14292         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
14293         return (uint64_t)ret_conv;
14294 }
14295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14296         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
14297         int64_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
14298         return ret_val;
14299 }
14300
14301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14302         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
14303         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14304         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
14305         return (uint64_t)ret_conv;
14306 }
14307
14308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
14309         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14310         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
14311         return (uint64_t)ret_conv;
14312 }
14313
14314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14315         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14316         CHECK_ACCESS(e_ptr);
14317         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14318         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14319         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14320         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
14321         return (uint64_t)ret_conv;
14322 }
14323
14324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14325         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
14326         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
14327         return ret_val;
14328 }
14329
14330 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14331         if ((_res & 1) != 0) return;
14332         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14333         CHECK_ACCESS(_res_ptr);
14334         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
14335         FREE((void*)_res);
14336         CResult_NonePaymentSendFailureZ_free(_res_conv);
14337 }
14338
14339 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
14340         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14341         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
14342         return (uint64_t)ret_conv;
14343 }
14344 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14345         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
14346         int64_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
14347         return ret_val;
14348 }
14349
14350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14351         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
14352         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14353         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
14354         return (uint64_t)ret_conv;
14355 }
14356
14357 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
14358         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14359         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
14360         return ((uint64_t)ret_conv);
14361 }
14362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14363         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
14364         int64_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
14365         return ret_val;
14366 }
14367
14368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14369         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
14370         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14371         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
14372         return ((uint64_t)ret_conv);
14373 }
14374
14375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
14376         LDKThirtyTwoBytes a_ref;
14377         CHECK((*env)->GetArrayLength(env, a) == 32);
14378         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14379         LDKThirtyTwoBytes b_ref;
14380         CHECK((*env)->GetArrayLength(env, b) == 32);
14381         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
14382         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14383         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
14384         return ((uint64_t)ret_conv);
14385 }
14386
14387 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14388         if ((_res & 1) != 0) return;
14389         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14390         CHECK_ACCESS(_res_ptr);
14391         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
14392         FREE((void*)_res);
14393         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
14394 }
14395
14396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14397         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14398         CHECK_ACCESS(o_ptr);
14399         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
14400         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
14401         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14402         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
14403         return (uint64_t)ret_conv;
14404 }
14405
14406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14407         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14408         CHECK_ACCESS(e_ptr);
14409         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14410         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14411         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14412         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
14413         return (uint64_t)ret_conv;
14414 }
14415
14416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14417         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
14418         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
14419         return ret_val;
14420 }
14421
14422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14423         if ((_res & 1) != 0) return;
14424         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14425         CHECK_ACCESS(_res_ptr);
14426         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
14427         FREE((void*)_res);
14428         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
14429 }
14430
14431 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14432         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14433         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14434         return (uint64_t)ret_conv;
14435 }
14436 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14437         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14438         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14439         return ret_val;
14440 }
14441
14442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14443         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14444         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14445         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14446         return (uint64_t)ret_conv;
14447 }
14448
14449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14450         LDKCVec_NetAddressZ _res_constr;
14451         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14452         if (_res_constr.datalen > 0)
14453                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14454         else
14455                 _res_constr.data = NULL;
14456         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14457         for (size_t m = 0; m < _res_constr.datalen; m++) {
14458                 int64_t _res_conv_12 = _res_vals[m];
14459                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
14460                 CHECK_ACCESS(_res_conv_12_ptr);
14461                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14462                 FREE((void*)_res_conv_12);
14463                 _res_constr.data[m] = _res_conv_12_conv;
14464         }
14465         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14466         CVec_NetAddressZ_free(_res_constr);
14467 }
14468
14469 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14470         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14471         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14472         return ((uint64_t)ret_conv);
14473 }
14474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14475         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14476         int64_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14477         return ret_val;
14478 }
14479
14480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14481         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14482         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14483         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14484         return ((uint64_t)ret_conv);
14485 }
14486
14487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
14488         LDKThirtyTwoBytes a_ref;
14489         CHECK((*env)->GetArrayLength(env, a) == 32);
14490         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14491         LDKThirtyTwoBytes b_ref;
14492         CHECK((*env)->GetArrayLength(env, b) == 32);
14493         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
14494         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14495         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14496         return ((uint64_t)ret_conv);
14497 }
14498
14499 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14500         if ((_res & 1) != 0) return;
14501         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14502         CHECK_ACCESS(_res_ptr);
14503         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14504         FREE((void*)_res);
14505         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14506 }
14507
14508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14509         LDKThirtyTwoBytes o_ref;
14510         CHECK((*env)->GetArrayLength(env, o) == 32);
14511         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14512         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14513         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14514         return (uint64_t)ret_conv;
14515 }
14516
14517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14518         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14519         CHECK_ACCESS(e_ptr);
14520         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14521         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
14522         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14523         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14524         return (uint64_t)ret_conv;
14525 }
14526
14527 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14528         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14529         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14530         return ret_val;
14531 }
14532
14533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14534         if ((_res & 1) != 0) return;
14535         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14536         CHECK_ACCESS(_res_ptr);
14537         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14538         FREE((void*)_res);
14539         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14540 }
14541
14542 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14543         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14544         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14545         return (uint64_t)ret_conv;
14546 }
14547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14548         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14549         int64_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14550         return ret_val;
14551 }
14552
14553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14554         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14555         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14556         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14557         return (uint64_t)ret_conv;
14558 }
14559
14560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14561         LDKCVec_ChannelMonitorZ _res_constr;
14562         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14563         if (_res_constr.datalen > 0)
14564                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14565         else
14566                 _res_constr.data = NULL;
14567         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14568         for (size_t q = 0; q < _res_constr.datalen; q++) {
14569                 int64_t _res_conv_16 = _res_vals[q];
14570                 LDKChannelMonitor _res_conv_16_conv;
14571                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14572                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14573                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14574                 _res_constr.data[q] = _res_conv_16_conv;
14575         }
14576         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14577         CVec_ChannelMonitorZ_free(_res_constr);
14578 }
14579
14580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
14581         LDKThirtyTwoBytes a_ref;
14582         CHECK((*env)->GetArrayLength(env, a) == 32);
14583         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14584         LDKChannelManager b_conv;
14585         b_conv.inner = (void*)(b & (~1));
14586         b_conv.is_owned = (b & 1) || (b == 0);
14587         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14588         // Warning: we need a move here but no clone is available for LDKChannelManager
14589         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14590         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14591         return ((uint64_t)ret_conv);
14592 }
14593
14594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14595         if ((_res & 1) != 0) return;
14596         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14597         CHECK_ACCESS(_res_ptr);
14598         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14599         FREE((void*)_res);
14600         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14601 }
14602
14603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14604         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14605         CHECK_ACCESS(o_ptr);
14606         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14607         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14608         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14609         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14610         return (uint64_t)ret_conv;
14611 }
14612
14613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14614         LDKDecodeError e_conv;
14615         e_conv.inner = (void*)(e & (~1));
14616         e_conv.is_owned = (e & 1) || (e == 0);
14617         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14618         e_conv = DecodeError_clone(&e_conv);
14619         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14620         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14621         return (uint64_t)ret_conv;
14622 }
14623
14624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14625         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14626         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14627         return ret_val;
14628 }
14629
14630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14631         if ((_res & 1) != 0) return;
14632         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14633         CHECK_ACCESS(_res_ptr);
14634         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14635         FREE((void*)_res);
14636         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14637 }
14638
14639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14640         LDKChannelConfig o_conv;
14641         o_conv.inner = (void*)(o & (~1));
14642         o_conv.is_owned = (o & 1) || (o == 0);
14643         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14644         o_conv = ChannelConfig_clone(&o_conv);
14645         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14646         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14647         return (uint64_t)ret_conv;
14648 }
14649
14650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14651         LDKDecodeError e_conv;
14652         e_conv.inner = (void*)(e & (~1));
14653         e_conv.is_owned = (e & 1) || (e == 0);
14654         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14655         e_conv = DecodeError_clone(&e_conv);
14656         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14657         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14658         return (uint64_t)ret_conv;
14659 }
14660
14661 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14662         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14663         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14664         return ret_val;
14665 }
14666
14667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14668         if ((_res & 1) != 0) return;
14669         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14670         CHECK_ACCESS(_res_ptr);
14671         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14672         FREE((void*)_res);
14673         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14674 }
14675
14676 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14677         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14678         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14679         return (uint64_t)ret_conv;
14680 }
14681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14682         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14683         int64_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14684         return ret_val;
14685 }
14686
14687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14688         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14689         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14690         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14691         return (uint64_t)ret_conv;
14692 }
14693
14694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14695         LDKOutPoint o_conv;
14696         o_conv.inner = (void*)(o & (~1));
14697         o_conv.is_owned = (o & 1) || (o == 0);
14698         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14699         o_conv = OutPoint_clone(&o_conv);
14700         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14701         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14702         return (uint64_t)ret_conv;
14703 }
14704
14705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14706         LDKDecodeError e_conv;
14707         e_conv.inner = (void*)(e & (~1));
14708         e_conv.is_owned = (e & 1) || (e == 0);
14709         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14710         e_conv = DecodeError_clone(&e_conv);
14711         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14712         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14713         return (uint64_t)ret_conv;
14714 }
14715
14716 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14717         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14718         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14719         return ret_val;
14720 }
14721
14722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14723         if ((_res & 1) != 0) return;
14724         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14725         CHECK_ACCESS(_res_ptr);
14726         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14727         FREE((void*)_res);
14728         CResult_OutPointDecodeErrorZ_free(_res_conv);
14729 }
14730
14731 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14732         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14733         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14734         return (uint64_t)ret_conv;
14735 }
14736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14737         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14738         int64_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14739         return ret_val;
14740 }
14741
14742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14743         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14744         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14745         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14746         return (uint64_t)ret_conv;
14747 }
14748
14749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
14750         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14751         CHECK_ACCESS(o_ptr);
14752         LDKType o_conv = *(LDKType*)(o_ptr);
14753         if (o_conv.free == LDKType_JCalls_free) {
14754                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14755                 LDKType_JCalls_cloned(&o_conv);
14756         }
14757         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14758         *ret_copy = COption_TypeZ_some(o_conv);
14759         uint64_t ret_ref = (uint64_t)ret_copy;
14760         return ret_ref;
14761 }
14762
14763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
14764         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14765         *ret_copy = COption_TypeZ_none();
14766         uint64_t ret_ref = (uint64_t)ret_copy;
14767         return ret_ref;
14768 }
14769
14770 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14771         if ((_res & 1) != 0) return;
14772         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14773         CHECK_ACCESS(_res_ptr);
14774         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
14775         FREE((void*)_res);
14776         COption_TypeZ_free(_res_conv);
14777 }
14778
14779 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
14780         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14781         *ret_copy = COption_TypeZ_clone(arg);
14782 uint64_t ret_ref = (uint64_t)ret_copy;
14783         return ret_ref;
14784 }
14785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14786         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
14787         int64_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
14788         return ret_val;
14789 }
14790
14791 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14792         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
14793         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14794         *ret_copy = COption_TypeZ_clone(orig_conv);
14795         uint64_t ret_ref = (uint64_t)ret_copy;
14796         return ret_ref;
14797 }
14798
14799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14800         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14801         CHECK_ACCESS(o_ptr);
14802         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
14803         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
14804         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14805         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
14806         return (uint64_t)ret_conv;
14807 }
14808
14809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14810         LDKDecodeError e_conv;
14811         e_conv.inner = (void*)(e & (~1));
14812         e_conv.is_owned = (e & 1) || (e == 0);
14813         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14814         e_conv = DecodeError_clone(&e_conv);
14815         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14816         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
14817         return (uint64_t)ret_conv;
14818 }
14819
14820 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14821         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
14822         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
14823         return ret_val;
14824 }
14825
14826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14827         if ((_res & 1) != 0) return;
14828         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14829         CHECK_ACCESS(_res_ptr);
14830         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
14831         FREE((void*)_res);
14832         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
14833 }
14834
14835 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
14836         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14837         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
14838         return (uint64_t)ret_conv;
14839 }
14840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14841         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
14842         int64_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
14843         return ret_val;
14844 }
14845
14846 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14847         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
14848         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14849         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
14850         return (uint64_t)ret_conv;
14851 }
14852
14853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14854         LDKThirtyTwoBytes o_ref;
14855         CHECK((*env)->GetArrayLength(env, o) == 32);
14856         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14857         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14858         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
14859         return (uint64_t)ret_conv;
14860 }
14861
14862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14863         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14864         CHECK_ACCESS(e_ptr);
14865         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
14866         e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
14867         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14868         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
14869         return (uint64_t)ret_conv;
14870 }
14871
14872 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14873         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
14874         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
14875         return ret_val;
14876 }
14877
14878 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14879         if ((_res & 1) != 0) return;
14880         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14881         CHECK_ACCESS(_res_ptr);
14882         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
14883         FREE((void*)_res);
14884         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
14885 }
14886
14887 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
14888         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14889         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
14890         return (uint64_t)ret_conv;
14891 }
14892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14893         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
14894         int64_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
14895         return ret_val;
14896 }
14897
14898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14899         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
14900         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14901         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
14902         return (uint64_t)ret_conv;
14903 }
14904
14905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
14906         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
14907         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14908         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
14909         return (uint64_t)ret_conv;
14910 }
14911
14912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
14913         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14914         *ret_conv = CResult_SiPrefixNoneZ_err();
14915         return (uint64_t)ret_conv;
14916 }
14917
14918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14919         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
14920         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
14921         return ret_val;
14922 }
14923
14924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14925         if ((_res & 1) != 0) return;
14926         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14927         CHECK_ACCESS(_res_ptr);
14928         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
14929         FREE((void*)_res);
14930         CResult_SiPrefixNoneZ_free(_res_conv);
14931 }
14932
14933 static inline uint64_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
14934         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14935         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
14936         return (uint64_t)ret_conv;
14937 }
14938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14939         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
14940         int64_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
14941         return ret_val;
14942 }
14943
14944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14945         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
14946         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14947         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
14948         return (uint64_t)ret_conv;
14949 }
14950
14951 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14952         LDKInvoice o_conv;
14953         o_conv.inner = (void*)(o & (~1));
14954         o_conv.is_owned = (o & 1) || (o == 0);
14955         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14956         o_conv = Invoice_clone(&o_conv);
14957         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14958         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
14959         return (uint64_t)ret_conv;
14960 }
14961
14962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
14963         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14964         *ret_conv = CResult_InvoiceNoneZ_err();
14965         return (uint64_t)ret_conv;
14966 }
14967
14968 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14969         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
14970         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
14971         return ret_val;
14972 }
14973
14974 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14975         if ((_res & 1) != 0) return;
14976         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14977         CHECK_ACCESS(_res_ptr);
14978         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
14979         FREE((void*)_res);
14980         CResult_InvoiceNoneZ_free(_res_conv);
14981 }
14982
14983 static inline uint64_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
14984         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14985         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
14986         return (uint64_t)ret_conv;
14987 }
14988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14989         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
14990         int64_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
14991         return ret_val;
14992 }
14993
14994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14995         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
14996         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14997         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
14998         return (uint64_t)ret_conv;
14999 }
15000
15001 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15002         LDKSignedRawInvoice o_conv;
15003         o_conv.inner = (void*)(o & (~1));
15004         o_conv.is_owned = (o & 1) || (o == 0);
15005         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15006         o_conv = SignedRawInvoice_clone(&o_conv);
15007         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15008         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
15009         return (uint64_t)ret_conv;
15010 }
15011
15012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
15013         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15014         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
15015         return (uint64_t)ret_conv;
15016 }
15017
15018 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15019         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
15020         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
15021         return ret_val;
15022 }
15023
15024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15025         if ((_res & 1) != 0) return;
15026         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15027         CHECK_ACCESS(_res_ptr);
15028         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
15029         FREE((void*)_res);
15030         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
15031 }
15032
15033 static inline uint64_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
15034         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15035         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
15036         return (uint64_t)ret_conv;
15037 }
15038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15039         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
15040         int64_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
15041         return ret_val;
15042 }
15043
15044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15045         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
15046         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15047         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
15048         return (uint64_t)ret_conv;
15049 }
15050
15051 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15052         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15053         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15054         return ((uint64_t)ret_conv);
15055 }
15056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15057         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15058         int64_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15059         return ret_val;
15060 }
15061
15062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15063         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15064         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15065         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15066         return ((uint64_t)ret_conv);
15067 }
15068
15069 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) {
15070         LDKRawInvoice a_conv;
15071         a_conv.inner = (void*)(a & (~1));
15072         a_conv.is_owned = (a & 1) || (a == 0);
15073         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15074         a_conv = RawInvoice_clone(&a_conv);
15075         LDKThirtyTwoBytes b_ref;
15076         CHECK((*env)->GetArrayLength(env, b) == 32);
15077         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
15078         LDKInvoiceSignature c_conv;
15079         c_conv.inner = (void*)(c & (~1));
15080         c_conv.is_owned = (c & 1) || (c == 0);
15081         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15082         c_conv = InvoiceSignature_clone(&c_conv);
15083         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15084         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15085         return ((uint64_t)ret_conv);
15086 }
15087
15088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15089         if ((_res & 1) != 0) return;
15090         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15091         CHECK_ACCESS(_res_ptr);
15092         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15093         FREE((void*)_res);
15094         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15095 }
15096
15097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15098         LDKPayeePubKey o_conv;
15099         o_conv.inner = (void*)(o & (~1));
15100         o_conv.is_owned = (o & 1) || (o == 0);
15101         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15102         o_conv = PayeePubKey_clone(&o_conv);
15103         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15104         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15105         return (uint64_t)ret_conv;
15106 }
15107
15108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15109         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15110         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15111         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15112         return (uint64_t)ret_conv;
15113 }
15114
15115 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15116         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15117         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15118         return ret_val;
15119 }
15120
15121 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15122         if ((_res & 1) != 0) return;
15123         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15124         CHECK_ACCESS(_res_ptr);
15125         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15126         FREE((void*)_res);
15127         CResult_PayeePubKeyErrorZ_free(_res_conv);
15128 }
15129
15130 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15131         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15132         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15133         return (uint64_t)ret_conv;
15134 }
15135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15136         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15137         int64_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15138         return ret_val;
15139 }
15140
15141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15142         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15143         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15144         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15145         return (uint64_t)ret_conv;
15146 }
15147
15148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15149         LDKCVec_PrivateRouteZ _res_constr;
15150         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15151         if (_res_constr.datalen > 0)
15152                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15153         else
15154                 _res_constr.data = NULL;
15155         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15156         for (size_t o = 0; o < _res_constr.datalen; o++) {
15157                 int64_t _res_conv_14 = _res_vals[o];
15158                 LDKPrivateRoute _res_conv_14_conv;
15159                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15160                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15161                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15162                 _res_constr.data[o] = _res_conv_14_conv;
15163         }
15164         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15165         CVec_PrivateRouteZ_free(_res_constr);
15166 }
15167
15168 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15169         LDKPositiveTimestamp o_conv;
15170         o_conv.inner = (void*)(o & (~1));
15171         o_conv.is_owned = (o & 1) || (o == 0);
15172         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15173         o_conv = PositiveTimestamp_clone(&o_conv);
15174         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15175         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15176         return (uint64_t)ret_conv;
15177 }
15178
15179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15180         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15181         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15182         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15183         return (uint64_t)ret_conv;
15184 }
15185
15186 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15187         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15188         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15189         return ret_val;
15190 }
15191
15192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15193         if ((_res & 1) != 0) return;
15194         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15195         CHECK_ACCESS(_res_ptr);
15196         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15197         FREE((void*)_res);
15198         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15199 }
15200
15201 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15202         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15203         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15204         return (uint64_t)ret_conv;
15205 }
15206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15207         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15208         int64_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15209         return ret_val;
15210 }
15211
15212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15213         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15214         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15215         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15216         return (uint64_t)ret_conv;
15217 }
15218
15219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
15220         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15221         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15222         return (uint64_t)ret_conv;
15223 }
15224
15225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15226         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
15227         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15228         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15229         return (uint64_t)ret_conv;
15230 }
15231
15232 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15233         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15234         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15235         return ret_val;
15236 }
15237
15238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15239         if ((_res & 1) != 0) return;
15240         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15241         CHECK_ACCESS(_res_ptr);
15242         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15243         FREE((void*)_res);
15244         CResult_NoneSemanticErrorZ_free(_res_conv);
15245 }
15246
15247 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15248         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15249         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15250         return (uint64_t)ret_conv;
15251 }
15252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15253         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15254         int64_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15255         return ret_val;
15256 }
15257
15258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15259         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15260         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15261         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15262         return (uint64_t)ret_conv;
15263 }
15264
15265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15266         LDKInvoice o_conv;
15267         o_conv.inner = (void*)(o & (~1));
15268         o_conv.is_owned = (o & 1) || (o == 0);
15269         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15270         o_conv = Invoice_clone(&o_conv);
15271         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15272         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15273         return (uint64_t)ret_conv;
15274 }
15275
15276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15277         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
15278         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15279         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15280         return (uint64_t)ret_conv;
15281 }
15282
15283 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15284         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15285         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15286         return ret_val;
15287 }
15288
15289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15290         if ((_res & 1) != 0) return;
15291         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15292         CHECK_ACCESS(_res_ptr);
15293         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15294         FREE((void*)_res);
15295         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15296 }
15297
15298 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15299         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15300         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15301         return (uint64_t)ret_conv;
15302 }
15303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15304         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15305         int64_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15306         return ret_val;
15307 }
15308
15309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15310         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15311         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15312         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15313         return (uint64_t)ret_conv;
15314 }
15315
15316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15317         LDKDescription o_conv;
15318         o_conv.inner = (void*)(o & (~1));
15319         o_conv.is_owned = (o & 1) || (o == 0);
15320         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15321         o_conv = Description_clone(&o_conv);
15322         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15323         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15324         return (uint64_t)ret_conv;
15325 }
15326
15327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15328         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15329         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15330         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15331         return (uint64_t)ret_conv;
15332 }
15333
15334 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15335         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15336         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15337         return ret_val;
15338 }
15339
15340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15341         if ((_res & 1) != 0) return;
15342         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15343         CHECK_ACCESS(_res_ptr);
15344         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15345         FREE((void*)_res);
15346         CResult_DescriptionCreationErrorZ_free(_res_conv);
15347 }
15348
15349 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15350         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15351         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15352         return (uint64_t)ret_conv;
15353 }
15354 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15355         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15356         int64_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15357         return ret_val;
15358 }
15359
15360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15361         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15362         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15363         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15364         return (uint64_t)ret_conv;
15365 }
15366
15367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15368         LDKExpiryTime o_conv;
15369         o_conv.inner = (void*)(o & (~1));
15370         o_conv.is_owned = (o & 1) || (o == 0);
15371         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15372         o_conv = ExpiryTime_clone(&o_conv);
15373         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
15374         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
15375         return (uint64_t)ret_conv;
15376 }
15377
15378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15379         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15380         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
15381         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
15382         return (uint64_t)ret_conv;
15383 }
15384
15385 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15386         LDKCResult_ExpiryTimeCreationErrorZ* o_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(o & ~1);
15387         jboolean ret_val = CResult_ExpiryTimeCreationErrorZ_is_ok(o_conv);
15388         return ret_val;
15389 }
15390
15391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15392         if ((_res & 1) != 0) return;
15393         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15394         CHECK_ACCESS(_res_ptr);
15395         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
15396         FREE((void*)_res);
15397         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
15398 }
15399
15400 static inline uint64_t CResult_ExpiryTimeCreationErrorZ_clone_ptr(LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR arg) {
15401         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
15402         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(arg);
15403         return (uint64_t)ret_conv;
15404 }
15405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15406         LDKCResult_ExpiryTimeCreationErrorZ* arg_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
15407         int64_t ret_val = CResult_ExpiryTimeCreationErrorZ_clone_ptr(arg_conv);
15408         return ret_val;
15409 }
15410
15411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15412         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
15413         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
15414         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
15415         return (uint64_t)ret_conv;
15416 }
15417
15418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15419         LDKPrivateRoute o_conv;
15420         o_conv.inner = (void*)(o & (~1));
15421         o_conv.is_owned = (o & 1) || (o == 0);
15422         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15423         o_conv = PrivateRoute_clone(&o_conv);
15424         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15425         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15426         return (uint64_t)ret_conv;
15427 }
15428
15429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15430         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15431         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15432         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15433         return (uint64_t)ret_conv;
15434 }
15435
15436 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15437         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15438         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15439         return ret_val;
15440 }
15441
15442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15443         if ((_res & 1) != 0) return;
15444         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15445         CHECK_ACCESS(_res_ptr);
15446         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15447         FREE((void*)_res);
15448         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15449 }
15450
15451 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15452         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15453         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15454         return (uint64_t)ret_conv;
15455 }
15456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15457         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15458         int64_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15459         return ret_val;
15460 }
15461
15462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15463         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15464         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15465         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15466         return (uint64_t)ret_conv;
15467 }
15468
15469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
15470         LDKStr o_conv = java_to_owned_str(env, o);
15471         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15472         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15473         return (uint64_t)ret_conv;
15474 }
15475
15476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15477         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15478         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15479         *ret_conv = CResult_StringErrorZ_err(e_conv);
15480         return (uint64_t)ret_conv;
15481 }
15482
15483 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15484         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15485         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
15486         return ret_val;
15487 }
15488
15489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15490         if ((_res & 1) != 0) return;
15491         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15492         CHECK_ACCESS(_res_ptr);
15493         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15494         FREE((void*)_res);
15495         CResult_StringErrorZ_free(_res_conv);
15496 }
15497
15498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15499         LDKChannelMonitorUpdate o_conv;
15500         o_conv.inner = (void*)(o & (~1));
15501         o_conv.is_owned = (o & 1) || (o == 0);
15502         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15503         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15504         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15505         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15506         return (uint64_t)ret_conv;
15507 }
15508
15509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15510         LDKDecodeError e_conv;
15511         e_conv.inner = (void*)(e & (~1));
15512         e_conv.is_owned = (e & 1) || (e == 0);
15513         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15514         e_conv = DecodeError_clone(&e_conv);
15515         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15516         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15517         return (uint64_t)ret_conv;
15518 }
15519
15520 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15521         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15522         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15523         return ret_val;
15524 }
15525
15526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15527         if ((_res & 1) != 0) return;
15528         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15529         CHECK_ACCESS(_res_ptr);
15530         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15531         FREE((void*)_res);
15532         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15533 }
15534
15535 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15536         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15537         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15538         return (uint64_t)ret_conv;
15539 }
15540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15541         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15542         int64_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15543         return ret_val;
15544 }
15545
15546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15547         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15548         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15549         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15550         return (uint64_t)ret_conv;
15551 }
15552
15553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15554         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15555         CHECK_ACCESS(o_ptr);
15556         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15557         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)o) & ~1));
15558         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15559         *ret_copy = COption_MonitorEventZ_some(o_conv);
15560         uint64_t ret_ref = (uint64_t)ret_copy;
15561         return ret_ref;
15562 }
15563
15564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
15565         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15566         *ret_copy = COption_MonitorEventZ_none();
15567         uint64_t ret_ref = (uint64_t)ret_copy;
15568         return ret_ref;
15569 }
15570
15571 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15572         if ((_res & 1) != 0) return;
15573         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15574         CHECK_ACCESS(_res_ptr);
15575         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15576         FREE((void*)_res);
15577         COption_MonitorEventZ_free(_res_conv);
15578 }
15579
15580 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15581         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15582         *ret_copy = COption_MonitorEventZ_clone(arg);
15583 uint64_t ret_ref = (uint64_t)ret_copy;
15584         return ret_ref;
15585 }
15586 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15587         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15588         int64_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
15589         return ret_val;
15590 }
15591
15592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15593         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15594         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15595         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15596         uint64_t ret_ref = (uint64_t)ret_copy;
15597         return ret_ref;
15598 }
15599
15600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15601         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15602         CHECK_ACCESS(o_ptr);
15603         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15604         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uint64_t)o) & ~1));
15605         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15606         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15607         return (uint64_t)ret_conv;
15608 }
15609
15610 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15611         LDKDecodeError e_conv;
15612         e_conv.inner = (void*)(e & (~1));
15613         e_conv.is_owned = (e & 1) || (e == 0);
15614         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15615         e_conv = DecodeError_clone(&e_conv);
15616         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15617         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15618         return (uint64_t)ret_conv;
15619 }
15620
15621 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15622         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15623         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15624         return ret_val;
15625 }
15626
15627 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15628         if ((_res & 1) != 0) return;
15629         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15630         CHECK_ACCESS(_res_ptr);
15631         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15632         FREE((void*)_res);
15633         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15634 }
15635
15636 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15637         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15638         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15639         return (uint64_t)ret_conv;
15640 }
15641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15642         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15643         int64_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15644         return ret_val;
15645 }
15646
15647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15648         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15649         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15650         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15651         return (uint64_t)ret_conv;
15652 }
15653
15654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15655         LDKHTLCUpdate o_conv;
15656         o_conv.inner = (void*)(o & (~1));
15657         o_conv.is_owned = (o & 1) || (o == 0);
15658         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15659         o_conv = HTLCUpdate_clone(&o_conv);
15660         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15661         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15662         return (uint64_t)ret_conv;
15663 }
15664
15665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15666         LDKDecodeError e_conv;
15667         e_conv.inner = (void*)(e & (~1));
15668         e_conv.is_owned = (e & 1) || (e == 0);
15669         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15670         e_conv = DecodeError_clone(&e_conv);
15671         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15672         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15673         return (uint64_t)ret_conv;
15674 }
15675
15676 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15677         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15678         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15679         return ret_val;
15680 }
15681
15682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15683         if ((_res & 1) != 0) return;
15684         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15685         CHECK_ACCESS(_res_ptr);
15686         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15687         FREE((void*)_res);
15688         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15689 }
15690
15691 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15692         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15693         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15694         return (uint64_t)ret_conv;
15695 }
15696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15697         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15698         int64_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15699         return ret_val;
15700 }
15701
15702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15703         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15704         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15705         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15706         return (uint64_t)ret_conv;
15707 }
15708
15709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
15710         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15711         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
15712         return (uint64_t)ret_conv;
15713 }
15714
15715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15716         LDKMonitorUpdateError e_conv;
15717         e_conv.inner = (void*)(e & (~1));
15718         e_conv.is_owned = (e & 1) || (e == 0);
15719         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15720         e_conv = MonitorUpdateError_clone(&e_conv);
15721         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15722         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
15723         return (uint64_t)ret_conv;
15724 }
15725
15726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15727         LDKCResult_NoneMonitorUpdateErrorZ* o_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(o & ~1);
15728         jboolean ret_val = CResult_NoneMonitorUpdateErrorZ_is_ok(o_conv);
15729         return ret_val;
15730 }
15731
15732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15733         if ((_res & 1) != 0) return;
15734         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15735         CHECK_ACCESS(_res_ptr);
15736         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
15737         FREE((void*)_res);
15738         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
15739 }
15740
15741 static inline uint64_t CResult_NoneMonitorUpdateErrorZ_clone_ptr(LDKCResult_NoneMonitorUpdateErrorZ *NONNULL_PTR arg) {
15742         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15743         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(arg);
15744         return (uint64_t)ret_conv;
15745 }
15746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15747         LDKCResult_NoneMonitorUpdateErrorZ* arg_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
15748         int64_t ret_val = CResult_NoneMonitorUpdateErrorZ_clone_ptr(arg_conv);
15749         return ret_val;
15750 }
15751
15752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15753         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
15754         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15755         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
15756         return (uint64_t)ret_conv;
15757 }
15758
15759 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15760         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15761         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15762         return ((uint64_t)ret_conv);
15763 }
15764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15765         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15766         int64_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15767         return ret_val;
15768 }
15769
15770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15771         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15772         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15773         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15774         return ((uint64_t)ret_conv);
15775 }
15776
15777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
15778         LDKOutPoint a_conv;
15779         a_conv.inner = (void*)(a & (~1));
15780         a_conv.is_owned = (a & 1) || (a == 0);
15781         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15782         a_conv = OutPoint_clone(&a_conv);
15783         LDKCVec_u8Z b_ref;
15784         b_ref.datalen = (*env)->GetArrayLength(env, b);
15785         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15786         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15787         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15788         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15789         return ((uint64_t)ret_conv);
15790 }
15791
15792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15793         if ((_res & 1) != 0) return;
15794         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15795         CHECK_ACCESS(_res_ptr);
15796         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15797         FREE((void*)_res);
15798         C2Tuple_OutPointScriptZ_free(_res_conv);
15799 }
15800
15801 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15802         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15803         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15804         return ((uint64_t)ret_conv);
15805 }
15806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15807         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15808         int64_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15809         return ret_val;
15810 }
15811
15812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15813         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15814         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15815         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15816         return ((uint64_t)ret_conv);
15817 }
15818
15819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
15820         LDKCVec_u8Z b_ref;
15821         b_ref.datalen = (*env)->GetArrayLength(env, b);
15822         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15823         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15824         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15825         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15826         return ((uint64_t)ret_conv);
15827 }
15828
15829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15830         if ((_res & 1) != 0) return;
15831         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15832         CHECK_ACCESS(_res_ptr);
15833         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15834         FREE((void*)_res);
15835         C2Tuple_u32ScriptZ_free(_res_conv);
15836 }
15837
15838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15839         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15840         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15841         if (_res_constr.datalen > 0)
15842                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15843         else
15844                 _res_constr.data = NULL;
15845         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15846         for (size_t v = 0; v < _res_constr.datalen; v++) {
15847                 int64_t _res_conv_21 = _res_vals[v];
15848                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
15849                 CHECK_ACCESS(_res_conv_21_ptr);
15850                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15851                 FREE((void*)_res_conv_21);
15852                 _res_constr.data[v] = _res_conv_21_conv;
15853         }
15854         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15855         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
15856 }
15857
15858 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
15859         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15860         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
15861         return ((uint64_t)ret_conv);
15862 }
15863 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15864         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
15865         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
15866         return ret_val;
15867 }
15868
15869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15870         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
15871         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15872         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
15873         return ((uint64_t)ret_conv);
15874 }
15875
15876 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
15877         LDKThirtyTwoBytes a_ref;
15878         CHECK((*env)->GetArrayLength(env, a) == 32);
15879         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
15880         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
15881         b_constr.datalen = (*env)->GetArrayLength(env, b);
15882         if (b_constr.datalen > 0)
15883                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15884         else
15885                 b_constr.data = NULL;
15886         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
15887         for (size_t v = 0; v < b_constr.datalen; v++) {
15888                 int64_t b_conv_21 = b_vals[v];
15889                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
15890                 CHECK_ACCESS(b_conv_21_ptr);
15891                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
15892                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
15893                 b_constr.data[v] = b_conv_21_conv;
15894         }
15895         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
15896         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15897         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
15898         return ((uint64_t)ret_conv);
15899 }
15900
15901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15902         if ((_res & 1) != 0) return;
15903         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15904         CHECK_ACCESS(_res_ptr);
15905         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
15906         FREE((void*)_res);
15907         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
15908 }
15909
15910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15911         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
15912         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15913         if (_res_constr.datalen > 0)
15914                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
15915         else
15916                 _res_constr.data = NULL;
15917         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15918         for (size_t o = 0; o < _res_constr.datalen; o++) {
15919                 int64_t _res_conv_40 = _res_vals[o];
15920                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
15921                 CHECK_ACCESS(_res_conv_40_ptr);
15922                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
15923                 FREE((void*)_res_conv_40);
15924                 _res_constr.data[o] = _res_conv_40_conv;
15925         }
15926         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15927         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
15928 }
15929
15930 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15931         LDKCVec_EventZ _res_constr;
15932         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15933         if (_res_constr.datalen > 0)
15934                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
15935         else
15936                 _res_constr.data = NULL;
15937         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15938         for (size_t h = 0; h < _res_constr.datalen; h++) {
15939                 int64_t _res_conv_7 = _res_vals[h];
15940                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
15941                 CHECK_ACCESS(_res_conv_7_ptr);
15942                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
15943                 FREE((void*)_res_conv_7);
15944                 _res_constr.data[h] = _res_conv_7_conv;
15945         }
15946         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15947         CVec_EventZ_free(_res_constr);
15948 }
15949
15950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15951         LDKCVec_TransactionZ _res_constr;
15952         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15953         if (_res_constr.datalen > 0)
15954                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
15955         else
15956                 _res_constr.data = NULL;
15957         for (size_t i = 0; i < _res_constr.datalen; i++) {
15958                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15959                 LDKTransaction _res_conv_8_ref;
15960                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
15961                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
15962                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
15963                 _res_conv_8_ref.data_is_owned = true;
15964                 _res_constr.data[i] = _res_conv_8_ref;
15965         }
15966         CVec_TransactionZ_free(_res_constr);
15967 }
15968
15969 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
15970         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15971         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
15972         return ((uint64_t)ret_conv);
15973 }
15974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15975         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
15976         int64_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
15977         return ret_val;
15978 }
15979
15980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15981         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
15982         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15983         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
15984         return ((uint64_t)ret_conv);
15985 }
15986
15987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
15988         void* b_ptr = (void*)(((uint64_t)b) & ~1);
15989         CHECK_ACCESS(b_ptr);
15990         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
15991         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
15992         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15993         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
15994         return ((uint64_t)ret_conv);
15995 }
15996
15997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15998         if ((_res & 1) != 0) return;
15999         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16000         CHECK_ACCESS(_res_ptr);
16001         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
16002         FREE((void*)_res);
16003         C2Tuple_u32TxOutZ_free(_res_conv);
16004 }
16005
16006 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16007         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
16008         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16009         if (_res_constr.datalen > 0)
16010                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16011         else
16012                 _res_constr.data = NULL;
16013         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16014         for (size_t u = 0; u < _res_constr.datalen; u++) {
16015                 int64_t _res_conv_20 = _res_vals[u];
16016                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
16017                 CHECK_ACCESS(_res_conv_20_ptr);
16018                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
16019                 FREE((void*)_res_conv_20);
16020                 _res_constr.data[u] = _res_conv_20_conv;
16021         }
16022         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16023         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
16024 }
16025
16026 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
16027         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16028         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
16029         return ((uint64_t)ret_conv);
16030 }
16031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16032         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
16033         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
16034         return ret_val;
16035 }
16036
16037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16038         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
16039         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16040         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
16041         return ((uint64_t)ret_conv);
16042 }
16043
16044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
16045         LDKThirtyTwoBytes a_ref;
16046         CHECK((*env)->GetArrayLength(env, a) == 32);
16047         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16048         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
16049         b_constr.datalen = (*env)->GetArrayLength(env, b);
16050         if (b_constr.datalen > 0)
16051                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16052         else
16053                 b_constr.data = NULL;
16054         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
16055         for (size_t u = 0; u < b_constr.datalen; u++) {
16056                 int64_t b_conv_20 = b_vals[u];
16057                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
16058                 CHECK_ACCESS(b_conv_20_ptr);
16059                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
16060                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
16061                 b_constr.data[u] = b_conv_20_conv;
16062         }
16063         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
16064         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16065         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
16066         return ((uint64_t)ret_conv);
16067 }
16068
16069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16070         if ((_res & 1) != 0) return;
16071         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16072         CHECK_ACCESS(_res_ptr);
16073         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
16074         FREE((void*)_res);
16075         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
16076 }
16077
16078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16079         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
16080         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16081         if (_res_constr.datalen > 0)
16082                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
16083         else
16084                 _res_constr.data = NULL;
16085         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16086         for (size_t n = 0; n < _res_constr.datalen; n++) {
16087                 int64_t _res_conv_39 = _res_vals[n];
16088                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
16089                 CHECK_ACCESS(_res_conv_39_ptr);
16090                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
16091                 FREE((void*)_res_conv_39);
16092                 _res_constr.data[n] = _res_conv_39_conv;
16093         }
16094         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16095         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
16096 }
16097
16098 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16099         LDKCVec_BalanceZ _res_constr;
16100         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16101         if (_res_constr.datalen > 0)
16102                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
16103         else
16104                 _res_constr.data = NULL;
16105         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16106         for (size_t j = 0; j < _res_constr.datalen; j++) {
16107                 int64_t _res_conv_9 = _res_vals[j];
16108                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
16109                 CHECK_ACCESS(_res_conv_9_ptr);
16110                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
16111                 FREE((void*)_res_conv_9);
16112                 _res_constr.data[j] = _res_conv_9_conv;
16113         }
16114         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16115         CVec_BalanceZ_free(_res_constr);
16116 }
16117
16118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16119         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16120         CHECK_ACCESS(o_ptr);
16121         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16122         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
16123         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16124         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16125         return (uint64_t)ret_conv;
16126 }
16127
16128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16129         LDKDecodeError e_conv;
16130         e_conv.inner = (void*)(e & (~1));
16131         e_conv.is_owned = (e & 1) || (e == 0);
16132         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16133         e_conv = DecodeError_clone(&e_conv);
16134         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16135         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16136         return (uint64_t)ret_conv;
16137 }
16138
16139 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16140         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16141         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16142         return ret_val;
16143 }
16144
16145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16146         if ((_res & 1) != 0) return;
16147         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16148         CHECK_ACCESS(_res_ptr);
16149         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16150         FREE((void*)_res);
16151         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16152 }
16153
16154 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16155         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16156         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16157         return (uint64_t)ret_conv;
16158 }
16159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16160         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16161         int64_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16162         return ret_val;
16163 }
16164
16165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16166         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16167         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16168         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16169         return (uint64_t)ret_conv;
16170 }
16171
16172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
16173         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16174         *ret_conv = CResult_NoneLightningErrorZ_ok();
16175         return (uint64_t)ret_conv;
16176 }
16177
16178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16179         LDKLightningError e_conv;
16180         e_conv.inner = (void*)(e & (~1));
16181         e_conv.is_owned = (e & 1) || (e == 0);
16182         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16183         e_conv = LightningError_clone(&e_conv);
16184         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16185         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16186         return (uint64_t)ret_conv;
16187 }
16188
16189 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16190         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16191         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
16192         return ret_val;
16193 }
16194
16195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16196         if ((_res & 1) != 0) return;
16197         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16198         CHECK_ACCESS(_res_ptr);
16199         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16200         FREE((void*)_res);
16201         CResult_NoneLightningErrorZ_free(_res_conv);
16202 }
16203
16204 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16205         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16206         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16207         return (uint64_t)ret_conv;
16208 }
16209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16210         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16211         int64_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16212         return ret_val;
16213 }
16214
16215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16216         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16217         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16218         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16219         return (uint64_t)ret_conv;
16220 }
16221
16222 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16223         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16224         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16225         return ((uint64_t)ret_conv);
16226 }
16227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16228         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16229         int64_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16230         return ret_val;
16231 }
16232
16233 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16234         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16235         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16236         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16237         return ((uint64_t)ret_conv);
16238 }
16239
16240 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
16241         LDKPublicKey a_ref;
16242         CHECK((*env)->GetArrayLength(env, a) == 33);
16243         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
16244         void* b_ptr = (void*)(((uint64_t)b) & ~1);
16245         CHECK_ACCESS(b_ptr);
16246         LDKType b_conv = *(LDKType*)(b_ptr);
16247         if (b_conv.free == LDKType_JCalls_free) {
16248                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16249                 LDKType_JCalls_cloned(&b_conv);
16250         }
16251         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16252         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16253         return ((uint64_t)ret_conv);
16254 }
16255
16256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16257         if ((_res & 1) != 0) return;
16258         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16259         CHECK_ACCESS(_res_ptr);
16260         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16261         FREE((void*)_res);
16262         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16263 }
16264
16265 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16266         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16267         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16268         if (_res_constr.datalen > 0)
16269                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16270         else
16271                 _res_constr.data = NULL;
16272         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16273         for (size_t z = 0; z < _res_constr.datalen; z++) {
16274                 int64_t _res_conv_25 = _res_vals[z];
16275                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
16276                 CHECK_ACCESS(_res_conv_25_ptr);
16277                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16278                 FREE((void*)_res_conv_25);
16279                 _res_constr.data[z] = _res_conv_25_conv;
16280         }
16281         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16282         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16283 }
16284
16285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
16286         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16287         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16288         return (uint64_t)ret_conv;
16289 }
16290
16291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16292         LDKLightningError e_conv;
16293         e_conv.inner = (void*)(e & (~1));
16294         e_conv.is_owned = (e & 1) || (e == 0);
16295         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16296         e_conv = LightningError_clone(&e_conv);
16297         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16298         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16299         return (uint64_t)ret_conv;
16300 }
16301
16302 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16303         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16304         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
16305         return ret_val;
16306 }
16307
16308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16309         if ((_res & 1) != 0) return;
16310         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16311         CHECK_ACCESS(_res_ptr);
16312         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16313         FREE((void*)_res);
16314         CResult_boolLightningErrorZ_free(_res_conv);
16315 }
16316
16317 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16318         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16319         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16320         return (uint64_t)ret_conv;
16321 }
16322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16323         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16324         int64_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16325         return ret_val;
16326 }
16327
16328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16329         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16330         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16331         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16332         return (uint64_t)ret_conv;
16333 }
16334
16335 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16336         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16337         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16338         return ((uint64_t)ret_conv);
16339 }
16340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16341         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16342         int64_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16343         return ret_val;
16344 }
16345
16346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16347         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16348         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16349         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16350         return ((uint64_t)ret_conv);
16351 }
16352
16353 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) {
16354         LDKChannelAnnouncement a_conv;
16355         a_conv.inner = (void*)(a & (~1));
16356         a_conv.is_owned = (a & 1) || (a == 0);
16357         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16358         a_conv = ChannelAnnouncement_clone(&a_conv);
16359         LDKChannelUpdate b_conv;
16360         b_conv.inner = (void*)(b & (~1));
16361         b_conv.is_owned = (b & 1) || (b == 0);
16362         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16363         b_conv = ChannelUpdate_clone(&b_conv);
16364         LDKChannelUpdate c_conv;
16365         c_conv.inner = (void*)(c & (~1));
16366         c_conv.is_owned = (c & 1) || (c == 0);
16367         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16368         c_conv = ChannelUpdate_clone(&c_conv);
16369         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16370         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16371         return ((uint64_t)ret_conv);
16372 }
16373
16374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16375         if ((_res & 1) != 0) return;
16376         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16377         CHECK_ACCESS(_res_ptr);
16378         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16379         FREE((void*)_res);
16380         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16381 }
16382
16383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16384         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16385         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16386         if (_res_constr.datalen > 0)
16387                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16388         else
16389                 _res_constr.data = NULL;
16390         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16391         for (size_t h = 0; h < _res_constr.datalen; h++) {
16392                 int64_t _res_conv_59 = _res_vals[h];
16393                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
16394                 CHECK_ACCESS(_res_conv_59_ptr);
16395                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16396                 FREE((void*)_res_conv_59);
16397                 _res_constr.data[h] = _res_conv_59_conv;
16398         }
16399         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16400         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16401 }
16402
16403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16404         LDKCVec_NodeAnnouncementZ _res_constr;
16405         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16406         if (_res_constr.datalen > 0)
16407                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16408         else
16409                 _res_constr.data = NULL;
16410         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16411         for (size_t s = 0; s < _res_constr.datalen; s++) {
16412                 int64_t _res_conv_18 = _res_vals[s];
16413                 LDKNodeAnnouncement _res_conv_18_conv;
16414                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16415                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16416                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16417                 _res_constr.data[s] = _res_conv_18_conv;
16418         }
16419         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16420         CVec_NodeAnnouncementZ_free(_res_constr);
16421 }
16422
16423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16424         LDKCVec_PublicKeyZ _res_constr;
16425         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16426         if (_res_constr.datalen > 0)
16427                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16428         else
16429                 _res_constr.data = NULL;
16430         for (size_t i = 0; i < _res_constr.datalen; i++) {
16431                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16432                 LDKPublicKey _res_conv_8_ref;
16433                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16434                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16435                 _res_constr.data[i] = _res_conv_8_ref;
16436         }
16437         CVec_PublicKeyZ_free(_res_constr);
16438 }
16439
16440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16441         LDKCVec_u8Z o_ref;
16442         o_ref.datalen = (*env)->GetArrayLength(env, o);
16443         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16444         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
16445         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16446         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16447         return (uint64_t)ret_conv;
16448 }
16449
16450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16451         LDKPeerHandleError e_conv;
16452         e_conv.inner = (void*)(e & (~1));
16453         e_conv.is_owned = (e & 1) || (e == 0);
16454         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16455         e_conv = PeerHandleError_clone(&e_conv);
16456         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16457         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16458         return (uint64_t)ret_conv;
16459 }
16460
16461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16462         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16463         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16464         return ret_val;
16465 }
16466
16467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16468         if ((_res & 1) != 0) return;
16469         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16470         CHECK_ACCESS(_res_ptr);
16471         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16472         FREE((void*)_res);
16473         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16474 }
16475
16476 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16477         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16478         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16479         return (uint64_t)ret_conv;
16480 }
16481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16482         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16483         int64_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16484         return ret_val;
16485 }
16486
16487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16488         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16489         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16490         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16491         return (uint64_t)ret_conv;
16492 }
16493
16494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
16495         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16496         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16497         return (uint64_t)ret_conv;
16498 }
16499
16500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16501         LDKPeerHandleError e_conv;
16502         e_conv.inner = (void*)(e & (~1));
16503         e_conv.is_owned = (e & 1) || (e == 0);
16504         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16505         e_conv = PeerHandleError_clone(&e_conv);
16506         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16507         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16508         return (uint64_t)ret_conv;
16509 }
16510
16511 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16512         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16513         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16514         return ret_val;
16515 }
16516
16517 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16518         if ((_res & 1) != 0) return;
16519         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16520         CHECK_ACCESS(_res_ptr);
16521         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16522         FREE((void*)_res);
16523         CResult_NonePeerHandleErrorZ_free(_res_conv);
16524 }
16525
16526 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16527         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16528         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16529         return (uint64_t)ret_conv;
16530 }
16531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16532         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16533         int64_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16534         return ret_val;
16535 }
16536
16537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16538         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16539         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16540         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16541         return (uint64_t)ret_conv;
16542 }
16543
16544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
16545         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16546         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16547         return (uint64_t)ret_conv;
16548 }
16549
16550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16551         LDKPeerHandleError e_conv;
16552         e_conv.inner = (void*)(e & (~1));
16553         e_conv.is_owned = (e & 1) || (e == 0);
16554         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16555         e_conv = PeerHandleError_clone(&e_conv);
16556         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16557         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16558         return (uint64_t)ret_conv;
16559 }
16560
16561 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16562         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16563         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16564         return ret_val;
16565 }
16566
16567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16568         if ((_res & 1) != 0) return;
16569         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16570         CHECK_ACCESS(_res_ptr);
16571         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16572         FREE((void*)_res);
16573         CResult_boolPeerHandleErrorZ_free(_res_conv);
16574 }
16575
16576 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16577         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16578         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16579         return (uint64_t)ret_conv;
16580 }
16581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16582         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16583         int64_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16584         return ret_val;
16585 }
16586
16587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16588         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16589         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16590         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16591         return (uint64_t)ret_conv;
16592 }
16593
16594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16595         LDKNodeId o_conv;
16596         o_conv.inner = (void*)(o & (~1));
16597         o_conv.is_owned = (o & 1) || (o == 0);
16598         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16599         o_conv = NodeId_clone(&o_conv);
16600         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16601         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16602         return (uint64_t)ret_conv;
16603 }
16604
16605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16606         LDKDecodeError e_conv;
16607         e_conv.inner = (void*)(e & (~1));
16608         e_conv.is_owned = (e & 1) || (e == 0);
16609         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16610         e_conv = DecodeError_clone(&e_conv);
16611         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16612         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16613         return (uint64_t)ret_conv;
16614 }
16615
16616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16617         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16618         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16619         return ret_val;
16620 }
16621
16622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16623         if ((_res & 1) != 0) return;
16624         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16625         CHECK_ACCESS(_res_ptr);
16626         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16627         FREE((void*)_res);
16628         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16629 }
16630
16631 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16632         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16633         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16634         return (uint64_t)ret_conv;
16635 }
16636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16637         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16638         int64_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16639         return ret_val;
16640 }
16641
16642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16643         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16644         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16645         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16646         return (uint64_t)ret_conv;
16647 }
16648
16649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16650         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16651         CHECK_ACCESS(o_ptr);
16652         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16653         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)o) & ~1));
16654         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16655         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16656         return (uint64_t)ret_conv;
16657 }
16658
16659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16660         LDKDecodeError e_conv;
16661         e_conv.inner = (void*)(e & (~1));
16662         e_conv.is_owned = (e & 1) || (e == 0);
16663         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16664         e_conv = DecodeError_clone(&e_conv);
16665         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16666         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16667         return (uint64_t)ret_conv;
16668 }
16669
16670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16671         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16672         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16673         return ret_val;
16674 }
16675
16676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16677         if ((_res & 1) != 0) return;
16678         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16679         CHECK_ACCESS(_res_ptr);
16680         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16681         FREE((void*)_res);
16682         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16683 }
16684
16685 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16686         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16687         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16688         return (uint64_t)ret_conv;
16689 }
16690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16691         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16692         int64_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16693         return ret_val;
16694 }
16695
16696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16697         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16698         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16699         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16700         return (uint64_t)ret_conv;
16701 }
16702
16703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16704         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16705         CHECK_ACCESS(o_ptr);
16706         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16707         if (o_conv.free == LDKAccess_JCalls_free) {
16708                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16709                 LDKAccess_JCalls_cloned(&o_conv);
16710         }
16711         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16712         *ret_copy = COption_AccessZ_some(o_conv);
16713         uint64_t ret_ref = (uint64_t)ret_copy;
16714         return ret_ref;
16715 }
16716
16717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
16718         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16719         *ret_copy = COption_AccessZ_none();
16720         uint64_t ret_ref = (uint64_t)ret_copy;
16721         return ret_ref;
16722 }
16723
16724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16725         if ((_res & 1) != 0) return;
16726         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16727         CHECK_ACCESS(_res_ptr);
16728         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16729         FREE((void*)_res);
16730         COption_AccessZ_free(_res_conv);
16731 }
16732
16733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16734         LDKDirectionalChannelInfo o_conv;
16735         o_conv.inner = (void*)(o & (~1));
16736         o_conv.is_owned = (o & 1) || (o == 0);
16737         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16738         o_conv = DirectionalChannelInfo_clone(&o_conv);
16739         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
16740         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
16741         return (uint64_t)ret_conv;
16742 }
16743
16744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16745         LDKDecodeError e_conv;
16746         e_conv.inner = (void*)(e & (~1));
16747         e_conv.is_owned = (e & 1) || (e == 0);
16748         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16749         e_conv = DecodeError_clone(&e_conv);
16750         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
16751         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
16752         return (uint64_t)ret_conv;
16753 }
16754
16755 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16756         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
16757         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
16758         return ret_val;
16759 }
16760
16761 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16762         if ((_res & 1) != 0) return;
16763         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16764         CHECK_ACCESS(_res_ptr);
16765         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
16766         FREE((void*)_res);
16767         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
16768 }
16769
16770 static inline uint64_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16771         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
16772         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
16773         return (uint64_t)ret_conv;
16774 }
16775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16776         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
16777         int64_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16778         return ret_val;
16779 }
16780
16781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16782         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
16783         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
16784         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
16785         return (uint64_t)ret_conv;
16786 }
16787
16788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16789         LDKChannelInfo o_conv;
16790         o_conv.inner = (void*)(o & (~1));
16791         o_conv.is_owned = (o & 1) || (o == 0);
16792         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16793         o_conv = ChannelInfo_clone(&o_conv);
16794         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16795         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
16796         return (uint64_t)ret_conv;
16797 }
16798
16799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16800         LDKDecodeError e_conv;
16801         e_conv.inner = (void*)(e & (~1));
16802         e_conv.is_owned = (e & 1) || (e == 0);
16803         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16804         e_conv = DecodeError_clone(&e_conv);
16805         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16806         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
16807         return (uint64_t)ret_conv;
16808 }
16809
16810 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16811         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
16812         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
16813         return ret_val;
16814 }
16815
16816 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16817         if ((_res & 1) != 0) return;
16818         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16819         CHECK_ACCESS(_res_ptr);
16820         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
16821         FREE((void*)_res);
16822         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
16823 }
16824
16825 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16826         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16827         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
16828         return (uint64_t)ret_conv;
16829 }
16830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16831         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
16832         int64_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16833         return ret_val;
16834 }
16835
16836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16837         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
16838         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16839         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
16840         return (uint64_t)ret_conv;
16841 }
16842
16843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16844         LDKRoutingFees o_conv;
16845         o_conv.inner = (void*)(o & (~1));
16846         o_conv.is_owned = (o & 1) || (o == 0);
16847         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16848         o_conv = RoutingFees_clone(&o_conv);
16849         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16850         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
16851         return (uint64_t)ret_conv;
16852 }
16853
16854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16855         LDKDecodeError e_conv;
16856         e_conv.inner = (void*)(e & (~1));
16857         e_conv.is_owned = (e & 1) || (e == 0);
16858         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16859         e_conv = DecodeError_clone(&e_conv);
16860         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16861         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
16862         return (uint64_t)ret_conv;
16863 }
16864
16865 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16866         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
16867         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
16868         return ret_val;
16869 }
16870
16871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16872         if ((_res & 1) != 0) return;
16873         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16874         CHECK_ACCESS(_res_ptr);
16875         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
16876         FREE((void*)_res);
16877         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
16878 }
16879
16880 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
16881         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16882         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
16883         return (uint64_t)ret_conv;
16884 }
16885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16886         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
16887         int64_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
16888         return ret_val;
16889 }
16890
16891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16892         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
16893         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16894         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
16895         return (uint64_t)ret_conv;
16896 }
16897
16898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16899         LDKNodeAnnouncementInfo o_conv;
16900         o_conv.inner = (void*)(o & (~1));
16901         o_conv.is_owned = (o & 1) || (o == 0);
16902         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16903         o_conv = NodeAnnouncementInfo_clone(&o_conv);
16904         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16905         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
16906         return (uint64_t)ret_conv;
16907 }
16908
16909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16910         LDKDecodeError e_conv;
16911         e_conv.inner = (void*)(e & (~1));
16912         e_conv.is_owned = (e & 1) || (e == 0);
16913         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16914         e_conv = DecodeError_clone(&e_conv);
16915         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16916         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
16917         return (uint64_t)ret_conv;
16918 }
16919
16920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16921         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
16922         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
16923         return ret_val;
16924 }
16925
16926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16927         if ((_res & 1) != 0) return;
16928         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16929         CHECK_ACCESS(_res_ptr);
16930         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
16931         FREE((void*)_res);
16932         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
16933 }
16934
16935 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
16936         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16937         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
16938         return (uint64_t)ret_conv;
16939 }
16940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16941         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
16942         int64_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
16943         return ret_val;
16944 }
16945
16946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16947         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
16948         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16949         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
16950         return (uint64_t)ret_conv;
16951 }
16952
16953 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16954         LDKCVec_u64Z _res_constr;
16955         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16956         if (_res_constr.datalen > 0)
16957                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16958         else
16959                 _res_constr.data = NULL;
16960         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16961         for (size_t g = 0; g < _res_constr.datalen; g++) {
16962                 int64_t _res_conv_6 = _res_vals[g];
16963                 _res_constr.data[g] = _res_conv_6;
16964         }
16965         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16966         CVec_u64Z_free(_res_constr);
16967 }
16968
16969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16970         LDKNodeInfo o_conv;
16971         o_conv.inner = (void*)(o & (~1));
16972         o_conv.is_owned = (o & 1) || (o == 0);
16973         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16974         o_conv = NodeInfo_clone(&o_conv);
16975         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16976         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
16977         return (uint64_t)ret_conv;
16978 }
16979
16980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16981         LDKDecodeError e_conv;
16982         e_conv.inner = (void*)(e & (~1));
16983         e_conv.is_owned = (e & 1) || (e == 0);
16984         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16985         e_conv = DecodeError_clone(&e_conv);
16986         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16987         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
16988         return (uint64_t)ret_conv;
16989 }
16990
16991 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16992         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
16993         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
16994         return ret_val;
16995 }
16996
16997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16998         if ((_res & 1) != 0) return;
16999         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17000         CHECK_ACCESS(_res_ptr);
17001         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17002         FREE((void*)_res);
17003         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17004 }
17005
17006 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17007         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17008         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17009         return (uint64_t)ret_conv;
17010 }
17011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17012         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17013         int64_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17014         return ret_val;
17015 }
17016
17017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17018         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17019         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17020         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17021         return (uint64_t)ret_conv;
17022 }
17023
17024 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17025         LDKNetworkGraph o_conv;
17026         o_conv.inner = (void*)(o & (~1));
17027         o_conv.is_owned = (o & 1) || (o == 0);
17028         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17029         o_conv = NetworkGraph_clone(&o_conv);
17030         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17031         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17032         return (uint64_t)ret_conv;
17033 }
17034
17035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17036         LDKDecodeError e_conv;
17037         e_conv.inner = (void*)(e & (~1));
17038         e_conv.is_owned = (e & 1) || (e == 0);
17039         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17040         e_conv = DecodeError_clone(&e_conv);
17041         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17042         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17043         return (uint64_t)ret_conv;
17044 }
17045
17046 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17047         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17048         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17049         return ret_val;
17050 }
17051
17052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17053         if ((_res & 1) != 0) return;
17054         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17055         CHECK_ACCESS(_res_ptr);
17056         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17057         FREE((void*)_res);
17058         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17059 }
17060
17061 static inline uint64_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
17062         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17063         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
17064         return (uint64_t)ret_conv;
17065 }
17066 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17067         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
17068         int64_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
17069         return ret_val;
17070 }
17071
17072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17073         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
17074         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17075         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
17076         return (uint64_t)ret_conv;
17077 }
17078
17079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
17080         LDKCVec_NetAddressZ o_constr;
17081         o_constr.datalen = (*env)->GetArrayLength(env, o);
17082         if (o_constr.datalen > 0)
17083                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17084         else
17085                 o_constr.data = NULL;
17086         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17087         for (size_t m = 0; m < o_constr.datalen; m++) {
17088                 int64_t o_conv_12 = o_vals[m];
17089                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
17090                 CHECK_ACCESS(o_conv_12_ptr);
17091                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17092                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
17093                 o_constr.data[m] = o_conv_12_conv;
17094         }
17095         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17096         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17097         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17098         uint64_t ret_ref = (uint64_t)ret_copy;
17099         return ret_ref;
17100 }
17101
17102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
17103         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17104         *ret_copy = COption_CVec_NetAddressZZ_none();
17105         uint64_t ret_ref = (uint64_t)ret_copy;
17106         return ret_ref;
17107 }
17108
17109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17110         if ((_res & 1) != 0) return;
17111         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17112         CHECK_ACCESS(_res_ptr);
17113         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17114         FREE((void*)_res);
17115         COption_CVec_NetAddressZZ_free(_res_conv);
17116 }
17117
17118 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17119         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17120         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17121 uint64_t ret_ref = (uint64_t)ret_copy;
17122         return ret_ref;
17123 }
17124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17125         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17126         int64_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17127         return ret_val;
17128 }
17129
17130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17131         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17132         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17133         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17134         uint64_t ret_ref = (uint64_t)ret_copy;
17135         return ret_ref;
17136 }
17137
17138 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17139         void* o_ptr = (void*)(((uint64_t)o) & ~1);
17140         CHECK_ACCESS(o_ptr);
17141         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17142         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
17143         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17144         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17145         return (uint64_t)ret_conv;
17146 }
17147
17148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17149         LDKDecodeError e_conv;
17150         e_conv.inner = (void*)(e & (~1));
17151         e_conv.is_owned = (e & 1) || (e == 0);
17152         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17153         e_conv = DecodeError_clone(&e_conv);
17154         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17155         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17156         return (uint64_t)ret_conv;
17157 }
17158
17159 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17160         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17161         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17162         return ret_val;
17163 }
17164
17165 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17166         if ((_res & 1) != 0) return;
17167         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17168         CHECK_ACCESS(_res_ptr);
17169         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17170         FREE((void*)_res);
17171         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17172 }
17173
17174 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17175         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17176         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17177         return (uint64_t)ret_conv;
17178 }
17179 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17180         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17181         int64_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17182         return ret_val;
17183 }
17184
17185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17186         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17187         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17188         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17189         return (uint64_t)ret_conv;
17190 }
17191
17192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17193         LDKCVec_UpdateAddHTLCZ _res_constr;
17194         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17195         if (_res_constr.datalen > 0)
17196                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17197         else
17198                 _res_constr.data = NULL;
17199         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17200         for (size_t p = 0; p < _res_constr.datalen; p++) {
17201                 int64_t _res_conv_15 = _res_vals[p];
17202                 LDKUpdateAddHTLC _res_conv_15_conv;
17203                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17204                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17205                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17206                 _res_constr.data[p] = _res_conv_15_conv;
17207         }
17208         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17209         CVec_UpdateAddHTLCZ_free(_res_constr);
17210 }
17211
17212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17213         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17214         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17215         if (_res_constr.datalen > 0)
17216                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17217         else
17218                 _res_constr.data = NULL;
17219         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17220         for (size_t t = 0; t < _res_constr.datalen; t++) {
17221                 int64_t _res_conv_19 = _res_vals[t];
17222                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17223                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17224                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17225                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17226                 _res_constr.data[t] = _res_conv_19_conv;
17227         }
17228         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17229         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17230 }
17231
17232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17233         LDKCVec_UpdateFailHTLCZ _res_constr;
17234         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17235         if (_res_constr.datalen > 0)
17236                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17237         else
17238                 _res_constr.data = NULL;
17239         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17240         for (size_t q = 0; q < _res_constr.datalen; q++) {
17241                 int64_t _res_conv_16 = _res_vals[q];
17242                 LDKUpdateFailHTLC _res_conv_16_conv;
17243                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17244                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17245                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17246                 _res_constr.data[q] = _res_conv_16_conv;
17247         }
17248         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17249         CVec_UpdateFailHTLCZ_free(_res_constr);
17250 }
17251
17252 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17253         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17254         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17255         if (_res_constr.datalen > 0)
17256                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17257         else
17258                 _res_constr.data = NULL;
17259         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17260         for (size_t z = 0; z < _res_constr.datalen; z++) {
17261                 int64_t _res_conv_25 = _res_vals[z];
17262                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17263                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17264                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17265                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17266                 _res_constr.data[z] = _res_conv_25_conv;
17267         }
17268         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17269         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17270 }
17271
17272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17273         LDKAcceptChannel o_conv;
17274         o_conv.inner = (void*)(o & (~1));
17275         o_conv.is_owned = (o & 1) || (o == 0);
17276         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17277         o_conv = AcceptChannel_clone(&o_conv);
17278         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17279         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17280         return (uint64_t)ret_conv;
17281 }
17282
17283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17284         LDKDecodeError e_conv;
17285         e_conv.inner = (void*)(e & (~1));
17286         e_conv.is_owned = (e & 1) || (e == 0);
17287         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17288         e_conv = DecodeError_clone(&e_conv);
17289         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17290         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17291         return (uint64_t)ret_conv;
17292 }
17293
17294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17295         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17296         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17297         return ret_val;
17298 }
17299
17300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17301         if ((_res & 1) != 0) return;
17302         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17303         CHECK_ACCESS(_res_ptr);
17304         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17305         FREE((void*)_res);
17306         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17307 }
17308
17309 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17310         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17311         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17312         return (uint64_t)ret_conv;
17313 }
17314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17315         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17316         int64_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17317         return ret_val;
17318 }
17319
17320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17321         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17322         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17323         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17324         return (uint64_t)ret_conv;
17325 }
17326
17327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17328         LDKAnnouncementSignatures o_conv;
17329         o_conv.inner = (void*)(o & (~1));
17330         o_conv.is_owned = (o & 1) || (o == 0);
17331         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17332         o_conv = AnnouncementSignatures_clone(&o_conv);
17333         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17334         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17335         return (uint64_t)ret_conv;
17336 }
17337
17338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17339         LDKDecodeError e_conv;
17340         e_conv.inner = (void*)(e & (~1));
17341         e_conv.is_owned = (e & 1) || (e == 0);
17342         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17343         e_conv = DecodeError_clone(&e_conv);
17344         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17345         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17346         return (uint64_t)ret_conv;
17347 }
17348
17349 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17350         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17351         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17352         return ret_val;
17353 }
17354
17355 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17356         if ((_res & 1) != 0) return;
17357         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17358         CHECK_ACCESS(_res_ptr);
17359         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17360         FREE((void*)_res);
17361         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17362 }
17363
17364 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17365         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17366         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17367         return (uint64_t)ret_conv;
17368 }
17369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17370         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17371         int64_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17372         return ret_val;
17373 }
17374
17375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17376         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17377         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17378         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17379         return (uint64_t)ret_conv;
17380 }
17381
17382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17383         LDKChannelReestablish o_conv;
17384         o_conv.inner = (void*)(o & (~1));
17385         o_conv.is_owned = (o & 1) || (o == 0);
17386         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17387         o_conv = ChannelReestablish_clone(&o_conv);
17388         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17389         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17390         return (uint64_t)ret_conv;
17391 }
17392
17393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17394         LDKDecodeError e_conv;
17395         e_conv.inner = (void*)(e & (~1));
17396         e_conv.is_owned = (e & 1) || (e == 0);
17397         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17398         e_conv = DecodeError_clone(&e_conv);
17399         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17400         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17401         return (uint64_t)ret_conv;
17402 }
17403
17404 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17405         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17406         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17407         return ret_val;
17408 }
17409
17410 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17411         if ((_res & 1) != 0) return;
17412         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17413         CHECK_ACCESS(_res_ptr);
17414         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17415         FREE((void*)_res);
17416         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17417 }
17418
17419 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17420         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17421         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17422         return (uint64_t)ret_conv;
17423 }
17424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17425         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17426         int64_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17427         return ret_val;
17428 }
17429
17430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17431         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17432         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17433         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17434         return (uint64_t)ret_conv;
17435 }
17436
17437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17438         LDKClosingSigned o_conv;
17439         o_conv.inner = (void*)(o & (~1));
17440         o_conv.is_owned = (o & 1) || (o == 0);
17441         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17442         o_conv = ClosingSigned_clone(&o_conv);
17443         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17444         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17445         return (uint64_t)ret_conv;
17446 }
17447
17448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17449         LDKDecodeError e_conv;
17450         e_conv.inner = (void*)(e & (~1));
17451         e_conv.is_owned = (e & 1) || (e == 0);
17452         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17453         e_conv = DecodeError_clone(&e_conv);
17454         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17455         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17456         return (uint64_t)ret_conv;
17457 }
17458
17459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17460         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17461         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17462         return ret_val;
17463 }
17464
17465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17466         if ((_res & 1) != 0) return;
17467         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17468         CHECK_ACCESS(_res_ptr);
17469         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17470         FREE((void*)_res);
17471         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17472 }
17473
17474 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17475         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17476         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17477         return (uint64_t)ret_conv;
17478 }
17479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17480         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17481         int64_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17482         return ret_val;
17483 }
17484
17485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17486         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17487         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17488         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17489         return (uint64_t)ret_conv;
17490 }
17491
17492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17493         LDKClosingSignedFeeRange o_conv;
17494         o_conv.inner = (void*)(o & (~1));
17495         o_conv.is_owned = (o & 1) || (o == 0);
17496         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17497         o_conv = ClosingSignedFeeRange_clone(&o_conv);
17498         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17499         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17500         return (uint64_t)ret_conv;
17501 }
17502
17503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17504         LDKDecodeError e_conv;
17505         e_conv.inner = (void*)(e & (~1));
17506         e_conv.is_owned = (e & 1) || (e == 0);
17507         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17508         e_conv = DecodeError_clone(&e_conv);
17509         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17510         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17511         return (uint64_t)ret_conv;
17512 }
17513
17514 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17515         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17516         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17517         return ret_val;
17518 }
17519
17520 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17521         if ((_res & 1) != 0) return;
17522         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17523         CHECK_ACCESS(_res_ptr);
17524         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17525         FREE((void*)_res);
17526         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17527 }
17528
17529 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17530         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17531         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17532         return (uint64_t)ret_conv;
17533 }
17534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17535         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17536         int64_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17537         return ret_val;
17538 }
17539
17540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17541         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17542         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17543         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17544         return (uint64_t)ret_conv;
17545 }
17546
17547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17548         LDKCommitmentSigned o_conv;
17549         o_conv.inner = (void*)(o & (~1));
17550         o_conv.is_owned = (o & 1) || (o == 0);
17551         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17552         o_conv = CommitmentSigned_clone(&o_conv);
17553         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17554         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17555         return (uint64_t)ret_conv;
17556 }
17557
17558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17559         LDKDecodeError e_conv;
17560         e_conv.inner = (void*)(e & (~1));
17561         e_conv.is_owned = (e & 1) || (e == 0);
17562         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17563         e_conv = DecodeError_clone(&e_conv);
17564         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17565         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17566         return (uint64_t)ret_conv;
17567 }
17568
17569 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17570         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17571         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17572         return ret_val;
17573 }
17574
17575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17576         if ((_res & 1) != 0) return;
17577         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17578         CHECK_ACCESS(_res_ptr);
17579         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17580         FREE((void*)_res);
17581         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17582 }
17583
17584 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17585         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17586         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17587         return (uint64_t)ret_conv;
17588 }
17589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17590         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17591         int64_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17592         return ret_val;
17593 }
17594
17595 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17596         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17597         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17598         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17599         return (uint64_t)ret_conv;
17600 }
17601
17602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17603         LDKFundingCreated o_conv;
17604         o_conv.inner = (void*)(o & (~1));
17605         o_conv.is_owned = (o & 1) || (o == 0);
17606         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17607         o_conv = FundingCreated_clone(&o_conv);
17608         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17609         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17610         return (uint64_t)ret_conv;
17611 }
17612
17613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17614         LDKDecodeError e_conv;
17615         e_conv.inner = (void*)(e & (~1));
17616         e_conv.is_owned = (e & 1) || (e == 0);
17617         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17618         e_conv = DecodeError_clone(&e_conv);
17619         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17620         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17621         return (uint64_t)ret_conv;
17622 }
17623
17624 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17625         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17626         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17627         return ret_val;
17628 }
17629
17630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17631         if ((_res & 1) != 0) return;
17632         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17633         CHECK_ACCESS(_res_ptr);
17634         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17635         FREE((void*)_res);
17636         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17637 }
17638
17639 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17640         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17641         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17642         return (uint64_t)ret_conv;
17643 }
17644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17645         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17646         int64_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17647         return ret_val;
17648 }
17649
17650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17651         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17652         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17653         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17654         return (uint64_t)ret_conv;
17655 }
17656
17657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17658         LDKFundingSigned o_conv;
17659         o_conv.inner = (void*)(o & (~1));
17660         o_conv.is_owned = (o & 1) || (o == 0);
17661         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17662         o_conv = FundingSigned_clone(&o_conv);
17663         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17664         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17665         return (uint64_t)ret_conv;
17666 }
17667
17668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17669         LDKDecodeError e_conv;
17670         e_conv.inner = (void*)(e & (~1));
17671         e_conv.is_owned = (e & 1) || (e == 0);
17672         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17673         e_conv = DecodeError_clone(&e_conv);
17674         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17675         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17676         return (uint64_t)ret_conv;
17677 }
17678
17679 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17680         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17681         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17682         return ret_val;
17683 }
17684
17685 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17686         if ((_res & 1) != 0) return;
17687         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17688         CHECK_ACCESS(_res_ptr);
17689         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17690         FREE((void*)_res);
17691         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17692 }
17693
17694 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17695         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17696         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17697         return (uint64_t)ret_conv;
17698 }
17699 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17700         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17701         int64_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17702         return ret_val;
17703 }
17704
17705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17706         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17707         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17708         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17709         return (uint64_t)ret_conv;
17710 }
17711
17712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17713         LDKFundingLocked o_conv;
17714         o_conv.inner = (void*)(o & (~1));
17715         o_conv.is_owned = (o & 1) || (o == 0);
17716         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17717         o_conv = FundingLocked_clone(&o_conv);
17718         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17719         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17720         return (uint64_t)ret_conv;
17721 }
17722
17723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17724         LDKDecodeError e_conv;
17725         e_conv.inner = (void*)(e & (~1));
17726         e_conv.is_owned = (e & 1) || (e == 0);
17727         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17728         e_conv = DecodeError_clone(&e_conv);
17729         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17730         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17731         return (uint64_t)ret_conv;
17732 }
17733
17734 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17735         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17736         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17737         return ret_val;
17738 }
17739
17740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17741         if ((_res & 1) != 0) return;
17742         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17743         CHECK_ACCESS(_res_ptr);
17744         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17745         FREE((void*)_res);
17746         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17747 }
17748
17749 static inline uint64_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17750         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17751         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17752         return (uint64_t)ret_conv;
17753 }
17754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17755         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17756         int64_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17757         return ret_val;
17758 }
17759
17760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17761         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17762         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17763         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17764         return (uint64_t)ret_conv;
17765 }
17766
17767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17768         LDKInit o_conv;
17769         o_conv.inner = (void*)(o & (~1));
17770         o_conv.is_owned = (o & 1) || (o == 0);
17771         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17772         o_conv = Init_clone(&o_conv);
17773         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17774         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17775         return (uint64_t)ret_conv;
17776 }
17777
17778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17779         LDKDecodeError e_conv;
17780         e_conv.inner = (void*)(e & (~1));
17781         e_conv.is_owned = (e & 1) || (e == 0);
17782         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17783         e_conv = DecodeError_clone(&e_conv);
17784         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17785         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
17786         return (uint64_t)ret_conv;
17787 }
17788
17789 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17790         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
17791         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
17792         return ret_val;
17793 }
17794
17795 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17796         if ((_res & 1) != 0) return;
17797         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17798         CHECK_ACCESS(_res_ptr);
17799         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
17800         FREE((void*)_res);
17801         CResult_InitDecodeErrorZ_free(_res_conv);
17802 }
17803
17804 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
17805         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17806         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
17807         return (uint64_t)ret_conv;
17808 }
17809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17810         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
17811         int64_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
17812         return ret_val;
17813 }
17814
17815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17816         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
17817         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17818         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
17819         return (uint64_t)ret_conv;
17820 }
17821
17822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17823         LDKOpenChannel o_conv;
17824         o_conv.inner = (void*)(o & (~1));
17825         o_conv.is_owned = (o & 1) || (o == 0);
17826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17827         o_conv = OpenChannel_clone(&o_conv);
17828         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17829         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
17830         return (uint64_t)ret_conv;
17831 }
17832
17833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17834         LDKDecodeError e_conv;
17835         e_conv.inner = (void*)(e & (~1));
17836         e_conv.is_owned = (e & 1) || (e == 0);
17837         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17838         e_conv = DecodeError_clone(&e_conv);
17839         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17840         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
17841         return (uint64_t)ret_conv;
17842 }
17843
17844 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17845         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
17846         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
17847         return ret_val;
17848 }
17849
17850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17851         if ((_res & 1) != 0) return;
17852         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17853         CHECK_ACCESS(_res_ptr);
17854         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
17855         FREE((void*)_res);
17856         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
17857 }
17858
17859 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
17860         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17861         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
17862         return (uint64_t)ret_conv;
17863 }
17864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17865         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
17866         int64_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
17867         return ret_val;
17868 }
17869
17870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17871         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
17872         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17873         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
17874         return (uint64_t)ret_conv;
17875 }
17876
17877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17878         LDKRevokeAndACK o_conv;
17879         o_conv.inner = (void*)(o & (~1));
17880         o_conv.is_owned = (o & 1) || (o == 0);
17881         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17882         o_conv = RevokeAndACK_clone(&o_conv);
17883         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17884         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
17885         return (uint64_t)ret_conv;
17886 }
17887
17888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17889         LDKDecodeError e_conv;
17890         e_conv.inner = (void*)(e & (~1));
17891         e_conv.is_owned = (e & 1) || (e == 0);
17892         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17893         e_conv = DecodeError_clone(&e_conv);
17894         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17895         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
17896         return (uint64_t)ret_conv;
17897 }
17898
17899 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17900         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
17901         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
17902         return ret_val;
17903 }
17904
17905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17906         if ((_res & 1) != 0) return;
17907         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17908         CHECK_ACCESS(_res_ptr);
17909         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
17910         FREE((void*)_res);
17911         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
17912 }
17913
17914 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
17915         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17916         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
17917         return (uint64_t)ret_conv;
17918 }
17919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17920         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
17921         int64_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
17922         return ret_val;
17923 }
17924
17925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17926         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
17927         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17928         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
17929         return (uint64_t)ret_conv;
17930 }
17931
17932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17933         LDKShutdown o_conv;
17934         o_conv.inner = (void*)(o & (~1));
17935         o_conv.is_owned = (o & 1) || (o == 0);
17936         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17937         o_conv = Shutdown_clone(&o_conv);
17938         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17939         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
17940         return (uint64_t)ret_conv;
17941 }
17942
17943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17944         LDKDecodeError e_conv;
17945         e_conv.inner = (void*)(e & (~1));
17946         e_conv.is_owned = (e & 1) || (e == 0);
17947         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17948         e_conv = DecodeError_clone(&e_conv);
17949         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17950         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
17951         return (uint64_t)ret_conv;
17952 }
17953
17954 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17955         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
17956         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
17957         return ret_val;
17958 }
17959
17960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17961         if ((_res & 1) != 0) return;
17962         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17963         CHECK_ACCESS(_res_ptr);
17964         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
17965         FREE((void*)_res);
17966         CResult_ShutdownDecodeErrorZ_free(_res_conv);
17967 }
17968
17969 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
17970         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17971         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
17972         return (uint64_t)ret_conv;
17973 }
17974 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17975         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
17976         int64_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
17977         return ret_val;
17978 }
17979
17980 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17981         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
17982         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17983         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
17984         return (uint64_t)ret_conv;
17985 }
17986
17987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17988         LDKUpdateFailHTLC o_conv;
17989         o_conv.inner = (void*)(o & (~1));
17990         o_conv.is_owned = (o & 1) || (o == 0);
17991         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17992         o_conv = UpdateFailHTLC_clone(&o_conv);
17993         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17994         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
17995         return (uint64_t)ret_conv;
17996 }
17997
17998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17999         LDKDecodeError e_conv;
18000         e_conv.inner = (void*)(e & (~1));
18001         e_conv.is_owned = (e & 1) || (e == 0);
18002         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18003         e_conv = DecodeError_clone(&e_conv);
18004         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18005         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18006         return (uint64_t)ret_conv;
18007 }
18008
18009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18010         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18011         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18012         return ret_val;
18013 }
18014
18015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18016         if ((_res & 1) != 0) return;
18017         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18018         CHECK_ACCESS(_res_ptr);
18019         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18020         FREE((void*)_res);
18021         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18022 }
18023
18024 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18025         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18026         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18027         return (uint64_t)ret_conv;
18028 }
18029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18030         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18031         int64_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18032         return ret_val;
18033 }
18034
18035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18036         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18037         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18038         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18039         return (uint64_t)ret_conv;
18040 }
18041
18042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18043         LDKUpdateFailMalformedHTLC o_conv;
18044         o_conv.inner = (void*)(o & (~1));
18045         o_conv.is_owned = (o & 1) || (o == 0);
18046         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18047         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
18048         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18049         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18050         return (uint64_t)ret_conv;
18051 }
18052
18053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18054         LDKDecodeError e_conv;
18055         e_conv.inner = (void*)(e & (~1));
18056         e_conv.is_owned = (e & 1) || (e == 0);
18057         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18058         e_conv = DecodeError_clone(&e_conv);
18059         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18060         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18061         return (uint64_t)ret_conv;
18062 }
18063
18064 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18065         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18066         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18067         return ret_val;
18068 }
18069
18070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18071         if ((_res & 1) != 0) return;
18072         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18073         CHECK_ACCESS(_res_ptr);
18074         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18075         FREE((void*)_res);
18076         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18077 }
18078
18079 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18080         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18081         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18082         return (uint64_t)ret_conv;
18083 }
18084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18085         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18086         int64_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18087         return ret_val;
18088 }
18089
18090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18091         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18092         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18093         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18094         return (uint64_t)ret_conv;
18095 }
18096
18097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18098         LDKUpdateFee o_conv;
18099         o_conv.inner = (void*)(o & (~1));
18100         o_conv.is_owned = (o & 1) || (o == 0);
18101         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18102         o_conv = UpdateFee_clone(&o_conv);
18103         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18104         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18105         return (uint64_t)ret_conv;
18106 }
18107
18108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18109         LDKDecodeError e_conv;
18110         e_conv.inner = (void*)(e & (~1));
18111         e_conv.is_owned = (e & 1) || (e == 0);
18112         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18113         e_conv = DecodeError_clone(&e_conv);
18114         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18115         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18116         return (uint64_t)ret_conv;
18117 }
18118
18119 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18120         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18121         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18122         return ret_val;
18123 }
18124
18125 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18126         if ((_res & 1) != 0) return;
18127         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18128         CHECK_ACCESS(_res_ptr);
18129         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18130         FREE((void*)_res);
18131         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18132 }
18133
18134 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18135         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18136         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18137         return (uint64_t)ret_conv;
18138 }
18139 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18140         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18141         int64_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18142         return ret_val;
18143 }
18144
18145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18146         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18147         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18148         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18149         return (uint64_t)ret_conv;
18150 }
18151
18152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18153         LDKUpdateFulfillHTLC o_conv;
18154         o_conv.inner = (void*)(o & (~1));
18155         o_conv.is_owned = (o & 1) || (o == 0);
18156         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18157         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18158         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18159         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18160         return (uint64_t)ret_conv;
18161 }
18162
18163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18164         LDKDecodeError e_conv;
18165         e_conv.inner = (void*)(e & (~1));
18166         e_conv.is_owned = (e & 1) || (e == 0);
18167         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18168         e_conv = DecodeError_clone(&e_conv);
18169         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18170         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18171         return (uint64_t)ret_conv;
18172 }
18173
18174 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18175         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18176         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18177         return ret_val;
18178 }
18179
18180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18181         if ((_res & 1) != 0) return;
18182         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18183         CHECK_ACCESS(_res_ptr);
18184         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18185         FREE((void*)_res);
18186         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18187 }
18188
18189 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18190         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18191         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18192         return (uint64_t)ret_conv;
18193 }
18194 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18195         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18196         int64_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18197         return ret_val;
18198 }
18199
18200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18201         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18202         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18203         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18204         return (uint64_t)ret_conv;
18205 }
18206
18207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18208         LDKUpdateAddHTLC o_conv;
18209         o_conv.inner = (void*)(o & (~1));
18210         o_conv.is_owned = (o & 1) || (o == 0);
18211         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18212         o_conv = UpdateAddHTLC_clone(&o_conv);
18213         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18214         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18215         return (uint64_t)ret_conv;
18216 }
18217
18218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18219         LDKDecodeError e_conv;
18220         e_conv.inner = (void*)(e & (~1));
18221         e_conv.is_owned = (e & 1) || (e == 0);
18222         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18223         e_conv = DecodeError_clone(&e_conv);
18224         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18225         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18226         return (uint64_t)ret_conv;
18227 }
18228
18229 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18230         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18231         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18232         return ret_val;
18233 }
18234
18235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18236         if ((_res & 1) != 0) return;
18237         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18238         CHECK_ACCESS(_res_ptr);
18239         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18240         FREE((void*)_res);
18241         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18242 }
18243
18244 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18245         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18246         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18247         return (uint64_t)ret_conv;
18248 }
18249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18250         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18251         int64_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18252         return ret_val;
18253 }
18254
18255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18256         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18257         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18258         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18259         return (uint64_t)ret_conv;
18260 }
18261
18262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18263         LDKPing o_conv;
18264         o_conv.inner = (void*)(o & (~1));
18265         o_conv.is_owned = (o & 1) || (o == 0);
18266         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18267         o_conv = Ping_clone(&o_conv);
18268         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18269         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18270         return (uint64_t)ret_conv;
18271 }
18272
18273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18274         LDKDecodeError e_conv;
18275         e_conv.inner = (void*)(e & (~1));
18276         e_conv.is_owned = (e & 1) || (e == 0);
18277         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18278         e_conv = DecodeError_clone(&e_conv);
18279         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18280         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18281         return (uint64_t)ret_conv;
18282 }
18283
18284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18285         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18286         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
18287         return ret_val;
18288 }
18289
18290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18291         if ((_res & 1) != 0) return;
18292         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18293         CHECK_ACCESS(_res_ptr);
18294         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18295         FREE((void*)_res);
18296         CResult_PingDecodeErrorZ_free(_res_conv);
18297 }
18298
18299 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18300         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18301         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18302         return (uint64_t)ret_conv;
18303 }
18304 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18305         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18306         int64_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18307         return ret_val;
18308 }
18309
18310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18311         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18312         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18313         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18314         return (uint64_t)ret_conv;
18315 }
18316
18317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18318         LDKPong o_conv;
18319         o_conv.inner = (void*)(o & (~1));
18320         o_conv.is_owned = (o & 1) || (o == 0);
18321         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18322         o_conv = Pong_clone(&o_conv);
18323         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18324         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18325         return (uint64_t)ret_conv;
18326 }
18327
18328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18329         LDKDecodeError e_conv;
18330         e_conv.inner = (void*)(e & (~1));
18331         e_conv.is_owned = (e & 1) || (e == 0);
18332         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18333         e_conv = DecodeError_clone(&e_conv);
18334         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18335         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18336         return (uint64_t)ret_conv;
18337 }
18338
18339 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18340         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18341         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
18342         return ret_val;
18343 }
18344
18345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18346         if ((_res & 1) != 0) return;
18347         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18348         CHECK_ACCESS(_res_ptr);
18349         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18350         FREE((void*)_res);
18351         CResult_PongDecodeErrorZ_free(_res_conv);
18352 }
18353
18354 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18355         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18356         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18357         return (uint64_t)ret_conv;
18358 }
18359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18360         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18361         int64_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18362         return ret_val;
18363 }
18364
18365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18366         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18367         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18368         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18369         return (uint64_t)ret_conv;
18370 }
18371
18372 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18373         LDKUnsignedChannelAnnouncement o_conv;
18374         o_conv.inner = (void*)(o & (~1));
18375         o_conv.is_owned = (o & 1) || (o == 0);
18376         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18377         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
18378         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18379         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18380         return (uint64_t)ret_conv;
18381 }
18382
18383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18384         LDKDecodeError e_conv;
18385         e_conv.inner = (void*)(e & (~1));
18386         e_conv.is_owned = (e & 1) || (e == 0);
18387         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18388         e_conv = DecodeError_clone(&e_conv);
18389         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18390         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18391         return (uint64_t)ret_conv;
18392 }
18393
18394 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18395         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18396         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18397         return ret_val;
18398 }
18399
18400 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18401         if ((_res & 1) != 0) return;
18402         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18403         CHECK_ACCESS(_res_ptr);
18404         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18405         FREE((void*)_res);
18406         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18407 }
18408
18409 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18410         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18411         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18412         return (uint64_t)ret_conv;
18413 }
18414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18415         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18416         int64_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18417         return ret_val;
18418 }
18419
18420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18421         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18422         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18423         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18424         return (uint64_t)ret_conv;
18425 }
18426
18427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18428         LDKChannelAnnouncement o_conv;
18429         o_conv.inner = (void*)(o & (~1));
18430         o_conv.is_owned = (o & 1) || (o == 0);
18431         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18432         o_conv = ChannelAnnouncement_clone(&o_conv);
18433         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18434         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18435         return (uint64_t)ret_conv;
18436 }
18437
18438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18439         LDKDecodeError e_conv;
18440         e_conv.inner = (void*)(e & (~1));
18441         e_conv.is_owned = (e & 1) || (e == 0);
18442         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18443         e_conv = DecodeError_clone(&e_conv);
18444         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18445         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18446         return (uint64_t)ret_conv;
18447 }
18448
18449 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18450         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18451         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18452         return ret_val;
18453 }
18454
18455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18456         if ((_res & 1) != 0) return;
18457         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18458         CHECK_ACCESS(_res_ptr);
18459         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18460         FREE((void*)_res);
18461         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18462 }
18463
18464 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18465         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18466         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18467         return (uint64_t)ret_conv;
18468 }
18469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18470         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18471         int64_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18472         return ret_val;
18473 }
18474
18475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18476         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18477         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18478         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18479         return (uint64_t)ret_conv;
18480 }
18481
18482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18483         LDKUnsignedChannelUpdate o_conv;
18484         o_conv.inner = (void*)(o & (~1));
18485         o_conv.is_owned = (o & 1) || (o == 0);
18486         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18487         o_conv = UnsignedChannelUpdate_clone(&o_conv);
18488         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18489         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18490         return (uint64_t)ret_conv;
18491 }
18492
18493 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18494         LDKDecodeError e_conv;
18495         e_conv.inner = (void*)(e & (~1));
18496         e_conv.is_owned = (e & 1) || (e == 0);
18497         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18498         e_conv = DecodeError_clone(&e_conv);
18499         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18500         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18501         return (uint64_t)ret_conv;
18502 }
18503
18504 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18505         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18506         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18507         return ret_val;
18508 }
18509
18510 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18511         if ((_res & 1) != 0) return;
18512         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18513         CHECK_ACCESS(_res_ptr);
18514         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18515         FREE((void*)_res);
18516         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18517 }
18518
18519 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18520         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18521         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18522         return (uint64_t)ret_conv;
18523 }
18524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18525         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18526         int64_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18527         return ret_val;
18528 }
18529
18530 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18531         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18532         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18533         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18534         return (uint64_t)ret_conv;
18535 }
18536
18537 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18538         LDKChannelUpdate o_conv;
18539         o_conv.inner = (void*)(o & (~1));
18540         o_conv.is_owned = (o & 1) || (o == 0);
18541         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18542         o_conv = ChannelUpdate_clone(&o_conv);
18543         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18544         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18545         return (uint64_t)ret_conv;
18546 }
18547
18548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18549         LDKDecodeError e_conv;
18550         e_conv.inner = (void*)(e & (~1));
18551         e_conv.is_owned = (e & 1) || (e == 0);
18552         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18553         e_conv = DecodeError_clone(&e_conv);
18554         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18555         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18556         return (uint64_t)ret_conv;
18557 }
18558
18559 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18560         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18561         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18562         return ret_val;
18563 }
18564
18565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18566         if ((_res & 1) != 0) return;
18567         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18568         CHECK_ACCESS(_res_ptr);
18569         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18570         FREE((void*)_res);
18571         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18572 }
18573
18574 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18575         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18576         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18577         return (uint64_t)ret_conv;
18578 }
18579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18580         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18581         int64_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18582         return ret_val;
18583 }
18584
18585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18586         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18587         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18588         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18589         return (uint64_t)ret_conv;
18590 }
18591
18592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18593         LDKErrorMessage o_conv;
18594         o_conv.inner = (void*)(o & (~1));
18595         o_conv.is_owned = (o & 1) || (o == 0);
18596         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18597         o_conv = ErrorMessage_clone(&o_conv);
18598         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18599         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18600         return (uint64_t)ret_conv;
18601 }
18602
18603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18604         LDKDecodeError e_conv;
18605         e_conv.inner = (void*)(e & (~1));
18606         e_conv.is_owned = (e & 1) || (e == 0);
18607         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18608         e_conv = DecodeError_clone(&e_conv);
18609         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18610         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18611         return (uint64_t)ret_conv;
18612 }
18613
18614 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18615         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18616         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18617         return ret_val;
18618 }
18619
18620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18621         if ((_res & 1) != 0) return;
18622         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18623         CHECK_ACCESS(_res_ptr);
18624         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18625         FREE((void*)_res);
18626         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18627 }
18628
18629 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18630         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18631         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18632         return (uint64_t)ret_conv;
18633 }
18634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18635         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18636         int64_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18637         return ret_val;
18638 }
18639
18640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18641         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18642         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18643         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18644         return (uint64_t)ret_conv;
18645 }
18646
18647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18648         LDKUnsignedNodeAnnouncement o_conv;
18649         o_conv.inner = (void*)(o & (~1));
18650         o_conv.is_owned = (o & 1) || (o == 0);
18651         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18652         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
18653         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18654         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18655         return (uint64_t)ret_conv;
18656 }
18657
18658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18659         LDKDecodeError e_conv;
18660         e_conv.inner = (void*)(e & (~1));
18661         e_conv.is_owned = (e & 1) || (e == 0);
18662         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18663         e_conv = DecodeError_clone(&e_conv);
18664         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18665         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18666         return (uint64_t)ret_conv;
18667 }
18668
18669 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18670         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18671         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18672         return ret_val;
18673 }
18674
18675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18676         if ((_res & 1) != 0) return;
18677         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18678         CHECK_ACCESS(_res_ptr);
18679         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18680         FREE((void*)_res);
18681         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18682 }
18683
18684 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18685         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18686         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18687         return (uint64_t)ret_conv;
18688 }
18689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18690         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18691         int64_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18692         return ret_val;
18693 }
18694
18695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18696         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18697         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18698         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18699         return (uint64_t)ret_conv;
18700 }
18701
18702 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18703         LDKNodeAnnouncement o_conv;
18704         o_conv.inner = (void*)(o & (~1));
18705         o_conv.is_owned = (o & 1) || (o == 0);
18706         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18707         o_conv = NodeAnnouncement_clone(&o_conv);
18708         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18709         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18710         return (uint64_t)ret_conv;
18711 }
18712
18713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18714         LDKDecodeError e_conv;
18715         e_conv.inner = (void*)(e & (~1));
18716         e_conv.is_owned = (e & 1) || (e == 0);
18717         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18718         e_conv = DecodeError_clone(&e_conv);
18719         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18720         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18721         return (uint64_t)ret_conv;
18722 }
18723
18724 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18725         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18726         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18727         return ret_val;
18728 }
18729
18730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18731         if ((_res & 1) != 0) return;
18732         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18733         CHECK_ACCESS(_res_ptr);
18734         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
18735         FREE((void*)_res);
18736         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
18737 }
18738
18739 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18740         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18741         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
18742         return (uint64_t)ret_conv;
18743 }
18744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18745         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
18746         int64_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18747         return ret_val;
18748 }
18749
18750 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18751         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
18752         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18753         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
18754         return (uint64_t)ret_conv;
18755 }
18756
18757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18758         LDKQueryShortChannelIds o_conv;
18759         o_conv.inner = (void*)(o & (~1));
18760         o_conv.is_owned = (o & 1) || (o == 0);
18761         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18762         o_conv = QueryShortChannelIds_clone(&o_conv);
18763         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18764         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
18765         return (uint64_t)ret_conv;
18766 }
18767
18768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18769         LDKDecodeError e_conv;
18770         e_conv.inner = (void*)(e & (~1));
18771         e_conv.is_owned = (e & 1) || (e == 0);
18772         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18773         e_conv = DecodeError_clone(&e_conv);
18774         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18775         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
18776         return (uint64_t)ret_conv;
18777 }
18778
18779 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18780         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
18781         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
18782         return ret_val;
18783 }
18784
18785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18786         if ((_res & 1) != 0) return;
18787         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18788         CHECK_ACCESS(_res_ptr);
18789         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
18790         FREE((void*)_res);
18791         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
18792 }
18793
18794 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
18795         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18796         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
18797         return (uint64_t)ret_conv;
18798 }
18799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18800         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
18801         int64_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
18802         return ret_val;
18803 }
18804
18805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18806         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
18807         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18808         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
18809         return (uint64_t)ret_conv;
18810 }
18811
18812 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18813         LDKReplyShortChannelIdsEnd o_conv;
18814         o_conv.inner = (void*)(o & (~1));
18815         o_conv.is_owned = (o & 1) || (o == 0);
18816         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18817         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
18818         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18819         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
18820         return (uint64_t)ret_conv;
18821 }
18822
18823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18824         LDKDecodeError e_conv;
18825         e_conv.inner = (void*)(e & (~1));
18826         e_conv.is_owned = (e & 1) || (e == 0);
18827         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18828         e_conv = DecodeError_clone(&e_conv);
18829         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18830         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
18831         return (uint64_t)ret_conv;
18832 }
18833
18834 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18835         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
18836         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
18837         return ret_val;
18838 }
18839
18840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18841         if ((_res & 1) != 0) return;
18842         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18843         CHECK_ACCESS(_res_ptr);
18844         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
18845         FREE((void*)_res);
18846         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
18847 }
18848
18849 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
18850         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18851         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
18852         return (uint64_t)ret_conv;
18853 }
18854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18855         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
18856         int64_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
18857         return ret_val;
18858 }
18859
18860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18861         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
18862         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18863         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
18864         return (uint64_t)ret_conv;
18865 }
18866
18867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18868         LDKQueryChannelRange o_conv;
18869         o_conv.inner = (void*)(o & (~1));
18870         o_conv.is_owned = (o & 1) || (o == 0);
18871         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18872         o_conv = QueryChannelRange_clone(&o_conv);
18873         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18874         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
18875         return (uint64_t)ret_conv;
18876 }
18877
18878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18879         LDKDecodeError e_conv;
18880         e_conv.inner = (void*)(e & (~1));
18881         e_conv.is_owned = (e & 1) || (e == 0);
18882         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18883         e_conv = DecodeError_clone(&e_conv);
18884         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18885         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
18886         return (uint64_t)ret_conv;
18887 }
18888
18889 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18890         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
18891         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
18892         return ret_val;
18893 }
18894
18895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18896         if ((_res & 1) != 0) return;
18897         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18898         CHECK_ACCESS(_res_ptr);
18899         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
18900         FREE((void*)_res);
18901         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
18902 }
18903
18904 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
18905         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18906         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
18907         return (uint64_t)ret_conv;
18908 }
18909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18910         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
18911         int64_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
18912         return ret_val;
18913 }
18914
18915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18916         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
18917         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18918         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
18919         return (uint64_t)ret_conv;
18920 }
18921
18922 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18923         LDKReplyChannelRange o_conv;
18924         o_conv.inner = (void*)(o & (~1));
18925         o_conv.is_owned = (o & 1) || (o == 0);
18926         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18927         o_conv = ReplyChannelRange_clone(&o_conv);
18928         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18929         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
18930         return (uint64_t)ret_conv;
18931 }
18932
18933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18934         LDKDecodeError e_conv;
18935         e_conv.inner = (void*)(e & (~1));
18936         e_conv.is_owned = (e & 1) || (e == 0);
18937         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18938         e_conv = DecodeError_clone(&e_conv);
18939         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18940         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
18941         return (uint64_t)ret_conv;
18942 }
18943
18944 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18945         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
18946         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
18947         return ret_val;
18948 }
18949
18950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18951         if ((_res & 1) != 0) return;
18952         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18953         CHECK_ACCESS(_res_ptr);
18954         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
18955         FREE((void*)_res);
18956         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
18957 }
18958
18959 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
18960         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18961         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
18962         return (uint64_t)ret_conv;
18963 }
18964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18965         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
18966         int64_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
18967         return ret_val;
18968 }
18969
18970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18971         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
18972         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18973         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
18974         return (uint64_t)ret_conv;
18975 }
18976
18977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18978         LDKGossipTimestampFilter o_conv;
18979         o_conv.inner = (void*)(o & (~1));
18980         o_conv.is_owned = (o & 1) || (o == 0);
18981         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18982         o_conv = GossipTimestampFilter_clone(&o_conv);
18983         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18984         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
18985         return (uint64_t)ret_conv;
18986 }
18987
18988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18989         LDKDecodeError e_conv;
18990         e_conv.inner = (void*)(e & (~1));
18991         e_conv.is_owned = (e & 1) || (e == 0);
18992         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18993         e_conv = DecodeError_clone(&e_conv);
18994         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18995         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
18996         return (uint64_t)ret_conv;
18997 }
18998
18999 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19000         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19001         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19002         return ret_val;
19003 }
19004
19005 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19006         if ((_res & 1) != 0) return;
19007         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19008         CHECK_ACCESS(_res_ptr);
19009         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19010         FREE((void*)_res);
19011         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19012 }
19013
19014 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19015         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19016         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19017         return (uint64_t)ret_conv;
19018 }
19019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19020         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19021         int64_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19022         return ret_val;
19023 }
19024
19025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19026         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19027         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19028         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19029         return (uint64_t)ret_conv;
19030 }
19031
19032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19033         LDKInvoice o_conv;
19034         o_conv.inner = (void*)(o & (~1));
19035         o_conv.is_owned = (o & 1) || (o == 0);
19036         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19037         o_conv = Invoice_clone(&o_conv);
19038         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19039         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19040         return (uint64_t)ret_conv;
19041 }
19042
19043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19044         void* e_ptr = (void*)(((uint64_t)e) & ~1);
19045         CHECK_ACCESS(e_ptr);
19046         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19047         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
19048         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19049         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19050         return (uint64_t)ret_conv;
19051 }
19052
19053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19054         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19055         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19056         return ret_val;
19057 }
19058
19059 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19060         if ((_res & 1) != 0) return;
19061         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19062         CHECK_ACCESS(_res_ptr);
19063         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19064         FREE((void*)_res);
19065         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19066 }
19067
19068 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19069         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19070         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19071         return (uint64_t)ret_conv;
19072 }
19073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19074         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19075         int64_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19076         return ret_val;
19077 }
19078
19079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19080         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19081         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19082         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19083         return (uint64_t)ret_conv;
19084 }
19085
19086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19087         void* o_ptr = (void*)(((uint64_t)o) & ~1);
19088         CHECK_ACCESS(o_ptr);
19089         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19090         if (o_conv.free == LDKFilter_JCalls_free) {
19091                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19092                 LDKFilter_JCalls_cloned(&o_conv);
19093         }
19094         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19095         *ret_copy = COption_FilterZ_some(o_conv);
19096         uint64_t ret_ref = (uint64_t)ret_copy;
19097         return ret_ref;
19098 }
19099
19100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
19101         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19102         *ret_copy = COption_FilterZ_none();
19103         uint64_t ret_ref = (uint64_t)ret_copy;
19104         return ret_ref;
19105 }
19106
19107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19108         if ((_res & 1) != 0) return;
19109         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19110         CHECK_ACCESS(_res_ptr);
19111         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19112         FREE((void*)_res);
19113         COption_FilterZ_free(_res_conv);
19114 }
19115
19116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19117         LDKLockedChannelMonitor o_conv;
19118         o_conv.inner = (void*)(o & (~1));
19119         o_conv.is_owned = (o & 1) || (o == 0);
19120         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19121         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
19122         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19123         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19124         return (uint64_t)ret_conv;
19125 }
19126
19127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
19128         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19129         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19130         return (uint64_t)ret_conv;
19131 }
19132
19133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19134         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19135         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19136         return ret_val;
19137 }
19138
19139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19140         if ((_res & 1) != 0) return;
19141         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19142         CHECK_ACCESS(_res_ptr);
19143         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19144         FREE((void*)_res);
19145         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19146 }
19147
19148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19149         LDKCVec_OutPointZ _res_constr;
19150         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19151         if (_res_constr.datalen > 0)
19152                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19153         else
19154                 _res_constr.data = NULL;
19155         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19156         for (size_t k = 0; k < _res_constr.datalen; k++) {
19157                 int64_t _res_conv_10 = _res_vals[k];
19158                 LDKOutPoint _res_conv_10_conv;
19159                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19160                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19161                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19162                 _res_constr.data[k] = _res_conv_10_conv;
19163         }
19164         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19165         CVec_OutPointZ_free(_res_constr);
19166 }
19167
19168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19169         if ((this_ptr & 1) != 0) return;
19170         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19171         CHECK_ACCESS(this_ptr_ptr);
19172         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19173         FREE((void*)this_ptr);
19174         PaymentPurpose_free(this_ptr_conv);
19175 }
19176
19177 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19178         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19179         *ret_copy = PaymentPurpose_clone(arg);
19180 uint64_t ret_ref = (uint64_t)ret_copy;
19181         return ret_ref;
19182 }
19183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19184         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19185         int64_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
19186         return ret_val;
19187 }
19188
19189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19190         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19191         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19192         *ret_copy = PaymentPurpose_clone(orig_conv);
19193         uint64_t ret_ref = (uint64_t)ret_copy;
19194         return ret_ref;
19195 }
19196
19197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1invoice_1payment(JNIEnv *env, jclass clz, int8_tArray payment_preimage, int8_tArray payment_secret, int64_t user_payment_id) {
19198         LDKThirtyTwoBytes payment_preimage_ref;
19199         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
19200         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
19201         LDKThirtyTwoBytes payment_secret_ref;
19202         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
19203         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
19204         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19205         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
19206         uint64_t ret_ref = (uint64_t)ret_copy;
19207         return ret_ref;
19208 }
19209
19210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
19211         LDKThirtyTwoBytes a_ref;
19212         CHECK((*env)->GetArrayLength(env, a) == 32);
19213         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19214         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19215         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19216         uint64_t ret_ref = (uint64_t)ret_copy;
19217         return ret_ref;
19218 }
19219
19220 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19221         if ((this_ptr & 1) != 0) return;
19222         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19223         CHECK_ACCESS(this_ptr_ptr);
19224         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19225         FREE((void*)this_ptr);
19226         ClosureReason_free(this_ptr_conv);
19227 }
19228
19229 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19230         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19231         *ret_copy = ClosureReason_clone(arg);
19232 uint64_t ret_ref = (uint64_t)ret_copy;
19233         return ret_ref;
19234 }
19235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19236         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19237         int64_t ret_val = ClosureReason_clone_ptr(arg_conv);
19238         return ret_val;
19239 }
19240
19241 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19242         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19243         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19244         *ret_copy = ClosureReason_clone(orig_conv);
19245         uint64_t ret_ref = (uint64_t)ret_copy;
19246         return ret_ref;
19247 }
19248
19249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
19250         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
19251         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19252         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19253         uint64_t ret_ref = (uint64_t)ret_copy;
19254         return ret_ref;
19255 }
19256
19257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
19258         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19259         *ret_copy = ClosureReason_holder_force_closed();
19260         uint64_t ret_ref = (uint64_t)ret_copy;
19261         return ret_ref;
19262 }
19263
19264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
19265         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19266         *ret_copy = ClosureReason_cooperative_closure();
19267         uint64_t ret_ref = (uint64_t)ret_copy;
19268         return ret_ref;
19269 }
19270
19271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
19272         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19273         *ret_copy = ClosureReason_commitment_tx_confirmed();
19274         uint64_t ret_ref = (uint64_t)ret_copy;
19275         return ret_ref;
19276 }
19277
19278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
19279         LDKStr err_conv = java_to_owned_str(env, err);
19280         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19281         *ret_copy = ClosureReason_processing_error(err_conv);
19282         uint64_t ret_ref = (uint64_t)ret_copy;
19283         return ret_ref;
19284 }
19285
19286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
19287         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19288         *ret_copy = ClosureReason_disconnected_peer();
19289         uint64_t ret_ref = (uint64_t)ret_copy;
19290         return ret_ref;
19291 }
19292
19293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
19294         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19295         *ret_copy = ClosureReason_outdated_channel_manager();
19296         uint64_t ret_ref = (uint64_t)ret_copy;
19297         return ret_ref;
19298 }
19299
19300 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
19301         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19302         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19303         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19304         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19305         CVec_u8Z_free(ret_var);
19306         return ret_arr;
19307 }
19308
19309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19310         LDKu8slice ser_ref;
19311         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19312         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19313         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19314         *ret_conv = ClosureReason_read(ser_ref);
19315         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19316         return (uint64_t)ret_conv;
19317 }
19318
19319 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19320         if ((this_ptr & 1) != 0) return;
19321         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19322         CHECK_ACCESS(this_ptr_ptr);
19323         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19324         FREE((void*)this_ptr);
19325         Event_free(this_ptr_conv);
19326 }
19327
19328 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19329         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19330         *ret_copy = Event_clone(arg);
19331 uint64_t ret_ref = (uint64_t)ret_copy;
19332         return ret_ref;
19333 }
19334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19335         LDKEvent* arg_conv = (LDKEvent*)arg;
19336         int64_t ret_val = Event_clone_ptr(arg_conv);
19337         return ret_val;
19338 }
19339
19340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19341         LDKEvent* orig_conv = (LDKEvent*)orig;
19342         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19343         *ret_copy = Event_clone(orig_conv);
19344         uint64_t ret_ref = (uint64_t)ret_copy;
19345         return ret_ref;
19346 }
19347
19348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1funding_1generation_1ready(JNIEnv *env, jclass clz, int8_tArray temporary_channel_id, int64_t channel_value_satoshis, int8_tArray output_script, int64_t user_channel_id) {
19349         LDKThirtyTwoBytes temporary_channel_id_ref;
19350         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
19351         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
19352         LDKCVec_u8Z output_script_ref;
19353         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
19354         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19355         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
19356         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19357         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19358         uint64_t ret_ref = (uint64_t)ret_copy;
19359         return ret_ref;
19360 }
19361
19362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1received(JNIEnv *env, jclass clz, int8_tArray payment_hash, int64_t amt, int64_t purpose) {
19363         LDKThirtyTwoBytes payment_hash_ref;
19364         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19365         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19366         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
19367         CHECK_ACCESS(purpose_ptr);
19368         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19369         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
19370         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19371         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19372         uint64_t ret_ref = (uint64_t)ret_copy;
19373         return ret_ref;
19374 }
19375
19376 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) {
19377         LDKThirtyTwoBytes payment_id_ref;
19378         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
19379         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
19380         LDKThirtyTwoBytes payment_preimage_ref;
19381         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
19382         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
19383         LDKThirtyTwoBytes payment_hash_ref;
19384         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19385         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19386         void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
19387         CHECK_ACCESS(fee_paid_msat_ptr);
19388         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19389         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
19390         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19391         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19392         uint64_t ret_ref = (uint64_t)ret_copy;
19393         return ret_ref;
19394 }
19395
19396 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 rejected_by_dest, int64_t network_update, jboolean all_paths_failed, int64_tArray path, int64_t short_channel_id, int64_t retry) {
19397         LDKThirtyTwoBytes payment_id_ref;
19398         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
19399         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
19400         LDKThirtyTwoBytes payment_hash_ref;
19401         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19402         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19403         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
19404         CHECK_ACCESS(network_update_ptr);
19405         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19406         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
19407         LDKCVec_RouteHopZ path_constr;
19408         path_constr.datalen = (*env)->GetArrayLength(env, path);
19409         if (path_constr.datalen > 0)
19410                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19411         else
19412                 path_constr.data = NULL;
19413         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
19414         for (size_t k = 0; k < path_constr.datalen; k++) {
19415                 int64_t path_conv_10 = path_vals[k];
19416                 LDKRouteHop path_conv_10_conv;
19417                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19418                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19419                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19420                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19421                 path_constr.data[k] = path_conv_10_conv;
19422         }
19423         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
19424         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
19425         CHECK_ACCESS(short_channel_id_ptr);
19426         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19427         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
19428         LDKRouteParameters retry_conv;
19429         retry_conv.inner = (void*)(retry & (~1));
19430         retry_conv.is_owned = (retry & 1) || (retry == 0);
19431         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19432         retry_conv = RouteParameters_clone(&retry_conv);
19433         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19434         *ret_copy = Event_payment_path_failed(payment_id_ref, payment_hash_ref, rejected_by_dest, network_update_conv, all_paths_failed, path_constr, short_channel_id_conv, retry_conv);
19435         uint64_t ret_ref = (uint64_t)ret_copy;
19436         return ret_ref;
19437 }
19438
19439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
19440         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19441         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19442         uint64_t ret_ref = (uint64_t)ret_copy;
19443         return ret_ref;
19444 }
19445
19446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
19447         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19448         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
19449         if (outputs_constr.datalen > 0)
19450                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19451         else
19452                 outputs_constr.data = NULL;
19453         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
19454         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19455                 int64_t outputs_conv_27 = outputs_vals[b];
19456                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
19457                 CHECK_ACCESS(outputs_conv_27_ptr);
19458                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19459                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
19460                 outputs_constr.data[b] = outputs_conv_27_conv;
19461         }
19462         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
19463         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19464         *ret_copy = Event_spendable_outputs(outputs_constr);
19465         uint64_t ret_ref = (uint64_t)ret_copy;
19466         return ret_ref;
19467 }
19468
19469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1payment_1forwarded(JNIEnv *env, jclass clz, int64_t fee_earned_msat, jboolean claim_from_onchain_tx) {
19470         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
19471         CHECK_ACCESS(fee_earned_msat_ptr);
19472         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19473         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
19474         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19475         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19476         uint64_t ret_ref = (uint64_t)ret_copy;
19477         return ret_ref;
19478 }
19479
19480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1channel_1closed(JNIEnv *env, jclass clz, int8_tArray channel_id, int64_t user_channel_id, int64_t reason) {
19481         LDKThirtyTwoBytes channel_id_ref;
19482         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
19483         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
19484         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
19485         CHECK_ACCESS(reason_ptr);
19486         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19487         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
19488         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19489         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19490         uint64_t ret_ref = (uint64_t)ret_copy;
19491         return ret_ref;
19492 }
19493
19494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
19495         LDKThirtyTwoBytes channel_id_ref;
19496         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
19497         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
19498         LDKTransaction transaction_ref;
19499         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
19500         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19501         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
19502         transaction_ref.data_is_owned = true;
19503         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19504         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19505         uint64_t ret_ref = (uint64_t)ret_copy;
19506         return ret_ref;
19507 }
19508
19509 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
19510         LDKEvent* obj_conv = (LDKEvent*)obj;
19511         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19512         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19513         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19514         CVec_u8Z_free(ret_var);
19515         return ret_arr;
19516 }
19517
19518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19519         LDKu8slice ser_ref;
19520         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19521         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19522         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19523         *ret_conv = Event_read(ser_ref);
19524         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19525         return (uint64_t)ret_conv;
19526 }
19527
19528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19529         if ((this_ptr & 1) != 0) return;
19530         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19531         CHECK_ACCESS(this_ptr_ptr);
19532         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19533         FREE((void*)this_ptr);
19534         MessageSendEvent_free(this_ptr_conv);
19535 }
19536
19537 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19538         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19539         *ret_copy = MessageSendEvent_clone(arg);
19540 uint64_t ret_ref = (uint64_t)ret_copy;
19541         return ret_ref;
19542 }
19543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19544         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19545         int64_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
19546         return ret_val;
19547 }
19548
19549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19550         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19551         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19552         *ret_copy = MessageSendEvent_clone(orig_conv);
19553         uint64_t ret_ref = (uint64_t)ret_copy;
19554         return ret_ref;
19555 }
19556
19557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19558         LDKPublicKey node_id_ref;
19559         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19560         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19561         LDKAcceptChannel msg_conv;
19562         msg_conv.inner = (void*)(msg & (~1));
19563         msg_conv.is_owned = (msg & 1) || (msg == 0);
19564         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19565         msg_conv = AcceptChannel_clone(&msg_conv);
19566         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19567         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19568         uint64_t ret_ref = (uint64_t)ret_copy;
19569         return ret_ref;
19570 }
19571
19572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19573         LDKPublicKey node_id_ref;
19574         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19575         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19576         LDKOpenChannel msg_conv;
19577         msg_conv.inner = (void*)(msg & (~1));
19578         msg_conv.is_owned = (msg & 1) || (msg == 0);
19579         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19580         msg_conv = OpenChannel_clone(&msg_conv);
19581         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19582         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19583         uint64_t ret_ref = (uint64_t)ret_copy;
19584         return ret_ref;
19585 }
19586
19587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19588         LDKPublicKey node_id_ref;
19589         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19590         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19591         LDKFundingCreated msg_conv;
19592         msg_conv.inner = (void*)(msg & (~1));
19593         msg_conv.is_owned = (msg & 1) || (msg == 0);
19594         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19595         msg_conv = FundingCreated_clone(&msg_conv);
19596         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19597         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19598         uint64_t ret_ref = (uint64_t)ret_copy;
19599         return ret_ref;
19600 }
19601
19602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19603         LDKPublicKey node_id_ref;
19604         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19605         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19606         LDKFundingSigned msg_conv;
19607         msg_conv.inner = (void*)(msg & (~1));
19608         msg_conv.is_owned = (msg & 1) || (msg == 0);
19609         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19610         msg_conv = FundingSigned_clone(&msg_conv);
19611         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19612         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19613         uint64_t ret_ref = (uint64_t)ret_copy;
19614         return ret_ref;
19615 }
19616
19617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19618         LDKPublicKey node_id_ref;
19619         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19620         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19621         LDKFundingLocked msg_conv;
19622         msg_conv.inner = (void*)(msg & (~1));
19623         msg_conv.is_owned = (msg & 1) || (msg == 0);
19624         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19625         msg_conv = FundingLocked_clone(&msg_conv);
19626         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19627         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19628         uint64_t ret_ref = (uint64_t)ret_copy;
19629         return ret_ref;
19630 }
19631
19632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19633         LDKPublicKey node_id_ref;
19634         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19635         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19636         LDKAnnouncementSignatures msg_conv;
19637         msg_conv.inner = (void*)(msg & (~1));
19638         msg_conv.is_owned = (msg & 1) || (msg == 0);
19639         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19640         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19641         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19642         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19643         uint64_t ret_ref = (uint64_t)ret_copy;
19644         return ret_ref;
19645 }
19646
19647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
19648         LDKPublicKey node_id_ref;
19649         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19650         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19651         LDKCommitmentUpdate updates_conv;
19652         updates_conv.inner = (void*)(updates & (~1));
19653         updates_conv.is_owned = (updates & 1) || (updates == 0);
19654         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19655         updates_conv = CommitmentUpdate_clone(&updates_conv);
19656         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19657         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19658         uint64_t ret_ref = (uint64_t)ret_copy;
19659         return ret_ref;
19660 }
19661
19662 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) {
19663         LDKPublicKey node_id_ref;
19664         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19665         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19666         LDKRevokeAndACK msg_conv;
19667         msg_conv.inner = (void*)(msg & (~1));
19668         msg_conv.is_owned = (msg & 1) || (msg == 0);
19669         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19670         msg_conv = RevokeAndACK_clone(&msg_conv);
19671         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19672         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
19673         uint64_t ret_ref = (uint64_t)ret_copy;
19674         return ret_ref;
19675 }
19676
19677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19678         LDKPublicKey node_id_ref;
19679         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19680         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19681         LDKClosingSigned msg_conv;
19682         msg_conv.inner = (void*)(msg & (~1));
19683         msg_conv.is_owned = (msg & 1) || (msg == 0);
19684         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19685         msg_conv = ClosingSigned_clone(&msg_conv);
19686         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19687         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
19688         uint64_t ret_ref = (uint64_t)ret_copy;
19689         return ret_ref;
19690 }
19691
19692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19693         LDKPublicKey node_id_ref;
19694         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19695         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19696         LDKShutdown msg_conv;
19697         msg_conv.inner = (void*)(msg & (~1));
19698         msg_conv.is_owned = (msg & 1) || (msg == 0);
19699         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19700         msg_conv = Shutdown_clone(&msg_conv);
19701         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19702         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
19703         uint64_t ret_ref = (uint64_t)ret_copy;
19704         return ret_ref;
19705 }
19706
19707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19708         LDKPublicKey node_id_ref;
19709         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19710         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19711         LDKChannelReestablish msg_conv;
19712         msg_conv.inner = (void*)(msg & (~1));
19713         msg_conv.is_owned = (msg & 1) || (msg == 0);
19714         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19715         msg_conv = ChannelReestablish_clone(&msg_conv);
19716         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19717         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
19718         uint64_t ret_ref = (uint64_t)ret_copy;
19719         return ret_ref;
19720 }
19721
19722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
19723         LDKChannelAnnouncement msg_conv;
19724         msg_conv.inner = (void*)(msg & (~1));
19725         msg_conv.is_owned = (msg & 1) || (msg == 0);
19726         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19727         msg_conv = ChannelAnnouncement_clone(&msg_conv);
19728         LDKChannelUpdate update_msg_conv;
19729         update_msg_conv.inner = (void*)(update_msg & (~1));
19730         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
19731         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
19732         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
19733         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19734         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
19735         uint64_t ret_ref = (uint64_t)ret_copy;
19736         return ret_ref;
19737 }
19738
19739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
19740         LDKNodeAnnouncement msg_conv;
19741         msg_conv.inner = (void*)(msg & (~1));
19742         msg_conv.is_owned = (msg & 1) || (msg == 0);
19743         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19744         msg_conv = NodeAnnouncement_clone(&msg_conv);
19745         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19746         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
19747         uint64_t ret_ref = (uint64_t)ret_copy;
19748         return ret_ref;
19749 }
19750
19751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
19752         LDKChannelUpdate msg_conv;
19753         msg_conv.inner = (void*)(msg & (~1));
19754         msg_conv.is_owned = (msg & 1) || (msg == 0);
19755         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19756         msg_conv = ChannelUpdate_clone(&msg_conv);
19757         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19758         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
19759         uint64_t ret_ref = (uint64_t)ret_copy;
19760         return ret_ref;
19761 }
19762
19763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19764         LDKPublicKey node_id_ref;
19765         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19766         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19767         LDKChannelUpdate msg_conv;
19768         msg_conv.inner = (void*)(msg & (~1));
19769         msg_conv.is_owned = (msg & 1) || (msg == 0);
19770         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19771         msg_conv = ChannelUpdate_clone(&msg_conv);
19772         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19773         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
19774         uint64_t ret_ref = (uint64_t)ret_copy;
19775         return ret_ref;
19776 }
19777
19778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
19779         LDKPublicKey node_id_ref;
19780         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19781         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19782         void* action_ptr = (void*)(((uint64_t)action) & ~1);
19783         CHECK_ACCESS(action_ptr);
19784         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
19785         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
19786         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19787         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
19788         uint64_t ret_ref = (uint64_t)ret_copy;
19789         return ret_ref;
19790 }
19791
19792 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) {
19793         LDKPublicKey node_id_ref;
19794         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19795         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19796         LDKQueryChannelRange msg_conv;
19797         msg_conv.inner = (void*)(msg & (~1));
19798         msg_conv.is_owned = (msg & 1) || (msg == 0);
19799         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19800         msg_conv = QueryChannelRange_clone(&msg_conv);
19801         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19802         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
19803         uint64_t ret_ref = (uint64_t)ret_copy;
19804         return ret_ref;
19805 }
19806
19807 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) {
19808         LDKPublicKey node_id_ref;
19809         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19810         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19811         LDKQueryShortChannelIds msg_conv;
19812         msg_conv.inner = (void*)(msg & (~1));
19813         msg_conv.is_owned = (msg & 1) || (msg == 0);
19814         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19815         msg_conv = QueryShortChannelIds_clone(&msg_conv);
19816         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19817         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
19818         uint64_t ret_ref = (uint64_t)ret_copy;
19819         return ret_ref;
19820 }
19821
19822 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) {
19823         LDKPublicKey node_id_ref;
19824         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19825         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19826         LDKReplyChannelRange msg_conv;
19827         msg_conv.inner = (void*)(msg & (~1));
19828         msg_conv.is_owned = (msg & 1) || (msg == 0);
19829         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19830         msg_conv = ReplyChannelRange_clone(&msg_conv);
19831         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19832         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
19833         uint64_t ret_ref = (uint64_t)ret_copy;
19834         return ret_ref;
19835 }
19836
19837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19838         if ((this_ptr & 1) != 0) return;
19839         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19840         CHECK_ACCESS(this_ptr_ptr);
19841         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
19842         FREE((void*)this_ptr);
19843         MessageSendEventsProvider_free(this_ptr_conv);
19844 }
19845
19846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19847         if ((this_ptr & 1) != 0) return;
19848         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19849         CHECK_ACCESS(this_ptr_ptr);
19850         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
19851         FREE((void*)this_ptr);
19852         EventsProvider_free(this_ptr_conv);
19853 }
19854
19855 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19856         if ((this_ptr & 1) != 0) return;
19857         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19858         CHECK_ACCESS(this_ptr_ptr);
19859         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
19860         FREE((void*)this_ptr);
19861         EventHandler_free(this_ptr_conv);
19862 }
19863
19864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19865         if ((this_ptr & 1) != 0) return;
19866         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19867         CHECK_ACCESS(this_ptr_ptr);
19868         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
19869         FREE((void*)this_ptr);
19870         APIError_free(this_ptr_conv);
19871 }
19872
19873 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
19874         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19875         *ret_copy = APIError_clone(arg);
19876 uint64_t ret_ref = (uint64_t)ret_copy;
19877         return ret_ref;
19878 }
19879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19880         LDKAPIError* arg_conv = (LDKAPIError*)arg;
19881         int64_t ret_val = APIError_clone_ptr(arg_conv);
19882         return ret_val;
19883 }
19884
19885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19886         LDKAPIError* orig_conv = (LDKAPIError*)orig;
19887         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19888         *ret_copy = APIError_clone(orig_conv);
19889         uint64_t ret_ref = (uint64_t)ret_copy;
19890         return ret_ref;
19891 }
19892
19893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
19894         LDKStr err_conv = java_to_owned_str(env, err);
19895         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19896         *ret_copy = APIError_apimisuse_error(err_conv);
19897         uint64_t ret_ref = (uint64_t)ret_copy;
19898         return ret_ref;
19899 }
19900
19901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
19902         LDKStr err_conv = java_to_owned_str(env, err);
19903         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19904         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
19905         uint64_t ret_ref = (uint64_t)ret_copy;
19906         return ret_ref;
19907 }
19908
19909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
19910         LDKStr err_conv = java_to_owned_str(env, err);
19911         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19912         *ret_copy = APIError_route_error(err_conv);
19913         uint64_t ret_ref = (uint64_t)ret_copy;
19914         return ret_ref;
19915 }
19916
19917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
19918         LDKStr err_conv = java_to_owned_str(env, err);
19919         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19920         *ret_copy = APIError_channel_unavailable(err_conv);
19921         uint64_t ret_ref = (uint64_t)ret_copy;
19922         return ret_ref;
19923 }
19924
19925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
19926         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19927         *ret_copy = APIError_monitor_update_failed();
19928         uint64_t ret_ref = (uint64_t)ret_copy;
19929         return ret_ref;
19930 }
19931
19932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
19933         LDKShutdownScript script_conv;
19934         script_conv.inner = (void*)(script & (~1));
19935         script_conv.is_owned = (script & 1) || (script == 0);
19936         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
19937         script_conv = ShutdownScript_clone(&script_conv);
19938         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19939         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
19940         uint64_t ret_ref = (uint64_t)ret_copy;
19941         return ret_ref;
19942 }
19943
19944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
19945         LDKu8slice msg_ref;
19946         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
19947         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
19948         unsigned char sk_arr[32];
19949         CHECK((*env)->GetArrayLength(env, sk) == 32);
19950         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
19951         unsigned char (*sk_ref)[32] = &sk_arr;
19952         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19953         *ret_conv = sign(msg_ref, sk_ref);
19954         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
19955         return (uint64_t)ret_conv;
19956 }
19957
19958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
19959         LDKu8slice msg_ref;
19960         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
19961         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
19962         LDKStr sig_conv = java_to_owned_str(env, sig);
19963         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19964         *ret_conv = recover_pk(msg_ref, sig_conv);
19965         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
19966         return (uint64_t)ret_conv;
19967 }
19968
19969 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
19970         LDKu8slice msg_ref;
19971         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
19972         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
19973         LDKStr sig_conv = java_to_owned_str(env, sig);
19974         LDKPublicKey pk_ref;
19975         CHECK((*env)->GetArrayLength(env, pk) == 33);
19976         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
19977         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
19978         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
19979         return ret_val;
19980 }
19981
19982 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19983         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
19984         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
19985         return ret_conv;
19986 }
19987
19988 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
19989         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
19990         return ret_conv;
19991 }
19992
19993 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
19994         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
19995         return ret_conv;
19996 }
19997
19998 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
19999         jclass ret_conv = LDKLevel_to_java(env, Level_info());
20000         return ret_conv;
20001 }
20002
20003 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
20004         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
20005         return ret_conv;
20006 }
20007
20008 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
20009         jclass ret_conv = LDKLevel_to_java(env, Level_error());
20010         return ret_conv;
20011 }
20012
20013 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
20014         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20015         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20016         jboolean ret_val = Level_eq(a_conv, b_conv);
20017         return ret_val;
20018 }
20019
20020 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
20021         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20022         int64_t ret_val = Level_hash(o_conv);
20023         return ret_val;
20024 }
20025
20026 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
20027         jclass ret_conv = LDKLevel_to_java(env, Level_max());
20028         return ret_conv;
20029 }
20030
20031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20032         LDKRecord this_obj_conv;
20033         this_obj_conv.inner = (void*)(this_obj & (~1));
20034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20036         Record_free(this_obj_conv);
20037 }
20038
20039 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
20040         LDKRecord this_ptr_conv;
20041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20042         this_ptr_conv.is_owned = false;
20043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20044         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
20045         return ret_conv;
20046 }
20047
20048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
20049         LDKRecord this_ptr_conv;
20050         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20051         this_ptr_conv.is_owned = false;
20052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20053         LDKLevel val_conv = LDKLevel_from_java(env, val);
20054         Record_set_level(&this_ptr_conv, val_conv);
20055 }
20056
20057 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
20058         LDKRecord this_ptr_conv;
20059         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20060         this_ptr_conv.is_owned = false;
20061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20062         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20063         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20064         Str_free(ret_str);
20065         return ret_conv;
20066 }
20067
20068 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20069         LDKRecord this_ptr_conv;
20070         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20071         this_ptr_conv.is_owned = false;
20072         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20073         LDKStr val_conv = java_to_owned_str(env, val);
20074         Record_set_args(&this_ptr_conv, val_conv);
20075 }
20076
20077 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
20078         LDKRecord this_ptr_conv;
20079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20080         this_ptr_conv.is_owned = false;
20081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20082         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20083         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20084         Str_free(ret_str);
20085         return ret_conv;
20086 }
20087
20088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20089         LDKRecord this_ptr_conv;
20090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20091         this_ptr_conv.is_owned = false;
20092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20093         LDKStr val_conv = java_to_owned_str(env, val);
20094         Record_set_module_path(&this_ptr_conv, val_conv);
20095 }
20096
20097 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
20098         LDKRecord this_ptr_conv;
20099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20100         this_ptr_conv.is_owned = false;
20101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20102         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20103         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20104         Str_free(ret_str);
20105         return ret_conv;
20106 }
20107
20108 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20109         LDKRecord this_ptr_conv;
20110         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20111         this_ptr_conv.is_owned = false;
20112         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20113         LDKStr val_conv = java_to_owned_str(env, val);
20114         Record_set_file(&this_ptr_conv, val_conv);
20115 }
20116
20117 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
20118         LDKRecord this_ptr_conv;
20119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20120         this_ptr_conv.is_owned = false;
20121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20122         int32_t ret_val = Record_get_line(&this_ptr_conv);
20123         return ret_val;
20124 }
20125
20126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20127         LDKRecord this_ptr_conv;
20128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20129         this_ptr_conv.is_owned = false;
20130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20131         Record_set_line(&this_ptr_conv, val);
20132 }
20133
20134 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20135         LDKRecord ret_var = Record_clone(arg);
20136 uint64_t ret_ref = 0;
20137 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20138 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20139 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20140 ret_ref = (uint64_t)ret_var.inner;
20141 if (ret_var.is_owned) {
20142         ret_ref |= 1;
20143 }
20144         return ret_ref;
20145 }
20146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20147         LDKRecord arg_conv;
20148         arg_conv.inner = (void*)(arg & (~1));
20149         arg_conv.is_owned = false;
20150         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20151         int64_t ret_val = Record_clone_ptr(&arg_conv);
20152         return ret_val;
20153 }
20154
20155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20156         LDKRecord orig_conv;
20157         orig_conv.inner = (void*)(orig & (~1));
20158         orig_conv.is_owned = false;
20159         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20160         LDKRecord ret_var = Record_clone(&orig_conv);
20161         uint64_t ret_ref = 0;
20162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20165         ret_ref = (uint64_t)ret_var.inner;
20166         if (ret_var.is_owned) {
20167                 ret_ref |= 1;
20168         }
20169         return ret_ref;
20170 }
20171
20172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20173         if ((this_ptr & 1) != 0) return;
20174         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20175         CHECK_ACCESS(this_ptr_ptr);
20176         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20177         FREE((void*)this_ptr);
20178         Logger_free(this_ptr_conv);
20179 }
20180
20181 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20182         LDKChannelHandshakeConfig this_obj_conv;
20183         this_obj_conv.inner = (void*)(this_obj & (~1));
20184         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20185         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20186         ChannelHandshakeConfig_free(this_obj_conv);
20187 }
20188
20189 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
20190         LDKChannelHandshakeConfig this_ptr_conv;
20191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20192         this_ptr_conv.is_owned = false;
20193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20194         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20195         return ret_val;
20196 }
20197
20198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20199         LDKChannelHandshakeConfig this_ptr_conv;
20200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20201         this_ptr_conv.is_owned = false;
20202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20203         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20204 }
20205
20206 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
20207         LDKChannelHandshakeConfig this_ptr_conv;
20208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20209         this_ptr_conv.is_owned = false;
20210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20211         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20212         return ret_val;
20213 }
20214
20215 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) {
20216         LDKChannelHandshakeConfig this_ptr_conv;
20217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20218         this_ptr_conv.is_owned = false;
20219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20220         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20221 }
20222
20223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20224         LDKChannelHandshakeConfig this_ptr_conv;
20225         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20226         this_ptr_conv.is_owned = false;
20227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20228         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20229         return ret_val;
20230 }
20231
20232 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) {
20233         LDKChannelHandshakeConfig this_ptr_conv;
20234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20235         this_ptr_conv.is_owned = false;
20236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20237         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20238 }
20239
20240 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) {
20241         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
20242         uint64_t ret_ref = 0;
20243         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20244         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20245         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20246         ret_ref = (uint64_t)ret_var.inner;
20247         if (ret_var.is_owned) {
20248                 ret_ref |= 1;
20249         }
20250         return ret_ref;
20251 }
20252
20253 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20254         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20255 uint64_t ret_ref = 0;
20256 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20257 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20258 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20259 ret_ref = (uint64_t)ret_var.inner;
20260 if (ret_var.is_owned) {
20261         ret_ref |= 1;
20262 }
20263         return ret_ref;
20264 }
20265 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20266         LDKChannelHandshakeConfig arg_conv;
20267         arg_conv.inner = (void*)(arg & (~1));
20268         arg_conv.is_owned = false;
20269         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20270         int64_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20271         return ret_val;
20272 }
20273
20274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20275         LDKChannelHandshakeConfig orig_conv;
20276         orig_conv.inner = (void*)(orig & (~1));
20277         orig_conv.is_owned = false;
20278         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20279         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20280         uint64_t ret_ref = 0;
20281         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20282         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20283         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20284         ret_ref = (uint64_t)ret_var.inner;
20285         if (ret_var.is_owned) {
20286                 ret_ref |= 1;
20287         }
20288         return ret_ref;
20289 }
20290
20291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
20292         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20293         uint64_t ret_ref = 0;
20294         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20295         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20296         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20297         ret_ref = (uint64_t)ret_var.inner;
20298         if (ret_var.is_owned) {
20299                 ret_ref |= 1;
20300         }
20301         return ret_ref;
20302 }
20303
20304 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20305         LDKChannelHandshakeLimits this_obj_conv;
20306         this_obj_conv.inner = (void*)(this_obj & (~1));
20307         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20308         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20309         ChannelHandshakeLimits_free(this_obj_conv);
20310 }
20311
20312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20313         LDKChannelHandshakeLimits this_ptr_conv;
20314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20315         this_ptr_conv.is_owned = false;
20316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20317         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20318         return ret_val;
20319 }
20320
20321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20322         LDKChannelHandshakeLimits this_ptr_conv;
20323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20324         this_ptr_conv.is_owned = false;
20325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20326         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20327 }
20328
20329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20330         LDKChannelHandshakeLimits this_ptr_conv;
20331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20332         this_ptr_conv.is_owned = false;
20333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20334         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20335         return ret_val;
20336 }
20337
20338 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) {
20339         LDKChannelHandshakeLimits this_ptr_conv;
20340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20341         this_ptr_conv.is_owned = false;
20342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20343         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20344 }
20345
20346 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) {
20347         LDKChannelHandshakeLimits this_ptr_conv;
20348         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20349         this_ptr_conv.is_owned = false;
20350         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20351         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20352         return ret_val;
20353 }
20354
20355 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) {
20356         LDKChannelHandshakeLimits this_ptr_conv;
20357         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20358         this_ptr_conv.is_owned = false;
20359         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20360         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20361 }
20362
20363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20364         LDKChannelHandshakeLimits this_ptr_conv;
20365         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20366         this_ptr_conv.is_owned = false;
20367         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20368         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20369         return ret_val;
20370 }
20371
20372 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) {
20373         LDKChannelHandshakeLimits this_ptr_conv;
20374         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20375         this_ptr_conv.is_owned = false;
20376         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20377         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20378 }
20379
20380 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
20381         LDKChannelHandshakeLimits this_ptr_conv;
20382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20383         this_ptr_conv.is_owned = false;
20384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20385         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20386         return ret_val;
20387 }
20388
20389 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) {
20390         LDKChannelHandshakeLimits this_ptr_conv;
20391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20392         this_ptr_conv.is_owned = false;
20393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20394         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20395 }
20396
20397 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
20398         LDKChannelHandshakeLimits this_ptr_conv;
20399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20400         this_ptr_conv.is_owned = false;
20401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20402         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20403         return ret_val;
20404 }
20405
20406 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20407         LDKChannelHandshakeLimits this_ptr_conv;
20408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20409         this_ptr_conv.is_owned = false;
20410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20411         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20412 }
20413
20414 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
20415         LDKChannelHandshakeLimits this_ptr_conv;
20416         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20417         this_ptr_conv.is_owned = false;
20418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20419         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20420         return ret_val;
20421 }
20422
20423 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20424         LDKChannelHandshakeLimits this_ptr_conv;
20425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20426         this_ptr_conv.is_owned = false;
20427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20428         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20429 }
20430
20431 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
20432         LDKChannelHandshakeLimits this_ptr_conv;
20433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20434         this_ptr_conv.is_owned = false;
20435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20436         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20437         return ret_val;
20438 }
20439
20440 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) {
20441         LDKChannelHandshakeLimits this_ptr_conv;
20442         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20443         this_ptr_conv.is_owned = false;
20444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20445         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20446 }
20447
20448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1new(JNIEnv *env, jclass clz, int64_t min_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 force_announced_channel_preference_arg, int16_t their_to_self_delay_arg) {
20449         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_new(min_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, force_announced_channel_preference_arg, their_to_self_delay_arg);
20450         uint64_t ret_ref = 0;
20451         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20452         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20454         ret_ref = (uint64_t)ret_var.inner;
20455         if (ret_var.is_owned) {
20456                 ret_ref |= 1;
20457         }
20458         return ret_ref;
20459 }
20460
20461 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20462         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20463 uint64_t ret_ref = 0;
20464 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20465 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20466 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20467 ret_ref = (uint64_t)ret_var.inner;
20468 if (ret_var.is_owned) {
20469         ret_ref |= 1;
20470 }
20471         return ret_ref;
20472 }
20473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20474         LDKChannelHandshakeLimits arg_conv;
20475         arg_conv.inner = (void*)(arg & (~1));
20476         arg_conv.is_owned = false;
20477         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20478         int64_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20479         return ret_val;
20480 }
20481
20482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20483         LDKChannelHandshakeLimits orig_conv;
20484         orig_conv.inner = (void*)(orig & (~1));
20485         orig_conv.is_owned = false;
20486         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20487         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20488         uint64_t ret_ref = 0;
20489         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20490         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20491         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20492         ret_ref = (uint64_t)ret_var.inner;
20493         if (ret_var.is_owned) {
20494                 ret_ref |= 1;
20495         }
20496         return ret_ref;
20497 }
20498
20499 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
20500         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20501         uint64_t ret_ref = 0;
20502         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20503         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20504         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20505         ret_ref = (uint64_t)ret_var.inner;
20506         if (ret_var.is_owned) {
20507                 ret_ref |= 1;
20508         }
20509         return ret_ref;
20510 }
20511
20512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20513         LDKChannelConfig this_obj_conv;
20514         this_obj_conv.inner = (void*)(this_obj & (~1));
20515         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20516         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20517         ChannelConfig_free(this_obj_conv);
20518 }
20519
20520 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20521         LDKChannelConfig this_ptr_conv;
20522         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20523         this_ptr_conv.is_owned = false;
20524         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20525         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20526         return ret_val;
20527 }
20528
20529 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) {
20530         LDKChannelConfig this_ptr_conv;
20531         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20532         this_ptr_conv.is_owned = false;
20533         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20534         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20535 }
20536
20537 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20538         LDKChannelConfig this_ptr_conv;
20539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20540         this_ptr_conv.is_owned = false;
20541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20542         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20543         return ret_val;
20544 }
20545
20546 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) {
20547         LDKChannelConfig this_ptr_conv;
20548         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20549         this_ptr_conv.is_owned = false;
20550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20551         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20552 }
20553
20554 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20555         LDKChannelConfig this_ptr_conv;
20556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20557         this_ptr_conv.is_owned = false;
20558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20559         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20560         return ret_val;
20561 }
20562
20563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20564         LDKChannelConfig this_ptr_conv;
20565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20566         this_ptr_conv.is_owned = false;
20567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20568         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20569 }
20570
20571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
20572         LDKChannelConfig this_ptr_conv;
20573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20574         this_ptr_conv.is_owned = false;
20575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20576         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
20577         return ret_val;
20578 }
20579
20580 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20581         LDKChannelConfig this_ptr_conv;
20582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20583         this_ptr_conv.is_owned = false;
20584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20585         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20586 }
20587
20588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
20589         LDKChannelConfig this_ptr_conv;
20590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20591         this_ptr_conv.is_owned = false;
20592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20593         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20594         return ret_val;
20595 }
20596
20597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20598         LDKChannelConfig this_ptr_conv;
20599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20600         this_ptr_conv.is_owned = false;
20601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20602         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20603 }
20604
20605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20606         LDKChannelConfig this_ptr_conv;
20607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20608         this_ptr_conv.is_owned = false;
20609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20610         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
20611         return ret_val;
20612 }
20613
20614 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) {
20615         LDKChannelConfig this_ptr_conv;
20616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20617         this_ptr_conv.is_owned = false;
20618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20619         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
20620 }
20621
20622 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) {
20623         LDKChannelConfig this_ptr_conv;
20624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20625         this_ptr_conv.is_owned = false;
20626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20627         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
20628         return ret_val;
20629 }
20630
20631 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) {
20632         LDKChannelConfig this_ptr_conv;
20633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20634         this_ptr_conv.is_owned = false;
20635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20636         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
20637 }
20638
20639 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, jboolean announced_channel_arg, jboolean commit_upfront_shutdown_pubkey_arg, int64_t max_dust_htlc_exposure_msat_arg, int64_t force_close_avoidance_max_fee_satoshis_arg) {
20640         LDKChannelConfig ret_var = ChannelConfig_new(forwarding_fee_proportional_millionths_arg, forwarding_fee_base_msat_arg, cltv_expiry_delta_arg, announced_channel_arg, commit_upfront_shutdown_pubkey_arg, max_dust_htlc_exposure_msat_arg, force_close_avoidance_max_fee_satoshis_arg);
20641         uint64_t ret_ref = 0;
20642         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20643         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20644         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20645         ret_ref = (uint64_t)ret_var.inner;
20646         if (ret_var.is_owned) {
20647                 ret_ref |= 1;
20648         }
20649         return ret_ref;
20650 }
20651
20652 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
20653         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
20654 uint64_t ret_ref = 0;
20655 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20656 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20657 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20658 ret_ref = (uint64_t)ret_var.inner;
20659 if (ret_var.is_owned) {
20660         ret_ref |= 1;
20661 }
20662         return ret_ref;
20663 }
20664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20665         LDKChannelConfig arg_conv;
20666         arg_conv.inner = (void*)(arg & (~1));
20667         arg_conv.is_owned = false;
20668         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20669         int64_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
20670         return ret_val;
20671 }
20672
20673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20674         LDKChannelConfig orig_conv;
20675         orig_conv.inner = (void*)(orig & (~1));
20676         orig_conv.is_owned = false;
20677         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20678         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
20679         uint64_t ret_ref = 0;
20680         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20681         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20682         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20683         ret_ref = (uint64_t)ret_var.inner;
20684         if (ret_var.is_owned) {
20685                 ret_ref |= 1;
20686         }
20687         return ret_ref;
20688 }
20689
20690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
20691         LDKChannelConfig ret_var = ChannelConfig_default();
20692         uint64_t ret_ref = 0;
20693         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20694         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20696         ret_ref = (uint64_t)ret_var.inner;
20697         if (ret_var.is_owned) {
20698                 ret_ref |= 1;
20699         }
20700         return ret_ref;
20701 }
20702
20703 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
20704         LDKChannelConfig obj_conv;
20705         obj_conv.inner = (void*)(obj & (~1));
20706         obj_conv.is_owned = false;
20707         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20708         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
20709         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20710         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20711         CVec_u8Z_free(ret_var);
20712         return ret_arr;
20713 }
20714
20715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20716         LDKu8slice ser_ref;
20717         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20718         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20719         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20720         *ret_conv = ChannelConfig_read(ser_ref);
20721         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20722         return (uint64_t)ret_conv;
20723 }
20724
20725 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20726         LDKUserConfig this_obj_conv;
20727         this_obj_conv.inner = (void*)(this_obj & (~1));
20728         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20730         UserConfig_free(this_obj_conv);
20731 }
20732
20733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
20734         LDKUserConfig this_ptr_conv;
20735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20736         this_ptr_conv.is_owned = false;
20737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20738         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
20739         uint64_t ret_ref = 0;
20740         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20741         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20742         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20743         ret_ref = (uint64_t)ret_var.inner;
20744         if (ret_var.is_owned) {
20745                 ret_ref |= 1;
20746         }
20747         return ret_ref;
20748 }
20749
20750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20751         LDKUserConfig this_ptr_conv;
20752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20753         this_ptr_conv.is_owned = false;
20754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20755         LDKChannelHandshakeConfig val_conv;
20756         val_conv.inner = (void*)(val & (~1));
20757         val_conv.is_owned = (val & 1) || (val == 0);
20758         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20759         val_conv = ChannelHandshakeConfig_clone(&val_conv);
20760         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
20761 }
20762
20763 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
20764         LDKUserConfig this_ptr_conv;
20765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20766         this_ptr_conv.is_owned = false;
20767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20768         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
20769         uint64_t ret_ref = 0;
20770         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20771         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20772         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20773         ret_ref = (uint64_t)ret_var.inner;
20774         if (ret_var.is_owned) {
20775                 ret_ref |= 1;
20776         }
20777         return ret_ref;
20778 }
20779
20780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20781         LDKUserConfig this_ptr_conv;
20782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20783         this_ptr_conv.is_owned = false;
20784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20785         LDKChannelHandshakeLimits val_conv;
20786         val_conv.inner = (void*)(val & (~1));
20787         val_conv.is_owned = (val & 1) || (val == 0);
20788         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20789         val_conv = ChannelHandshakeLimits_clone(&val_conv);
20790         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
20791 }
20792
20793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
20794         LDKUserConfig this_ptr_conv;
20795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20796         this_ptr_conv.is_owned = false;
20797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20798         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
20799         uint64_t ret_ref = 0;
20800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20803         ret_ref = (uint64_t)ret_var.inner;
20804         if (ret_var.is_owned) {
20805                 ret_ref |= 1;
20806         }
20807         return ret_ref;
20808 }
20809
20810 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20811         LDKUserConfig this_ptr_conv;
20812         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20813         this_ptr_conv.is_owned = false;
20814         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20815         LDKChannelConfig val_conv;
20816         val_conv.inner = (void*)(val & (~1));
20817         val_conv.is_owned = (val & 1) || (val == 0);
20818         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20819         val_conv = ChannelConfig_clone(&val_conv);
20820         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
20821 }
20822
20823 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
20824         LDKUserConfig this_ptr_conv;
20825         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20826         this_ptr_conv.is_owned = false;
20827         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20828         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
20829         return ret_val;
20830 }
20831
20832 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) {
20833         LDKUserConfig this_ptr_conv;
20834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20835         this_ptr_conv.is_owned = false;
20836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20837         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
20838 }
20839
20840 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1new(JNIEnv *env, jclass clz, int64_t own_channel_config_arg, int64_t peer_channel_config_limits_arg, int64_t channel_options_arg, jboolean accept_forwards_to_priv_channels_arg) {
20841         LDKChannelHandshakeConfig own_channel_config_arg_conv;
20842         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
20843         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
20844         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
20845         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
20846         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
20847         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
20848         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
20849         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
20850         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
20851         LDKChannelConfig channel_options_arg_conv;
20852         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
20853         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
20854         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
20855         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
20856         LDKUserConfig ret_var = UserConfig_new(own_channel_config_arg_conv, peer_channel_config_limits_arg_conv, channel_options_arg_conv, accept_forwards_to_priv_channels_arg);
20857         uint64_t ret_ref = 0;
20858         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20859         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20860         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20861         ret_ref = (uint64_t)ret_var.inner;
20862         if (ret_var.is_owned) {
20863                 ret_ref |= 1;
20864         }
20865         return ret_ref;
20866 }
20867
20868 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
20869         LDKUserConfig ret_var = UserConfig_clone(arg);
20870 uint64_t ret_ref = 0;
20871 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20872 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20873 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20874 ret_ref = (uint64_t)ret_var.inner;
20875 if (ret_var.is_owned) {
20876         ret_ref |= 1;
20877 }
20878         return ret_ref;
20879 }
20880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20881         LDKUserConfig arg_conv;
20882         arg_conv.inner = (void*)(arg & (~1));
20883         arg_conv.is_owned = false;
20884         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20885         int64_t ret_val = UserConfig_clone_ptr(&arg_conv);
20886         return ret_val;
20887 }
20888
20889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20890         LDKUserConfig orig_conv;
20891         orig_conv.inner = (void*)(orig & (~1));
20892         orig_conv.is_owned = false;
20893         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20894         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
20895         uint64_t ret_ref = 0;
20896         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20897         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20898         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20899         ret_ref = (uint64_t)ret_var.inner;
20900         if (ret_var.is_owned) {
20901                 ret_ref |= 1;
20902         }
20903         return ret_ref;
20904 }
20905
20906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
20907         LDKUserConfig ret_var = UserConfig_default();
20908         uint64_t ret_ref = 0;
20909         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20910         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20911         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20912         ret_ref = (uint64_t)ret_var.inner;
20913         if (ret_var.is_owned) {
20914                 ret_ref |= 1;
20915         }
20916         return ret_ref;
20917 }
20918
20919 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20920         LDKBestBlock this_obj_conv;
20921         this_obj_conv.inner = (void*)(this_obj & (~1));
20922         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20923         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20924         BestBlock_free(this_obj_conv);
20925 }
20926
20927 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
20928         LDKBestBlock ret_var = BestBlock_clone(arg);
20929 uint64_t ret_ref = 0;
20930 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20931 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20932 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20933 ret_ref = (uint64_t)ret_var.inner;
20934 if (ret_var.is_owned) {
20935         ret_ref |= 1;
20936 }
20937         return ret_ref;
20938 }
20939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20940         LDKBestBlock arg_conv;
20941         arg_conv.inner = (void*)(arg & (~1));
20942         arg_conv.is_owned = false;
20943         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20944         int64_t ret_val = BestBlock_clone_ptr(&arg_conv);
20945         return ret_val;
20946 }
20947
20948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20949         LDKBestBlock orig_conv;
20950         orig_conv.inner = (void*)(orig & (~1));
20951         orig_conv.is_owned = false;
20952         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20953         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
20954         uint64_t ret_ref = 0;
20955         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20956         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20958         ret_ref = (uint64_t)ret_var.inner;
20959         if (ret_var.is_owned) {
20960                 ret_ref |= 1;
20961         }
20962         return ret_ref;
20963 }
20964
20965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
20966         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
20967         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
20968         uint64_t ret_ref = 0;
20969         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20970         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20971         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20972         ret_ref = (uint64_t)ret_var.inner;
20973         if (ret_var.is_owned) {
20974                 ret_ref |= 1;
20975         }
20976         return ret_ref;
20977 }
20978
20979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
20980         LDKThirtyTwoBytes block_hash_ref;
20981         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
20982         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
20983         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
20984         uint64_t ret_ref = 0;
20985         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20986         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20988         ret_ref = (uint64_t)ret_var.inner;
20989         if (ret_var.is_owned) {
20990                 ret_ref |= 1;
20991         }
20992         return ret_ref;
20993 }
20994
20995 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
20996         LDKBestBlock this_arg_conv;
20997         this_arg_conv.inner = (void*)(this_arg & (~1));
20998         this_arg_conv.is_owned = false;
20999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21000         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21001         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
21002         return ret_arr;
21003 }
21004
21005 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
21006         LDKBestBlock this_arg_conv;
21007         this_arg_conv.inner = (void*)(this_arg & (~1));
21008         this_arg_conv.is_owned = false;
21009         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21010         int32_t ret_val = BestBlock_height(&this_arg_conv);
21011         return ret_val;
21012 }
21013
21014 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21015         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21016         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
21017         return ret_conv;
21018 }
21019
21020 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
21021         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
21022         return ret_conv;
21023 }
21024
21025 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
21026         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
21027         return ret_conv;
21028 }
21029
21030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21031         if ((this_ptr & 1) != 0) return;
21032         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21033         CHECK_ACCESS(this_ptr_ptr);
21034         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21035         FREE((void*)this_ptr);
21036         Access_free(this_ptr_conv);
21037 }
21038
21039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21040         if ((this_ptr & 1) != 0) return;
21041         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21042         CHECK_ACCESS(this_ptr_ptr);
21043         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21044         FREE((void*)this_ptr);
21045         Listen_free(this_ptr_conv);
21046 }
21047
21048 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21049         if ((this_ptr & 1) != 0) return;
21050         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21051         CHECK_ACCESS(this_ptr_ptr);
21052         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21053         FREE((void*)this_ptr);
21054         Confirm_free(this_ptr_conv);
21055 }
21056
21057 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21058         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21059         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
21060         return ret_conv;
21061 }
21062
21063 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
21064         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
21065         return ret_conv;
21066 }
21067
21068 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
21069         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
21070         return ret_conv;
21071 }
21072
21073 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21074         if ((this_ptr & 1) != 0) return;
21075         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21076         CHECK_ACCESS(this_ptr_ptr);
21077         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21078         FREE((void*)this_ptr);
21079         Watch_free(this_ptr_conv);
21080 }
21081
21082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21083         if ((this_ptr & 1) != 0) return;
21084         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21085         CHECK_ACCESS(this_ptr_ptr);
21086         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21087         FREE((void*)this_ptr);
21088         Filter_free(this_ptr_conv);
21089 }
21090
21091 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21092         LDKWatchedOutput this_obj_conv;
21093         this_obj_conv.inner = (void*)(this_obj & (~1));
21094         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21095         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21096         WatchedOutput_free(this_obj_conv);
21097 }
21098
21099 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21100         LDKWatchedOutput this_ptr_conv;
21101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21102         this_ptr_conv.is_owned = false;
21103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21104         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21105         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
21106         return ret_arr;
21107 }
21108
21109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21110         LDKWatchedOutput this_ptr_conv;
21111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21112         this_ptr_conv.is_owned = false;
21113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21114         LDKThirtyTwoBytes val_ref;
21115         CHECK((*env)->GetArrayLength(env, val) == 32);
21116         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21117         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21118 }
21119
21120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21121         LDKWatchedOutput this_ptr_conv;
21122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21123         this_ptr_conv.is_owned = false;
21124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21125         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21126         uint64_t ret_ref = 0;
21127         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21128         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21129         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21130         ret_ref = (uint64_t)ret_var.inner;
21131         if (ret_var.is_owned) {
21132                 ret_ref |= 1;
21133         }
21134         return ret_ref;
21135 }
21136
21137 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21138         LDKWatchedOutput this_ptr_conv;
21139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21140         this_ptr_conv.is_owned = false;
21141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21142         LDKOutPoint val_conv;
21143         val_conv.inner = (void*)(val & (~1));
21144         val_conv.is_owned = (val & 1) || (val == 0);
21145         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21146         val_conv = OutPoint_clone(&val_conv);
21147         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21148 }
21149
21150 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21151         LDKWatchedOutput this_ptr_conv;
21152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21153         this_ptr_conv.is_owned = false;
21154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21155         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21156         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21157         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21158         return ret_arr;
21159 }
21160
21161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21162         LDKWatchedOutput this_ptr_conv;
21163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21164         this_ptr_conv.is_owned = false;
21165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21166         LDKCVec_u8Z val_ref;
21167         val_ref.datalen = (*env)->GetArrayLength(env, val);
21168         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21169         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
21170         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21171 }
21172
21173 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) {
21174         LDKThirtyTwoBytes block_hash_arg_ref;
21175         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
21176         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
21177         LDKOutPoint outpoint_arg_conv;
21178         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21179         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21180         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21181         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21182         LDKCVec_u8Z script_pubkey_arg_ref;
21183         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
21184         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21185         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
21186         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21187         uint64_t ret_ref = 0;
21188         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21189         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21190         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21191         ret_ref = (uint64_t)ret_var.inner;
21192         if (ret_var.is_owned) {
21193                 ret_ref |= 1;
21194         }
21195         return ret_ref;
21196 }
21197
21198 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21199         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21200 uint64_t ret_ref = 0;
21201 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21202 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21203 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21204 ret_ref = (uint64_t)ret_var.inner;
21205 if (ret_var.is_owned) {
21206         ret_ref |= 1;
21207 }
21208         return ret_ref;
21209 }
21210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21211         LDKWatchedOutput arg_conv;
21212         arg_conv.inner = (void*)(arg & (~1));
21213         arg_conv.is_owned = false;
21214         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21215         int64_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
21216         return ret_val;
21217 }
21218
21219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21220         LDKWatchedOutput orig_conv;
21221         orig_conv.inner = (void*)(orig & (~1));
21222         orig_conv.is_owned = false;
21223         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21224         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21225         uint64_t ret_ref = 0;
21226         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21227         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21228         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21229         ret_ref = (uint64_t)ret_var.inner;
21230         if (ret_var.is_owned) {
21231                 ret_ref |= 1;
21232         }
21233         return ret_ref;
21234 }
21235
21236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
21237         LDKWatchedOutput o_conv;
21238         o_conv.inner = (void*)(o & (~1));
21239         o_conv.is_owned = false;
21240         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21241         int64_t ret_val = WatchedOutput_hash(&o_conv);
21242         return ret_val;
21243 }
21244
21245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21246         if ((this_ptr & 1) != 0) return;
21247         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21248         CHECK_ACCESS(this_ptr_ptr);
21249         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21250         FREE((void*)this_ptr);
21251         BroadcasterInterface_free(this_ptr_conv);
21252 }
21253
21254 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21255         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21256         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
21257         return ret_conv;
21258 }
21259
21260 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
21261         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
21262         return ret_conv;
21263 }
21264
21265 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
21266         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
21267         return ret_conv;
21268 }
21269
21270 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
21271         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
21272         return ret_conv;
21273 }
21274
21275 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
21276         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21277         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21278         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
21279         return ret_val;
21280 }
21281
21282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21283         if ((this_ptr & 1) != 0) return;
21284         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21285         CHECK_ACCESS(this_ptr_ptr);
21286         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21287         FREE((void*)this_ptr);
21288         FeeEstimator_free(this_ptr_conv);
21289 }
21290
21291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21292         LDKMonitorUpdateId this_obj_conv;
21293         this_obj_conv.inner = (void*)(this_obj & (~1));
21294         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21296         MonitorUpdateId_free(this_obj_conv);
21297 }
21298
21299 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21300         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21301 uint64_t ret_ref = 0;
21302 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21303 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21304 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21305 ret_ref = (uint64_t)ret_var.inner;
21306 if (ret_var.is_owned) {
21307         ret_ref |= 1;
21308 }
21309         return ret_ref;
21310 }
21311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21312         LDKMonitorUpdateId arg_conv;
21313         arg_conv.inner = (void*)(arg & (~1));
21314         arg_conv.is_owned = false;
21315         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21316         int64_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
21317         return ret_val;
21318 }
21319
21320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21321         LDKMonitorUpdateId orig_conv;
21322         orig_conv.inner = (void*)(orig & (~1));
21323         orig_conv.is_owned = false;
21324         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21325         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21326         uint64_t ret_ref = 0;
21327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21330         ret_ref = (uint64_t)ret_var.inner;
21331         if (ret_var.is_owned) {
21332                 ret_ref |= 1;
21333         }
21334         return ret_ref;
21335 }
21336
21337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
21338         LDKMonitorUpdateId o_conv;
21339         o_conv.inner = (void*)(o & (~1));
21340         o_conv.is_owned = false;
21341         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21342         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
21343         return ret_val;
21344 }
21345
21346 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
21347         LDKMonitorUpdateId a_conv;
21348         a_conv.inner = (void*)(a & (~1));
21349         a_conv.is_owned = false;
21350         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21351         LDKMonitorUpdateId b_conv;
21352         b_conv.inner = (void*)(b & (~1));
21353         b_conv.is_owned = false;
21354         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21355         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
21356         return ret_val;
21357 }
21358
21359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21360         if ((this_ptr & 1) != 0) return;
21361         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21362         CHECK_ACCESS(this_ptr_ptr);
21363         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21364         FREE((void*)this_ptr);
21365         Persist_free(this_ptr_conv);
21366 }
21367
21368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21369         LDKLockedChannelMonitor this_obj_conv;
21370         this_obj_conv.inner = (void*)(this_obj & (~1));
21371         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21373         LockedChannelMonitor_free(this_obj_conv);
21374 }
21375
21376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21377         LDKChainMonitor this_obj_conv;
21378         this_obj_conv.inner = (void*)(this_obj & (~1));
21379         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21381         ChainMonitor_free(this_obj_conv);
21382 }
21383
21384 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) {
21385         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
21386         CHECK_ACCESS(chain_source_ptr);
21387         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21388         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
21389         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21390                 // Manually implement clone for Java trait instances
21391                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
21392                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21393                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
21394                 }
21395         }
21396         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
21397         CHECK_ACCESS(broadcaster_ptr);
21398         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21399         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
21400                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21401                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
21402         }
21403         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
21404         CHECK_ACCESS(logger_ptr);
21405         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21406         if (logger_conv.free == LDKLogger_JCalls_free) {
21407                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21408                 LDKLogger_JCalls_cloned(&logger_conv);
21409         }
21410         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
21411         CHECK_ACCESS(feeest_ptr);
21412         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21413         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
21414                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21415                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
21416         }
21417         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
21418         CHECK_ACCESS(persister_ptr);
21419         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21420         if (persister_conv.free == LDKPersist_JCalls_free) {
21421                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21422                 LDKPersist_JCalls_cloned(&persister_conv);
21423         }
21424         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21425         uint64_t ret_ref = 0;
21426         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21427         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21428         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21429         ret_ref = (uint64_t)ret_var.inner;
21430         if (ret_var.is_owned) {
21431                 ret_ref |= 1;
21432         }
21433         return ret_ref;
21434 }
21435
21436 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) {
21437         LDKChainMonitor this_arg_conv;
21438         this_arg_conv.inner = (void*)(this_arg & (~1));
21439         this_arg_conv.is_owned = false;
21440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21441         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21442         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
21443         if (ignored_channels_constr.datalen > 0)
21444                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21445         else
21446                 ignored_channels_constr.data = NULL;
21447         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
21448         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21449                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
21450                 LDKChannelDetails ignored_channels_conv_16_conv;
21451                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21452                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21453                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21454                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21455                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21456         }
21457         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
21458         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21459         int64_tArray ret_arr = NULL;
21460         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
21461         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
21462         for (size_t j = 0; j < ret_var.datalen; j++) {
21463                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21464                 *ret_conv_9_copy = ret_var.data[j];
21465                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
21466                 ret_arr_ptr[j] = ret_conv_9_ref;
21467         }
21468         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
21469         FREE(ret_var.data);
21470         return ret_arr;
21471 }
21472
21473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
21474         LDKChainMonitor this_arg_conv;
21475         this_arg_conv.inner = (void*)(this_arg & (~1));
21476         this_arg_conv.is_owned = false;
21477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21478         LDKOutPoint funding_txo_conv;
21479         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21480         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21481         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21482         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21483         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21484         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21485         return (uint64_t)ret_conv;
21486 }
21487
21488 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
21489         LDKChainMonitor this_arg_conv;
21490         this_arg_conv.inner = (void*)(this_arg & (~1));
21491         this_arg_conv.is_owned = false;
21492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21493         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21494         int64_tArray ret_arr = NULL;
21495         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
21496         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
21497         for (size_t k = 0; k < ret_var.datalen; k++) {
21498                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21499                 uint64_t ret_conv_10_ref = 0;
21500                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21501                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21502                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21503                 ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
21504                 if (ret_conv_10_var.is_owned) {
21505                         ret_conv_10_ref |= 1;
21506                 }
21507                 ret_arr_ptr[k] = ret_conv_10_ref;
21508         }
21509         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
21510         FREE(ret_var.data);
21511         return ret_arr;
21512 }
21513
21514 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) {
21515         LDKChainMonitor this_arg_conv;
21516         this_arg_conv.inner = (void*)(this_arg & (~1));
21517         this_arg_conv.is_owned = false;
21518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21519         LDKOutPoint funding_txo_conv;
21520         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21521         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21522         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21523         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21524         LDKMonitorUpdateId completed_update_id_conv;
21525         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21526         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21527         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21528         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21529         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21530         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21531         return (uint64_t)ret_conv;
21532 }
21533
21534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
21535         LDKChainMonitor this_arg_conv;
21536         this_arg_conv.inner = (void*)(this_arg & (~1));
21537         this_arg_conv.is_owned = false;
21538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21539         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21540         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21541         return (uint64_t)ret_ret;
21542 }
21543
21544 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
21545         LDKChainMonitor this_arg_conv;
21546         this_arg_conv.inner = (void*)(this_arg & (~1));
21547         this_arg_conv.is_owned = false;
21548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21549         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21550         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21551         return (uint64_t)ret_ret;
21552 }
21553
21554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
21555         LDKChainMonitor this_arg_conv;
21556         this_arg_conv.inner = (void*)(this_arg & (~1));
21557         this_arg_conv.is_owned = false;
21558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21559         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21560         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21561         return (uint64_t)ret_ret;
21562 }
21563
21564 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21565         LDKChainMonitor this_arg_conv;
21566         this_arg_conv.inner = (void*)(this_arg & (~1));
21567         this_arg_conv.is_owned = false;
21568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21569         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21570         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21571         return (uint64_t)ret_ret;
21572 }
21573
21574 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21575         LDKChannelMonitorUpdate this_obj_conv;
21576         this_obj_conv.inner = (void*)(this_obj & (~1));
21577         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21579         ChannelMonitorUpdate_free(this_obj_conv);
21580 }
21581
21582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21583         LDKChannelMonitorUpdate this_ptr_conv;
21584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21585         this_ptr_conv.is_owned = false;
21586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21587         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
21588         return ret_val;
21589 }
21590
21591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21592         LDKChannelMonitorUpdate this_ptr_conv;
21593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21594         this_ptr_conv.is_owned = false;
21595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21596         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
21597 }
21598
21599 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
21600         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
21601 uint64_t ret_ref = 0;
21602 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21603 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21604 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21605 ret_ref = (uint64_t)ret_var.inner;
21606 if (ret_var.is_owned) {
21607         ret_ref |= 1;
21608 }
21609         return ret_ref;
21610 }
21611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21612         LDKChannelMonitorUpdate arg_conv;
21613         arg_conv.inner = (void*)(arg & (~1));
21614         arg_conv.is_owned = false;
21615         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21616         int64_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
21617         return ret_val;
21618 }
21619
21620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21621         LDKChannelMonitorUpdate orig_conv;
21622         orig_conv.inner = (void*)(orig & (~1));
21623         orig_conv.is_owned = false;
21624         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21625         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
21626         uint64_t ret_ref = 0;
21627         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21628         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21629         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21630         ret_ref = (uint64_t)ret_var.inner;
21631         if (ret_var.is_owned) {
21632                 ret_ref |= 1;
21633         }
21634         return ret_ref;
21635 }
21636
21637 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21638         LDKChannelMonitorUpdate obj_conv;
21639         obj_conv.inner = (void*)(obj & (~1));
21640         obj_conv.is_owned = false;
21641         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21642         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
21643         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21644         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21645         CVec_u8Z_free(ret_var);
21646         return ret_arr;
21647 }
21648
21649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21650         LDKu8slice ser_ref;
21651         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21652         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21653         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21654         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
21655         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21656         return (uint64_t)ret_conv;
21657 }
21658
21659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21660         LDKMonitorUpdateError this_obj_conv;
21661         this_obj_conv.inner = (void*)(this_obj & (~1));
21662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21664         MonitorUpdateError_free(this_obj_conv);
21665 }
21666
21667 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
21668         LDKMonitorUpdateError this_ptr_conv;
21669         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21670         this_ptr_conv.is_owned = false;
21671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21672         LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
21673         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
21674         Str_free(ret_str);
21675         return ret_conv;
21676 }
21677
21678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
21679         LDKMonitorUpdateError this_ptr_conv;
21680         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21681         this_ptr_conv.is_owned = false;
21682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21683         LDKStr val_conv = java_to_owned_str(env, val);
21684         MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
21685 }
21686
21687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1new(JNIEnv *env, jclass clz, jstring a_arg) {
21688         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
21689         LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
21690         uint64_t ret_ref = 0;
21691         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21692         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21693         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21694         ret_ref = (uint64_t)ret_var.inner;
21695         if (ret_var.is_owned) {
21696                 ret_ref |= 1;
21697         }
21698         return ret_ref;
21699 }
21700
21701 static inline uint64_t MonitorUpdateError_clone_ptr(LDKMonitorUpdateError *NONNULL_PTR arg) {
21702         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(arg);
21703 uint64_t ret_ref = 0;
21704 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21705 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21706 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21707 ret_ref = (uint64_t)ret_var.inner;
21708 if (ret_var.is_owned) {
21709         ret_ref |= 1;
21710 }
21711         return ret_ref;
21712 }
21713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21714         LDKMonitorUpdateError arg_conv;
21715         arg_conv.inner = (void*)(arg & (~1));
21716         arg_conv.is_owned = false;
21717         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21718         int64_t ret_val = MonitorUpdateError_clone_ptr(&arg_conv);
21719         return ret_val;
21720 }
21721
21722 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21723         LDKMonitorUpdateError orig_conv;
21724         orig_conv.inner = (void*)(orig & (~1));
21725         orig_conv.is_owned = false;
21726         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21727         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
21728         uint64_t ret_ref = 0;
21729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21732         ret_ref = (uint64_t)ret_var.inner;
21733         if (ret_var.is_owned) {
21734                 ret_ref |= 1;
21735         }
21736         return ret_ref;
21737 }
21738
21739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21740         if ((this_ptr & 1) != 0) return;
21741         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21742         CHECK_ACCESS(this_ptr_ptr);
21743         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
21744         FREE((void*)this_ptr);
21745         MonitorEvent_free(this_ptr_conv);
21746 }
21747
21748 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
21749         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21750         *ret_copy = MonitorEvent_clone(arg);
21751 uint64_t ret_ref = (uint64_t)ret_copy;
21752         return ret_ref;
21753 }
21754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21755         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
21756         int64_t ret_val = MonitorEvent_clone_ptr(arg_conv);
21757         return ret_val;
21758 }
21759
21760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21761         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
21762         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21763         *ret_copy = MonitorEvent_clone(orig_conv);
21764         uint64_t ret_ref = (uint64_t)ret_copy;
21765         return ret_ref;
21766 }
21767
21768 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
21769         LDKHTLCUpdate a_conv;
21770         a_conv.inner = (void*)(a & (~1));
21771         a_conv.is_owned = (a & 1) || (a == 0);
21772         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21773         a_conv = HTLCUpdate_clone(&a_conv);
21774         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21775         *ret_copy = MonitorEvent_htlcevent(a_conv);
21776         uint64_t ret_ref = (uint64_t)ret_copy;
21777         return ret_ref;
21778 }
21779
21780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
21781         LDKOutPoint a_conv;
21782         a_conv.inner = (void*)(a & (~1));
21783         a_conv.is_owned = (a & 1) || (a == 0);
21784         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21785         a_conv = OutPoint_clone(&a_conv);
21786         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21787         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
21788         uint64_t ret_ref = (uint64_t)ret_copy;
21789         return ret_ref;
21790 }
21791
21792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1completed(JNIEnv *env, jclass clz, int64_t funding_txo, int64_t monitor_update_id) {
21793         LDKOutPoint funding_txo_conv;
21794         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21795         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21796         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21797         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21798         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21799         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
21800         uint64_t ret_ref = (uint64_t)ret_copy;
21801         return ret_ref;
21802 }
21803
21804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
21805         LDKOutPoint a_conv;
21806         a_conv.inner = (void*)(a & (~1));
21807         a_conv.is_owned = (a & 1) || (a == 0);
21808         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21809         a_conv = OutPoint_clone(&a_conv);
21810         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21811         *ret_copy = MonitorEvent_update_failed(a_conv);
21812         uint64_t ret_ref = (uint64_t)ret_copy;
21813         return ret_ref;
21814 }
21815
21816 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
21817         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
21818         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
21819         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21820         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21821         CVec_u8Z_free(ret_var);
21822         return ret_arr;
21823 }
21824
21825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21826         LDKu8slice ser_ref;
21827         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21828         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21829         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21830         *ret_conv = MonitorEvent_read(ser_ref);
21831         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21832         return (uint64_t)ret_conv;
21833 }
21834
21835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21836         LDKHTLCUpdate this_obj_conv;
21837         this_obj_conv.inner = (void*)(this_obj & (~1));
21838         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21840         HTLCUpdate_free(this_obj_conv);
21841 }
21842
21843 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
21844         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
21845 uint64_t ret_ref = 0;
21846 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21847 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21848 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21849 ret_ref = (uint64_t)ret_var.inner;
21850 if (ret_var.is_owned) {
21851         ret_ref |= 1;
21852 }
21853         return ret_ref;
21854 }
21855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21856         LDKHTLCUpdate arg_conv;
21857         arg_conv.inner = (void*)(arg & (~1));
21858         arg_conv.is_owned = false;
21859         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21860         int64_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
21861         return ret_val;
21862 }
21863
21864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21865         LDKHTLCUpdate orig_conv;
21866         orig_conv.inner = (void*)(orig & (~1));
21867         orig_conv.is_owned = false;
21868         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21869         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
21870         uint64_t ret_ref = 0;
21871         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21872         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21873         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21874         ret_ref = (uint64_t)ret_var.inner;
21875         if (ret_var.is_owned) {
21876                 ret_ref |= 1;
21877         }
21878         return ret_ref;
21879 }
21880
21881 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21882         LDKHTLCUpdate obj_conv;
21883         obj_conv.inner = (void*)(obj & (~1));
21884         obj_conv.is_owned = false;
21885         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21886         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
21887         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21888         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21889         CVec_u8Z_free(ret_var);
21890         return ret_arr;
21891 }
21892
21893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21894         LDKu8slice ser_ref;
21895         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21896         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21897         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21898         *ret_conv = HTLCUpdate_read(ser_ref);
21899         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21900         return (uint64_t)ret_conv;
21901 }
21902
21903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21904         if ((this_ptr & 1) != 0) return;
21905         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21906         CHECK_ACCESS(this_ptr_ptr);
21907         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
21908         FREE((void*)this_ptr);
21909         Balance_free(this_ptr_conv);
21910 }
21911
21912 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
21913         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21914         *ret_copy = Balance_clone(arg);
21915 uint64_t ret_ref = (uint64_t)ret_copy;
21916         return ret_ref;
21917 }
21918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21919         LDKBalance* arg_conv = (LDKBalance*)arg;
21920         int64_t ret_val = Balance_clone_ptr(arg_conv);
21921         return ret_val;
21922 }
21923
21924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21925         LDKBalance* orig_conv = (LDKBalance*)orig;
21926         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21927         *ret_copy = Balance_clone(orig_conv);
21928         uint64_t ret_ref = (uint64_t)ret_copy;
21929         return ret_ref;
21930 }
21931
21932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
21933         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21934         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
21935         uint64_t ret_ref = (uint64_t)ret_copy;
21936         return ret_ref;
21937 }
21938
21939 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) {
21940         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21941         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
21942         uint64_t ret_ref = (uint64_t)ret_copy;
21943         return ret_ref;
21944 }
21945
21946 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) {
21947         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21948         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
21949         uint64_t ret_ref = (uint64_t)ret_copy;
21950         return ret_ref;
21951 }
21952
21953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1maybe_1claimable_1htlcawaiting_1timeout(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis, int32_t claimable_height) {
21954         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21955         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
21956         uint64_t ret_ref = (uint64_t)ret_copy;
21957         return ret_ref;
21958 }
21959
21960 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
21961         LDKBalance* a_conv = (LDKBalance*)a;
21962         LDKBalance* b_conv = (LDKBalance*)b;
21963         jboolean ret_val = Balance_eq(a_conv, b_conv);
21964         return ret_val;
21965 }
21966
21967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21968         LDKChannelMonitor this_obj_conv;
21969         this_obj_conv.inner = (void*)(this_obj & (~1));
21970         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21972         ChannelMonitor_free(this_obj_conv);
21973 }
21974
21975 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
21976         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
21977 uint64_t ret_ref = 0;
21978 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21979 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21980 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21981 ret_ref = (uint64_t)ret_var.inner;
21982 if (ret_var.is_owned) {
21983         ret_ref |= 1;
21984 }
21985         return ret_ref;
21986 }
21987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21988         LDKChannelMonitor arg_conv;
21989         arg_conv.inner = (void*)(arg & (~1));
21990         arg_conv.is_owned = false;
21991         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21992         int64_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
21993         return ret_val;
21994 }
21995
21996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21997         LDKChannelMonitor orig_conv;
21998         orig_conv.inner = (void*)(orig & (~1));
21999         orig_conv.is_owned = false;
22000         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22001         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22002         uint64_t ret_ref = 0;
22003         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22004         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22006         ret_ref = (uint64_t)ret_var.inner;
22007         if (ret_var.is_owned) {
22008                 ret_ref |= 1;
22009         }
22010         return ret_ref;
22011 }
22012
22013 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
22014         LDKChannelMonitor obj_conv;
22015         obj_conv.inner = (void*)(obj & (~1));
22016         obj_conv.is_owned = false;
22017         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22018         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22019         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22020         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22021         CVec_u8Z_free(ret_var);
22022         return ret_arr;
22023 }
22024
22025 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) {
22026         LDKChannelMonitor this_arg_conv;
22027         this_arg_conv.inner = (void*)(this_arg & (~1));
22028         this_arg_conv.is_owned = false;
22029         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22030         LDKChannelMonitorUpdate updates_conv;
22031         updates_conv.inner = (void*)(updates & (~1));
22032         updates_conv.is_owned = false;
22033         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22034         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22035         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22036         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22037         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22038         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22039         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22040         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22041         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22042         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22043         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
22044         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22045         return (uint64_t)ret_conv;
22046 }
22047
22048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
22049         LDKChannelMonitor this_arg_conv;
22050         this_arg_conv.inner = (void*)(this_arg & (~1));
22051         this_arg_conv.is_owned = false;
22052         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22053         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22054         return ret_val;
22055 }
22056
22057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
22058         LDKChannelMonitor this_arg_conv;
22059         this_arg_conv.inner = (void*)(this_arg & (~1));
22060         this_arg_conv.is_owned = false;
22061         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22062         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22063         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22064         return ((uint64_t)ret_conv);
22065 }
22066
22067 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
22068         LDKChannelMonitor this_arg_conv;
22069         this_arg_conv.inner = (void*)(this_arg & (~1));
22070         this_arg_conv.is_owned = false;
22071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22072         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22073         int64_tArray ret_arr = NULL;
22074         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22075         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22076         for (size_t o = 0; o < ret_var.datalen; o++) {
22077                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22078                 *ret_conv_40_conv = ret_var.data[o];
22079                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
22080         }
22081         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22082         FREE(ret_var.data);
22083         return ret_arr;
22084 }
22085
22086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
22087         LDKChannelMonitor this_arg_conv;
22088         this_arg_conv.inner = (void*)(this_arg & (~1));
22089         this_arg_conv.is_owned = false;
22090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22091         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
22092         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22093         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22094         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22095 }
22096
22097 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22098         LDKChannelMonitor this_arg_conv;
22099         this_arg_conv.inner = (void*)(this_arg & (~1));
22100         this_arg_conv.is_owned = false;
22101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22102         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22103         int64_tArray ret_arr = NULL;
22104         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22105         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22106         for (size_t o = 0; o < ret_var.datalen; o++) {
22107                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22108                 *ret_conv_14_copy = ret_var.data[o];
22109                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
22110                 ret_arr_ptr[o] = ret_conv_14_ref;
22111         }
22112         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22113         FREE(ret_var.data);
22114         return ret_arr;
22115 }
22116
22117 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22118         LDKChannelMonitor this_arg_conv;
22119         this_arg_conv.inner = (void*)(this_arg & (~1));
22120         this_arg_conv.is_owned = false;
22121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22122         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22123         int64_tArray ret_arr = NULL;
22124         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22125         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22126         for (size_t h = 0; h < ret_var.datalen; h++) {
22127                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22128                 *ret_conv_7_copy = ret_var.data[h];
22129                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
22130                 ret_arr_ptr[h] = ret_conv_7_ref;
22131         }
22132         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22133         FREE(ret_var.data);
22134         return ret_arr;
22135 }
22136
22137 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) {
22138         LDKChannelMonitor this_arg_conv;
22139         this_arg_conv.inner = (void*)(this_arg & (~1));
22140         this_arg_conv.is_owned = false;
22141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22142         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22143         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22144         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22145         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22146         jobjectArray ret_arr = NULL;
22147         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22148         ;
22149         for (size_t i = 0; i < ret_var.datalen; i++) {
22150                 LDKTransaction ret_conv_8_var = ret_var.data[i];
22151                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
22152                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
22153                 Transaction_free(ret_conv_8_var);
22154                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22155         }
22156         
22157         FREE(ret_var.data);
22158         return ret_arr;
22159 }
22160
22161 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) {
22162         LDKChannelMonitor this_arg_conv;
22163         this_arg_conv.inner = (void*)(this_arg & (~1));
22164         this_arg_conv.is_owned = false;
22165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22166         unsigned char header_arr[80];
22167         CHECK((*env)->GetArrayLength(env, header) == 80);
22168         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22169         unsigned char (*header_ref)[80] = &header_arr;
22170         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22171         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
22172         if (txdata_constr.datalen > 0)
22173                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22174         else
22175                 txdata_constr.data = NULL;
22176         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
22177         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22178                 int64_t txdata_conv_28 = txdata_vals[c];
22179                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
22180                 CHECK_ACCESS(txdata_conv_28_ptr);
22181                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22182                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
22183                 txdata_constr.data[c] = txdata_conv_28_conv;
22184         }
22185         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
22186         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22187         CHECK_ACCESS(broadcaster_ptr);
22188         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22189         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22190                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22191                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22192         }
22193         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22194         CHECK_ACCESS(fee_estimator_ptr);
22195         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22196         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22197                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22198                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22199         }
22200         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22201         CHECK_ACCESS(logger_ptr);
22202         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22203         if (logger_conv.free == LDKLogger_JCalls_free) {
22204                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22205                 LDKLogger_JCalls_cloned(&logger_conv);
22206         }
22207         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);
22208         int64_tArray ret_arr = NULL;
22209         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22210         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22211         for (size_t n = 0; n < ret_var.datalen; n++) {
22212                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22213                 *ret_conv_39_conv = ret_var.data[n];
22214                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
22215         }
22216         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22217         FREE(ret_var.data);
22218         return ret_arr;
22219 }
22220
22221 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) {
22222         LDKChannelMonitor this_arg_conv;
22223         this_arg_conv.inner = (void*)(this_arg & (~1));
22224         this_arg_conv.is_owned = false;
22225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22226         unsigned char header_arr[80];
22227         CHECK((*env)->GetArrayLength(env, header) == 80);
22228         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22229         unsigned char (*header_ref)[80] = &header_arr;
22230         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22231         CHECK_ACCESS(broadcaster_ptr);
22232         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22233         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22234                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22235                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22236         }
22237         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22238         CHECK_ACCESS(fee_estimator_ptr);
22239         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22240         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22241                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22242                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22243         }
22244         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22245         CHECK_ACCESS(logger_ptr);
22246         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22247         if (logger_conv.free == LDKLogger_JCalls_free) {
22248                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22249                 LDKLogger_JCalls_cloned(&logger_conv);
22250         }
22251         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22252 }
22253
22254 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) {
22255         LDKChannelMonitor this_arg_conv;
22256         this_arg_conv.inner = (void*)(this_arg & (~1));
22257         this_arg_conv.is_owned = false;
22258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22259         unsigned char header_arr[80];
22260         CHECK((*env)->GetArrayLength(env, header) == 80);
22261         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22262         unsigned char (*header_ref)[80] = &header_arr;
22263         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22264         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
22265         if (txdata_constr.datalen > 0)
22266                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22267         else
22268                 txdata_constr.data = NULL;
22269         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
22270         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22271                 int64_t txdata_conv_28 = txdata_vals[c];
22272                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
22273                 CHECK_ACCESS(txdata_conv_28_ptr);
22274                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22275                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
22276                 txdata_constr.data[c] = txdata_conv_28_conv;
22277         }
22278         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
22279         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22280         CHECK_ACCESS(broadcaster_ptr);
22281         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22282         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22283                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22284                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22285         }
22286         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22287         CHECK_ACCESS(fee_estimator_ptr);
22288         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22289         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22290                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22291                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22292         }
22293         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22294         CHECK_ACCESS(logger_ptr);
22295         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22296         if (logger_conv.free == LDKLogger_JCalls_free) {
22297                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22298                 LDKLogger_JCalls_cloned(&logger_conv);
22299         }
22300         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);
22301         int64_tArray ret_arr = NULL;
22302         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22303         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22304         for (size_t n = 0; n < ret_var.datalen; n++) {
22305                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22306                 *ret_conv_39_conv = ret_var.data[n];
22307                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
22308         }
22309         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22310         FREE(ret_var.data);
22311         return ret_arr;
22312 }
22313
22314 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) {
22315         LDKChannelMonitor this_arg_conv;
22316         this_arg_conv.inner = (void*)(this_arg & (~1));
22317         this_arg_conv.is_owned = false;
22318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22319         unsigned char txid_arr[32];
22320         CHECK((*env)->GetArrayLength(env, txid) == 32);
22321         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
22322         unsigned char (*txid_ref)[32] = &txid_arr;
22323         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22324         CHECK_ACCESS(broadcaster_ptr);
22325         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22326         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22327                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22328                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22329         }
22330         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22331         CHECK_ACCESS(fee_estimator_ptr);
22332         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22333         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22334                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22335                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22336         }
22337         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22338         CHECK_ACCESS(logger_ptr);
22339         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22340         if (logger_conv.free == LDKLogger_JCalls_free) {
22341                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22342                 LDKLogger_JCalls_cloned(&logger_conv);
22343         }
22344         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22345 }
22346
22347 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) {
22348         LDKChannelMonitor this_arg_conv;
22349         this_arg_conv.inner = (void*)(this_arg & (~1));
22350         this_arg_conv.is_owned = false;
22351         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22352         unsigned char header_arr[80];
22353         CHECK((*env)->GetArrayLength(env, header) == 80);
22354         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22355         unsigned char (*header_ref)[80] = &header_arr;
22356         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22357         CHECK_ACCESS(broadcaster_ptr);
22358         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22359         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22360                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22361                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22362         }
22363         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22364         CHECK_ACCESS(fee_estimator_ptr);
22365         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22366         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22367                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22368                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22369         }
22370         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22371         CHECK_ACCESS(logger_ptr);
22372         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22373         if (logger_conv.free == LDKLogger_JCalls_free) {
22374                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22375                 LDKLogger_JCalls_cloned(&logger_conv);
22376         }
22377         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22378         int64_tArray ret_arr = NULL;
22379         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22380         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22381         for (size_t n = 0; n < ret_var.datalen; n++) {
22382                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22383                 *ret_conv_39_conv = ret_var.data[n];
22384                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
22385         }
22386         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22387         FREE(ret_var.data);
22388         return ret_arr;
22389 }
22390
22391 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
22392         LDKChannelMonitor this_arg_conv;
22393         this_arg_conv.inner = (void*)(this_arg & (~1));
22394         this_arg_conv.is_owned = false;
22395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22396         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22397         jobjectArray ret_arr = NULL;
22398         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22399         ;
22400         for (size_t i = 0; i < ret_var.datalen; i++) {
22401                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
22402                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
22403                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22404         }
22405         
22406         FREE(ret_var.data);
22407         return ret_arr;
22408 }
22409
22410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
22411         LDKChannelMonitor this_arg_conv;
22412         this_arg_conv.inner = (void*)(this_arg & (~1));
22413         this_arg_conv.is_owned = false;
22414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22415         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22416         uint64_t ret_ref = 0;
22417         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22418         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22420         ret_ref = (uint64_t)ret_var.inner;
22421         if (ret_var.is_owned) {
22422                 ret_ref |= 1;
22423         }
22424         return ret_ref;
22425 }
22426
22427 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
22428         LDKChannelMonitor this_arg_conv;
22429         this_arg_conv.inner = (void*)(this_arg & (~1));
22430         this_arg_conv.is_owned = false;
22431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22432         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22433         int64_tArray ret_arr = NULL;
22434         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22435         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22436         for (size_t j = 0; j < ret_var.datalen; j++) {
22437                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22438                 *ret_conv_9_copy = ret_var.data[j];
22439                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
22440                 ret_arr_ptr[j] = ret_conv_9_ref;
22441         }
22442         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22443         FREE(ret_var.data);
22444         return ret_arr;
22445 }
22446
22447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
22448         LDKu8slice ser_ref;
22449         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22450         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22451         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
22452         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22453         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22454         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22455         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22456         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22457         return (uint64_t)ret_conv;
22458 }
22459
22460 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22461         LDKOutPoint this_obj_conv;
22462         this_obj_conv.inner = (void*)(this_obj & (~1));
22463         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22465         OutPoint_free(this_obj_conv);
22466 }
22467
22468 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22469         LDKOutPoint this_ptr_conv;
22470         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22471         this_ptr_conv.is_owned = false;
22472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22473         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22474         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
22475         return ret_arr;
22476 }
22477
22478 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22479         LDKOutPoint this_ptr_conv;
22480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22481         this_ptr_conv.is_owned = false;
22482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22483         LDKThirtyTwoBytes val_ref;
22484         CHECK((*env)->GetArrayLength(env, val) == 32);
22485         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22486         OutPoint_set_txid(&this_ptr_conv, val_ref);
22487 }
22488
22489 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
22490         LDKOutPoint this_ptr_conv;
22491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22492         this_ptr_conv.is_owned = false;
22493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22494         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
22495         return ret_val;
22496 }
22497
22498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22499         LDKOutPoint this_ptr_conv;
22500         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22501         this_ptr_conv.is_owned = false;
22502         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22503         OutPoint_set_index(&this_ptr_conv, val);
22504 }
22505
22506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
22507         LDKThirtyTwoBytes txid_arg_ref;
22508         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22509         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22510         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22511         uint64_t ret_ref = 0;
22512         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22513         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22514         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22515         ret_ref = (uint64_t)ret_var.inner;
22516         if (ret_var.is_owned) {
22517                 ret_ref |= 1;
22518         }
22519         return ret_ref;
22520 }
22521
22522 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22523         LDKOutPoint ret_var = OutPoint_clone(arg);
22524 uint64_t ret_ref = 0;
22525 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22526 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22527 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22528 ret_ref = (uint64_t)ret_var.inner;
22529 if (ret_var.is_owned) {
22530         ret_ref |= 1;
22531 }
22532         return ret_ref;
22533 }
22534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22535         LDKOutPoint arg_conv;
22536         arg_conv.inner = (void*)(arg & (~1));
22537         arg_conv.is_owned = false;
22538         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22539         int64_t ret_val = OutPoint_clone_ptr(&arg_conv);
22540         return ret_val;
22541 }
22542
22543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22544         LDKOutPoint orig_conv;
22545         orig_conv.inner = (void*)(orig & (~1));
22546         orig_conv.is_owned = false;
22547         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22548         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22549         uint64_t ret_ref = 0;
22550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22553         ret_ref = (uint64_t)ret_var.inner;
22554         if (ret_var.is_owned) {
22555                 ret_ref |= 1;
22556         }
22557         return ret_ref;
22558 }
22559
22560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22561         LDKOutPoint a_conv;
22562         a_conv.inner = (void*)(a & (~1));
22563         a_conv.is_owned = false;
22564         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22565         LDKOutPoint b_conv;
22566         b_conv.inner = (void*)(b & (~1));
22567         b_conv.is_owned = false;
22568         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22569         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
22570         return ret_val;
22571 }
22572
22573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
22574         LDKOutPoint o_conv;
22575         o_conv.inner = (void*)(o & (~1));
22576         o_conv.is_owned = false;
22577         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22578         int64_t ret_val = OutPoint_hash(&o_conv);
22579         return ret_val;
22580 }
22581
22582 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
22583         LDKOutPoint this_arg_conv;
22584         this_arg_conv.inner = (void*)(this_arg & (~1));
22585         this_arg_conv.is_owned = false;
22586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22587         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22588         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
22589         return ret_arr;
22590 }
22591
22592 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
22593         LDKOutPoint obj_conv;
22594         obj_conv.inner = (void*)(obj & (~1));
22595         obj_conv.is_owned = false;
22596         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22597         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22598         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22599         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22600         CVec_u8Z_free(ret_var);
22601         return ret_arr;
22602 }
22603
22604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22605         LDKu8slice ser_ref;
22606         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22607         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22608         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22609         *ret_conv = OutPoint_read(ser_ref);
22610         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22611         return (uint64_t)ret_conv;
22612 }
22613
22614 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22615         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22616         this_obj_conv.inner = (void*)(this_obj & (~1));
22617         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22619         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22620 }
22621
22622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22623         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22624         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22625         this_ptr_conv.is_owned = false;
22626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22627         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22628         uint64_t ret_ref = 0;
22629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22632         ret_ref = (uint64_t)ret_var.inner;
22633         if (ret_var.is_owned) {
22634                 ret_ref |= 1;
22635         }
22636         return ret_ref;
22637 }
22638
22639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22640         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22642         this_ptr_conv.is_owned = false;
22643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22644         LDKOutPoint val_conv;
22645         val_conv.inner = (void*)(val & (~1));
22646         val_conv.is_owned = (val & 1) || (val == 0);
22647         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22648         val_conv = OutPoint_clone(&val_conv);
22649         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22650 }
22651
22652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22653         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22654         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22655         this_ptr_conv.is_owned = false;
22656         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22657         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22658         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
22659         return ret_arr;
22660 }
22661
22662 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22663         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22665         this_ptr_conv.is_owned = false;
22666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22667         LDKPublicKey val_ref;
22668         CHECK((*env)->GetArrayLength(env, val) == 33);
22669         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22670         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
22671 }
22672
22673 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22674         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22676         this_ptr_conv.is_owned = false;
22677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22678         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
22679         return ret_val;
22680 }
22681
22682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22683         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22685         this_ptr_conv.is_owned = false;
22686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22687         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
22688 }
22689
22690 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22691         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22693         this_ptr_conv.is_owned = false;
22694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22695         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22696         CHECK_ACCESS(val_ptr);
22697         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22698         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
22699         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22700 }
22701
22702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22703         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22705         this_ptr_conv.is_owned = false;
22706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22707         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
22709         return ret_arr;
22710 }
22711
22712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22713         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22715         this_ptr_conv.is_owned = false;
22716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22717         LDKPublicKey val_ref;
22718         CHECK((*env)->GetArrayLength(env, val) == 33);
22719         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22720         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
22721 }
22722
22723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22724         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22726         this_ptr_conv.is_owned = false;
22727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22728         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22729         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
22730         return ret_arr;
22731 }
22732
22733 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22734         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22735         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22736         this_ptr_conv.is_owned = false;
22737         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22738         LDKThirtyTwoBytes val_ref;
22739         CHECK((*env)->GetArrayLength(env, val) == 32);
22740         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22741         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22742 }
22743
22744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22745         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22746         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22747         this_ptr_conv.is_owned = false;
22748         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22749         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22750         return ret_val;
22751 }
22752
22753 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22754         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22756         this_ptr_conv.is_owned = false;
22757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22758         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22759 }
22760
22761 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) {
22762         LDKOutPoint outpoint_arg_conv;
22763         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22764         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22765         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22766         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22767         LDKPublicKey per_commitment_point_arg_ref;
22768         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
22769         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
22770         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
22771         CHECK_ACCESS(output_arg_ptr);
22772         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22773         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
22774         LDKPublicKey revocation_pubkey_arg_ref;
22775         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
22776         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
22777         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22778         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
22779         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
22780         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);
22781         uint64_t ret_ref = 0;
22782         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22783         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22785         ret_ref = (uint64_t)ret_var.inner;
22786         if (ret_var.is_owned) {
22787                 ret_ref |= 1;
22788         }
22789         return ret_ref;
22790 }
22791
22792 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
22793         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
22794 uint64_t ret_ref = 0;
22795 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22796 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22797 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22798 ret_ref = (uint64_t)ret_var.inner;
22799 if (ret_var.is_owned) {
22800         ret_ref |= 1;
22801 }
22802         return ret_ref;
22803 }
22804 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22805         LDKDelayedPaymentOutputDescriptor arg_conv;
22806         arg_conv.inner = (void*)(arg & (~1));
22807         arg_conv.is_owned = false;
22808         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22809         int64_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
22810         return ret_val;
22811 }
22812
22813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22814         LDKDelayedPaymentOutputDescriptor orig_conv;
22815         orig_conv.inner = (void*)(orig & (~1));
22816         orig_conv.is_owned = false;
22817         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22818         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
22819         uint64_t ret_ref = 0;
22820         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22821         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22822         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22823         ret_ref = (uint64_t)ret_var.inner;
22824         if (ret_var.is_owned) {
22825                 ret_ref |= 1;
22826         }
22827         return ret_ref;
22828 }
22829
22830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
22831         LDKDelayedPaymentOutputDescriptor obj_conv;
22832         obj_conv.inner = (void*)(obj & (~1));
22833         obj_conv.is_owned = false;
22834         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22835         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
22836         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22837         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22838         CVec_u8Z_free(ret_var);
22839         return ret_arr;
22840 }
22841
22842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22843         LDKu8slice ser_ref;
22844         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22845         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22846         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
22847         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
22848         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22849         return (uint64_t)ret_conv;
22850 }
22851
22852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22853         LDKStaticPaymentOutputDescriptor this_obj_conv;
22854         this_obj_conv.inner = (void*)(this_obj & (~1));
22855         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22857         StaticPaymentOutputDescriptor_free(this_obj_conv);
22858 }
22859
22860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22861         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22863         this_ptr_conv.is_owned = false;
22864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22865         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22866         uint64_t ret_ref = 0;
22867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22870         ret_ref = (uint64_t)ret_var.inner;
22871         if (ret_var.is_owned) {
22872                 ret_ref |= 1;
22873         }
22874         return ret_ref;
22875 }
22876
22877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22878         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22880         this_ptr_conv.is_owned = false;
22881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22882         LDKOutPoint val_conv;
22883         val_conv.inner = (void*)(val & (~1));
22884         val_conv.is_owned = (val & 1) || (val == 0);
22885         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22886         val_conv = OutPoint_clone(&val_conv);
22887         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22888 }
22889
22890 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22891         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22893         this_ptr_conv.is_owned = false;
22894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22895         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22896         CHECK_ACCESS(val_ptr);
22897         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22898         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
22899         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22900 }
22901
22902 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22903         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22905         this_ptr_conv.is_owned = false;
22906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22907         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22908         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
22909         return ret_arr;
22910 }
22911
22912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22913         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22915         this_ptr_conv.is_owned = false;
22916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22917         LDKThirtyTwoBytes val_ref;
22918         CHECK((*env)->GetArrayLength(env, val) == 32);
22919         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22920         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22921 }
22922
22923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22924         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22926         this_ptr_conv.is_owned = false;
22927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22928         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22929         return ret_val;
22930 }
22931
22932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22933         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22935         this_ptr_conv.is_owned = false;
22936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22937         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22938 }
22939
22940 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) {
22941         LDKOutPoint outpoint_arg_conv;
22942         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22943         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22944         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22945         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22946         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
22947         CHECK_ACCESS(output_arg_ptr);
22948         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22949         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
22950         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22951         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
22952         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
22953         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
22954         uint64_t ret_ref = 0;
22955         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22956         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22957         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22958         ret_ref = (uint64_t)ret_var.inner;
22959         if (ret_var.is_owned) {
22960                 ret_ref |= 1;
22961         }
22962         return ret_ref;
22963 }
22964
22965 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
22966         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
22967 uint64_t ret_ref = 0;
22968 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22969 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22970 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22971 ret_ref = (uint64_t)ret_var.inner;
22972 if (ret_var.is_owned) {
22973         ret_ref |= 1;
22974 }
22975         return ret_ref;
22976 }
22977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22978         LDKStaticPaymentOutputDescriptor arg_conv;
22979         arg_conv.inner = (void*)(arg & (~1));
22980         arg_conv.is_owned = false;
22981         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22982         int64_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
22983         return ret_val;
22984 }
22985
22986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22987         LDKStaticPaymentOutputDescriptor orig_conv;
22988         orig_conv.inner = (void*)(orig & (~1));
22989         orig_conv.is_owned = false;
22990         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22991         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
22992         uint64_t ret_ref = 0;
22993         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22994         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22995         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22996         ret_ref = (uint64_t)ret_var.inner;
22997         if (ret_var.is_owned) {
22998                 ret_ref |= 1;
22999         }
23000         return ret_ref;
23001 }
23002
23003 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
23004         LDKStaticPaymentOutputDescriptor obj_conv;
23005         obj_conv.inner = (void*)(obj & (~1));
23006         obj_conv.is_owned = false;
23007         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23008         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23009         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23010         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23011         CVec_u8Z_free(ret_var);
23012         return ret_arr;
23013 }
23014
23015 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23016         LDKu8slice ser_ref;
23017         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23018         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23019         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23020         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23021         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23022         return (uint64_t)ret_conv;
23023 }
23024
23025 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23026         if ((this_ptr & 1) != 0) return;
23027         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23028         CHECK_ACCESS(this_ptr_ptr);
23029         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23030         FREE((void*)this_ptr);
23031         SpendableOutputDescriptor_free(this_ptr_conv);
23032 }
23033
23034 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23035         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23036         *ret_copy = SpendableOutputDescriptor_clone(arg);
23037 uint64_t ret_ref = (uint64_t)ret_copy;
23038         return ret_ref;
23039 }
23040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23041         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23042         int64_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
23043         return ret_val;
23044 }
23045
23046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23047         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
23048         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23049         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
23050         uint64_t ret_ref = (uint64_t)ret_copy;
23051         return ret_ref;
23052 }
23053
23054 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
23055         LDKOutPoint outpoint_conv;
23056         outpoint_conv.inner = (void*)(outpoint & (~1));
23057         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
23058         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
23059         outpoint_conv = OutPoint_clone(&outpoint_conv);
23060         void* output_ptr = (void*)(((uint64_t)output) & ~1);
23061         CHECK_ACCESS(output_ptr);
23062         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
23063         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
23064         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23065         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
23066         uint64_t ret_ref = (uint64_t)ret_copy;
23067         return ret_ref;
23068 }
23069
23070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
23071         LDKDelayedPaymentOutputDescriptor a_conv;
23072         a_conv.inner = (void*)(a & (~1));
23073         a_conv.is_owned = (a & 1) || (a == 0);
23074         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23075         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
23076         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23077         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
23078         uint64_t ret_ref = (uint64_t)ret_copy;
23079         return ret_ref;
23080 }
23081
23082 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
23083         LDKStaticPaymentOutputDescriptor a_conv;
23084         a_conv.inner = (void*)(a & (~1));
23085         a_conv.is_owned = (a & 1) || (a == 0);
23086         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23087         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
23088         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23089         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
23090         uint64_t ret_ref = (uint64_t)ret_copy;
23091         return ret_ref;
23092 }
23093
23094 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
23095         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
23096         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
23097         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23098         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23099         CVec_u8Z_free(ret_var);
23100         return ret_arr;
23101 }
23102
23103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23104         LDKu8slice ser_ref;
23105         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23106         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23107         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23108         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23109         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23110         return (uint64_t)ret_conv;
23111 }
23112
23113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23114         if ((this_ptr & 1) != 0) return;
23115         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23116         CHECK_ACCESS(this_ptr_ptr);
23117         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23118         FREE((void*)this_ptr);
23119         BaseSign_free(this_ptr_conv);
23120 }
23121
23122 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23123         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23124         *ret_ret = Sign_clone(arg);
23125         return (uint64_t)ret_ret;
23126 }
23127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23128         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
23129         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23130         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23131         int64_t ret_val = Sign_clone_ptr(arg_conv);
23132         return ret_val;
23133 }
23134
23135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23136         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
23137         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23138         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23139         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23140         *ret_ret = Sign_clone(orig_conv);
23141         return (uint64_t)ret_ret;
23142 }
23143
23144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23145         if ((this_ptr & 1) != 0) return;
23146         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23147         CHECK_ACCESS(this_ptr_ptr);
23148         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23149         FREE((void*)this_ptr);
23150         Sign_free(this_ptr_conv);
23151 }
23152
23153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23154         if ((this_ptr & 1) != 0) return;
23155         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23156         CHECK_ACCESS(this_ptr_ptr);
23157         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23158         FREE((void*)this_ptr);
23159         KeysInterface_free(this_ptr_conv);
23160 }
23161
23162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23163         LDKInMemorySigner this_obj_conv;
23164         this_obj_conv.inner = (void*)(this_obj & (~1));
23165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23167         InMemorySigner_free(this_obj_conv);
23168 }
23169
23170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23171         LDKInMemorySigner this_ptr_conv;
23172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23173         this_ptr_conv.is_owned = false;
23174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23175         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23176         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
23177         return ret_arr;
23178 }
23179
23180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23181         LDKInMemorySigner this_ptr_conv;
23182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23183         this_ptr_conv.is_owned = false;
23184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23185         LDKSecretKey val_ref;
23186         CHECK((*env)->GetArrayLength(env, val) == 32);
23187         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23188         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23189 }
23190
23191 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23192         LDKInMemorySigner this_ptr_conv;
23193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23194         this_ptr_conv.is_owned = false;
23195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23196         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23197         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
23198         return ret_arr;
23199 }
23200
23201 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23202         LDKInMemorySigner this_ptr_conv;
23203         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23204         this_ptr_conv.is_owned = false;
23205         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23206         LDKSecretKey val_ref;
23207         CHECK((*env)->GetArrayLength(env, val) == 32);
23208         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23209         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23210 }
23211
23212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23213         LDKInMemorySigner this_ptr_conv;
23214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23215         this_ptr_conv.is_owned = false;
23216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23217         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
23219         return ret_arr;
23220 }
23221
23222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23223         LDKInMemorySigner this_ptr_conv;
23224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23225         this_ptr_conv.is_owned = false;
23226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23227         LDKSecretKey val_ref;
23228         CHECK((*env)->GetArrayLength(env, val) == 32);
23229         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23230         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23231 }
23232
23233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23234         LDKInMemorySigner this_ptr_conv;
23235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23236         this_ptr_conv.is_owned = false;
23237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23238         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
23240         return ret_arr;
23241 }
23242
23243 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) {
23244         LDKInMemorySigner this_ptr_conv;
23245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23246         this_ptr_conv.is_owned = false;
23247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23248         LDKSecretKey val_ref;
23249         CHECK((*env)->GetArrayLength(env, val) == 32);
23250         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23251         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23252 }
23253
23254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23255         LDKInMemorySigner this_ptr_conv;
23256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23257         this_ptr_conv.is_owned = false;
23258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23259         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
23261         return ret_arr;
23262 }
23263
23264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23265         LDKInMemorySigner this_ptr_conv;
23266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23267         this_ptr_conv.is_owned = false;
23268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23269         LDKSecretKey val_ref;
23270         CHECK((*env)->GetArrayLength(env, val) == 32);
23271         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23272         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
23273 }
23274
23275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
23276         LDKInMemorySigner this_ptr_conv;
23277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23278         this_ptr_conv.is_owned = false;
23279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23280         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
23282         return ret_arr;
23283 }
23284
23285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23286         LDKInMemorySigner this_ptr_conv;
23287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23288         this_ptr_conv.is_owned = false;
23289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23290         LDKThirtyTwoBytes val_ref;
23291         CHECK((*env)->GetArrayLength(env, val) == 32);
23292         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23293         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23294 }
23295
23296 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23297         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23298 uint64_t ret_ref = 0;
23299 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23300 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23301 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23302 ret_ref = (uint64_t)ret_var.inner;
23303 if (ret_var.is_owned) {
23304         ret_ref |= 1;
23305 }
23306         return ret_ref;
23307 }
23308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23309         LDKInMemorySigner arg_conv;
23310         arg_conv.inner = (void*)(arg & (~1));
23311         arg_conv.is_owned = false;
23312         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23313         int64_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
23314         return ret_val;
23315 }
23316
23317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23318         LDKInMemorySigner orig_conv;
23319         orig_conv.inner = (void*)(orig & (~1));
23320         orig_conv.is_owned = false;
23321         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23322         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23323         uint64_t ret_ref = 0;
23324         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23325         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23326         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23327         ret_ref = (uint64_t)ret_var.inner;
23328         if (ret_var.is_owned) {
23329                 ret_ref |= 1;
23330         }
23331         return ret_ref;
23332 }
23333
23334 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) {
23335         LDKSecretKey funding_key_ref;
23336         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
23337         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
23338         LDKSecretKey revocation_base_key_ref;
23339         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
23340         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
23341         LDKSecretKey payment_key_ref;
23342         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
23343         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
23344         LDKSecretKey delayed_payment_base_key_ref;
23345         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
23346         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
23347         LDKSecretKey htlc_base_key_ref;
23348         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
23349         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
23350         LDKThirtyTwoBytes commitment_seed_ref;
23351         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
23352         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
23353         LDKThirtyTwoBytes channel_keys_id_ref;
23354         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
23355         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
23356         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);
23357         uint64_t ret_ref = 0;
23358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23361         ret_ref = (uint64_t)ret_var.inner;
23362         if (ret_var.is_owned) {
23363                 ret_ref |= 1;
23364         }
23365         return ret_ref;
23366 }
23367
23368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23369         LDKInMemorySigner this_arg_conv;
23370         this_arg_conv.inner = (void*)(this_arg & (~1));
23371         this_arg_conv.is_owned = false;
23372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23373         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23374         uint64_t ret_ref = 0;
23375         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23376         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23377         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23378         ret_ref = (uint64_t)ret_var.inner;
23379         if (ret_var.is_owned) {
23380                 ret_ref |= 1;
23381         }
23382         return ret_ref;
23383 }
23384
23385 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
23386         LDKInMemorySigner this_arg_conv;
23387         this_arg_conv.inner = (void*)(this_arg & (~1));
23388         this_arg_conv.is_owned = false;
23389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23390         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23391         return ret_val;
23392 }
23393
23394 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
23395         LDKInMemorySigner this_arg_conv;
23396         this_arg_conv.inner = (void*)(this_arg & (~1));
23397         this_arg_conv.is_owned = false;
23398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23399         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23400         return ret_val;
23401 }
23402
23403 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
23404         LDKInMemorySigner this_arg_conv;
23405         this_arg_conv.inner = (void*)(this_arg & (~1));
23406         this_arg_conv.is_owned = false;
23407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23408         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
23409         return ret_val;
23410 }
23411
23412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
23413         LDKInMemorySigner this_arg_conv;
23414         this_arg_conv.inner = (void*)(this_arg & (~1));
23415         this_arg_conv.is_owned = false;
23416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23417         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23418         uint64_t ret_ref = 0;
23419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23422         ret_ref = (uint64_t)ret_var.inner;
23423         if (ret_var.is_owned) {
23424                 ret_ref |= 1;
23425         }
23426         return ret_ref;
23427 }
23428
23429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
23430         LDKInMemorySigner this_arg_conv;
23431         this_arg_conv.inner = (void*)(this_arg & (~1));
23432         this_arg_conv.is_owned = false;
23433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23434         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23435         uint64_t ret_ref = 0;
23436         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23437         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23439         ret_ref = (uint64_t)ret_var.inner;
23440         if (ret_var.is_owned) {
23441                 ret_ref |= 1;
23442         }
23443         return ret_ref;
23444 }
23445
23446 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) {
23447         LDKInMemorySigner this_arg_conv;
23448         this_arg_conv.inner = (void*)(this_arg & (~1));
23449         this_arg_conv.is_owned = false;
23450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23451         LDKTransaction spend_tx_ref;
23452         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
23453         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23454         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
23455         spend_tx_ref.data_is_owned = true;
23456         LDKStaticPaymentOutputDescriptor descriptor_conv;
23457         descriptor_conv.inner = (void*)(descriptor & (~1));
23458         descriptor_conv.is_owned = false;
23459         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23460         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23461         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23462         return (uint64_t)ret_conv;
23463 }
23464
23465 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) {
23466         LDKInMemorySigner this_arg_conv;
23467         this_arg_conv.inner = (void*)(this_arg & (~1));
23468         this_arg_conv.is_owned = false;
23469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23470         LDKTransaction spend_tx_ref;
23471         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
23472         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23473         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
23474         spend_tx_ref.data_is_owned = true;
23475         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23476         descriptor_conv.inner = (void*)(descriptor & (~1));
23477         descriptor_conv.is_owned = false;
23478         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23479         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23480         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23481         return (uint64_t)ret_conv;
23482 }
23483
23484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
23485         LDKInMemorySigner this_arg_conv;
23486         this_arg_conv.inner = (void*)(this_arg & (~1));
23487         this_arg_conv.is_owned = false;
23488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23489         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23490         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23491         return (uint64_t)ret_ret;
23492 }
23493
23494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
23495         LDKInMemorySigner this_arg_conv;
23496         this_arg_conv.inner = (void*)(this_arg & (~1));
23497         this_arg_conv.is_owned = false;
23498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23499         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23500         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23501         return (uint64_t)ret_ret;
23502 }
23503
23504 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
23505         LDKInMemorySigner obj_conv;
23506         obj_conv.inner = (void*)(obj & (~1));
23507         obj_conv.is_owned = false;
23508         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23509         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23510         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23511         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23512         CVec_u8Z_free(ret_var);
23513         return ret_arr;
23514 }
23515
23516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23517         LDKu8slice ser_ref;
23518         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23519         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23520         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23521         *ret_conv = InMemorySigner_read(ser_ref);
23522         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23523         return (uint64_t)ret_conv;
23524 }
23525
23526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23527         LDKKeysManager this_obj_conv;
23528         this_obj_conv.inner = (void*)(this_obj & (~1));
23529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23531         KeysManager_free(this_obj_conv);
23532 }
23533
23534 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) {
23535         unsigned char seed_arr[32];
23536         CHECK((*env)->GetArrayLength(env, seed) == 32);
23537         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
23538         unsigned char (*seed_ref)[32] = &seed_arr;
23539         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
23540         uint64_t ret_ref = 0;
23541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23544         ret_ref = (uint64_t)ret_var.inner;
23545         if (ret_var.is_owned) {
23546                 ret_ref |= 1;
23547         }
23548         return ret_ref;
23549 }
23550
23551 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) {
23552         LDKKeysManager this_arg_conv;
23553         this_arg_conv.inner = (void*)(this_arg & (~1));
23554         this_arg_conv.is_owned = false;
23555         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23556         unsigned char params_arr[32];
23557         CHECK((*env)->GetArrayLength(env, params) == 32);
23558         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
23559         unsigned char (*params_ref)[32] = &params_arr;
23560         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23561         uint64_t ret_ref = 0;
23562         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23563         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23564         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23565         ret_ref = (uint64_t)ret_var.inner;
23566         if (ret_var.is_owned) {
23567                 ret_ref |= 1;
23568         }
23569         return ret_ref;
23570 }
23571
23572 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) {
23573         LDKKeysManager this_arg_conv;
23574         this_arg_conv.inner = (void*)(this_arg & (~1));
23575         this_arg_conv.is_owned = false;
23576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23577         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23578         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
23579         if (descriptors_constr.datalen > 0)
23580                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23581         else
23582                 descriptors_constr.data = NULL;
23583         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
23584         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23585                 int64_t descriptors_conv_27 = descriptors_vals[b];
23586                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
23587                 CHECK_ACCESS(descriptors_conv_27_ptr);
23588                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23589                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
23590                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23591         }
23592         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
23593         LDKCVec_TxOutZ outputs_constr;
23594         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
23595         if (outputs_constr.datalen > 0)
23596                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23597         else
23598                 outputs_constr.data = NULL;
23599         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
23600         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23601                 int64_t outputs_conv_7 = outputs_vals[h];
23602                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
23603                 CHECK_ACCESS(outputs_conv_7_ptr);
23604                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23605                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
23606                 outputs_constr.data[h] = outputs_conv_7_conv;
23607         }
23608         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
23609         LDKCVec_u8Z change_destination_script_ref;
23610         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
23611         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23612         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
23613         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23614         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23615         return (uint64_t)ret_conv;
23616 }
23617
23618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
23619         LDKKeysManager this_arg_conv;
23620         this_arg_conv.inner = (void*)(this_arg & (~1));
23621         this_arg_conv.is_owned = false;
23622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23623         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23624         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23625         return (uint64_t)ret_ret;
23626 }
23627
23628 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23629         LDKChannelManager this_obj_conv;
23630         this_obj_conv.inner = (void*)(this_obj & (~1));
23631         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23632         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23633         ChannelManager_free(this_obj_conv);
23634 }
23635
23636 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23637         LDKChainParameters this_obj_conv;
23638         this_obj_conv.inner = (void*)(this_obj & (~1));
23639         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23641         ChainParameters_free(this_obj_conv);
23642 }
23643
23644 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
23645         LDKChainParameters this_ptr_conv;
23646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23647         this_ptr_conv.is_owned = false;
23648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23649         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
23650         return ret_conv;
23651 }
23652
23653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
23654         LDKChainParameters this_ptr_conv;
23655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23656         this_ptr_conv.is_owned = false;
23657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23658         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
23659         ChainParameters_set_network(&this_ptr_conv, val_conv);
23660 }
23661
23662 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
23663         LDKChainParameters this_ptr_conv;
23664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23665         this_ptr_conv.is_owned = false;
23666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23667         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
23668         uint64_t ret_ref = 0;
23669         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23670         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23671         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23672         ret_ref = (uint64_t)ret_var.inner;
23673         if (ret_var.is_owned) {
23674                 ret_ref |= 1;
23675         }
23676         return ret_ref;
23677 }
23678
23679 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23680         LDKChainParameters this_ptr_conv;
23681         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23682         this_ptr_conv.is_owned = false;
23683         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23684         LDKBestBlock val_conv;
23685         val_conv.inner = (void*)(val & (~1));
23686         val_conv.is_owned = (val & 1) || (val == 0);
23687         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23688         val_conv = BestBlock_clone(&val_conv);
23689         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
23690 }
23691
23692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
23693         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
23694         LDKBestBlock best_block_arg_conv;
23695         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
23696         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
23697         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
23698         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
23699         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
23700         uint64_t ret_ref = 0;
23701         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23702         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23703         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23704         ret_ref = (uint64_t)ret_var.inner;
23705         if (ret_var.is_owned) {
23706                 ret_ref |= 1;
23707         }
23708         return ret_ref;
23709 }
23710
23711 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
23712         LDKChainParameters ret_var = ChainParameters_clone(arg);
23713 uint64_t ret_ref = 0;
23714 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23715 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23716 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23717 ret_ref = (uint64_t)ret_var.inner;
23718 if (ret_var.is_owned) {
23719         ret_ref |= 1;
23720 }
23721         return ret_ref;
23722 }
23723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23724         LDKChainParameters arg_conv;
23725         arg_conv.inner = (void*)(arg & (~1));
23726         arg_conv.is_owned = false;
23727         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23728         int64_t ret_val = ChainParameters_clone_ptr(&arg_conv);
23729         return ret_val;
23730 }
23731
23732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23733         LDKChainParameters orig_conv;
23734         orig_conv.inner = (void*)(orig & (~1));
23735         orig_conv.is_owned = false;
23736         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23737         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
23738         uint64_t ret_ref = 0;
23739         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23740         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23741         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23742         ret_ref = (uint64_t)ret_var.inner;
23743         if (ret_var.is_owned) {
23744                 ret_ref |= 1;
23745         }
23746         return ret_ref;
23747 }
23748
23749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23750         LDKCounterpartyForwardingInfo this_obj_conv;
23751         this_obj_conv.inner = (void*)(this_obj & (~1));
23752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23754         CounterpartyForwardingInfo_free(this_obj_conv);
23755 }
23756
23757 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23758         LDKCounterpartyForwardingInfo this_ptr_conv;
23759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23760         this_ptr_conv.is_owned = false;
23761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23762         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
23763         return ret_val;
23764 }
23765
23766 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23767         LDKCounterpartyForwardingInfo this_ptr_conv;
23768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23769         this_ptr_conv.is_owned = false;
23770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23771         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
23772 }
23773
23774 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
23775         LDKCounterpartyForwardingInfo this_ptr_conv;
23776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23777         this_ptr_conv.is_owned = false;
23778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23779         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
23780         return ret_val;
23781 }
23782
23783 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23784         LDKCounterpartyForwardingInfo this_ptr_conv;
23785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23786         this_ptr_conv.is_owned = false;
23787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23788         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
23789 }
23790
23791 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23792         LDKCounterpartyForwardingInfo this_ptr_conv;
23793         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23794         this_ptr_conv.is_owned = false;
23795         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23796         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
23797         return ret_val;
23798 }
23799
23800 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23801         LDKCounterpartyForwardingInfo this_ptr_conv;
23802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23803         this_ptr_conv.is_owned = false;
23804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23805         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23806 }
23807
23808 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) {
23809         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
23810         uint64_t ret_ref = 0;
23811         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23812         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23813         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23814         ret_ref = (uint64_t)ret_var.inner;
23815         if (ret_var.is_owned) {
23816                 ret_ref |= 1;
23817         }
23818         return ret_ref;
23819 }
23820
23821 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
23822         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
23823 uint64_t ret_ref = 0;
23824 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23825 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23826 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23827 ret_ref = (uint64_t)ret_var.inner;
23828 if (ret_var.is_owned) {
23829         ret_ref |= 1;
23830 }
23831         return ret_ref;
23832 }
23833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23834         LDKCounterpartyForwardingInfo arg_conv;
23835         arg_conv.inner = (void*)(arg & (~1));
23836         arg_conv.is_owned = false;
23837         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23838         int64_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
23839         return ret_val;
23840 }
23841
23842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23843         LDKCounterpartyForwardingInfo orig_conv;
23844         orig_conv.inner = (void*)(orig & (~1));
23845         orig_conv.is_owned = false;
23846         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23847         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
23848         uint64_t ret_ref = 0;
23849         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23850         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23852         ret_ref = (uint64_t)ret_var.inner;
23853         if (ret_var.is_owned) {
23854                 ret_ref |= 1;
23855         }
23856         return ret_ref;
23857 }
23858
23859 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23860         LDKChannelCounterparty this_obj_conv;
23861         this_obj_conv.inner = (void*)(this_obj & (~1));
23862         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23864         ChannelCounterparty_free(this_obj_conv);
23865 }
23866
23867 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23868         LDKChannelCounterparty this_ptr_conv;
23869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23870         this_ptr_conv.is_owned = false;
23871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23872         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23873         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
23874         return ret_arr;
23875 }
23876
23877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23878         LDKChannelCounterparty this_ptr_conv;
23879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23880         this_ptr_conv.is_owned = false;
23881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23882         LDKPublicKey val_ref;
23883         CHECK((*env)->GetArrayLength(env, val) == 33);
23884         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23885         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
23886 }
23887
23888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23889         LDKChannelCounterparty this_ptr_conv;
23890         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23891         this_ptr_conv.is_owned = false;
23892         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23893         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
23894         uint64_t ret_ref = 0;
23895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23898         ret_ref = (uint64_t)ret_var.inner;
23899         if (ret_var.is_owned) {
23900                 ret_ref |= 1;
23901         }
23902         return ret_ref;
23903 }
23904
23905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23906         LDKChannelCounterparty this_ptr_conv;
23907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23908         this_ptr_conv.is_owned = false;
23909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23910         LDKInitFeatures val_conv;
23911         val_conv.inner = (void*)(val & (~1));
23912         val_conv.is_owned = (val & 1) || (val == 0);
23913         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23914         val_conv = InitFeatures_clone(&val_conv);
23915         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
23916 }
23917
23918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
23919         LDKChannelCounterparty this_ptr_conv;
23920         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23921         this_ptr_conv.is_owned = false;
23922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23923         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
23924         return ret_val;
23925 }
23926
23927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23928         LDKChannelCounterparty this_ptr_conv;
23929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23930         this_ptr_conv.is_owned = false;
23931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23932         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
23933 }
23934
23935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
23936         LDKChannelCounterparty this_ptr_conv;
23937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23938         this_ptr_conv.is_owned = false;
23939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23940         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
23941         uint64_t ret_ref = 0;
23942         if ((uint64_t)ret_var.inner > 4096) {
23943                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23944                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23945         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23946                 ret_ref = (uint64_t)ret_var.inner;
23947                 if (ret_var.is_owned) {
23948                         ret_ref |= 1;
23949                 }
23950         }
23951         return ret_ref;
23952 }
23953
23954 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23955         LDKChannelCounterparty this_ptr_conv;
23956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23957         this_ptr_conv.is_owned = false;
23958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23959         LDKCounterpartyForwardingInfo val_conv;
23960         val_conv.inner = (void*)(val & (~1));
23961         val_conv.is_owned = (val & 1) || (val == 0);
23962         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23963         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
23964         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
23965 }
23966
23967 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) {
23968         LDKPublicKey node_id_arg_ref;
23969         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
23970         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
23971         LDKInitFeatures features_arg_conv;
23972         features_arg_conv.inner = (void*)(features_arg & (~1));
23973         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23974         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
23975         features_arg_conv = InitFeatures_clone(&features_arg_conv);
23976         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
23977         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
23978         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
23979         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
23980         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
23981         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
23982         uint64_t ret_ref = 0;
23983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23986         ret_ref = (uint64_t)ret_var.inner;
23987         if (ret_var.is_owned) {
23988                 ret_ref |= 1;
23989         }
23990         return ret_ref;
23991 }
23992
23993 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
23994         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
23995 uint64_t ret_ref = 0;
23996 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23997 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23998 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23999 ret_ref = (uint64_t)ret_var.inner;
24000 if (ret_var.is_owned) {
24001         ret_ref |= 1;
24002 }
24003         return ret_ref;
24004 }
24005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24006         LDKChannelCounterparty arg_conv;
24007         arg_conv.inner = (void*)(arg & (~1));
24008         arg_conv.is_owned = false;
24009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24010         int64_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
24011         return ret_val;
24012 }
24013
24014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24015         LDKChannelCounterparty orig_conv;
24016         orig_conv.inner = (void*)(orig & (~1));
24017         orig_conv.is_owned = false;
24018         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24019         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24020         uint64_t ret_ref = 0;
24021         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24022         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24024         ret_ref = (uint64_t)ret_var.inner;
24025         if (ret_var.is_owned) {
24026                 ret_ref |= 1;
24027         }
24028         return ret_ref;
24029 }
24030
24031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24032         LDKChannelDetails this_obj_conv;
24033         this_obj_conv.inner = (void*)(this_obj & (~1));
24034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24036         ChannelDetails_free(this_obj_conv);
24037 }
24038
24039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24040         LDKChannelDetails this_ptr_conv;
24041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24042         this_ptr_conv.is_owned = false;
24043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24044         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24045         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
24046         return ret_arr;
24047 }
24048
24049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24050         LDKChannelDetails this_ptr_conv;
24051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24052         this_ptr_conv.is_owned = false;
24053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24054         LDKThirtyTwoBytes val_ref;
24055         CHECK((*env)->GetArrayLength(env, val) == 32);
24056         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24057         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24058 }
24059
24060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
24061         LDKChannelDetails this_ptr_conv;
24062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24063         this_ptr_conv.is_owned = false;
24064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24065         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24066         uint64_t ret_ref = 0;
24067         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24068         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24070         ret_ref = (uint64_t)ret_var.inner;
24071         if (ret_var.is_owned) {
24072                 ret_ref |= 1;
24073         }
24074         return ret_ref;
24075 }
24076
24077 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24078         LDKChannelDetails this_ptr_conv;
24079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24080         this_ptr_conv.is_owned = false;
24081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24082         LDKChannelCounterparty val_conv;
24083         val_conv.inner = (void*)(val & (~1));
24084         val_conv.is_owned = (val & 1) || (val == 0);
24085         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24086         val_conv = ChannelCounterparty_clone(&val_conv);
24087         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24088 }
24089
24090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
24091         LDKChannelDetails this_ptr_conv;
24092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24093         this_ptr_conv.is_owned = false;
24094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24095         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24096         uint64_t ret_ref = 0;
24097         if ((uint64_t)ret_var.inner > 4096) {
24098                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24099                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24101                 ret_ref = (uint64_t)ret_var.inner;
24102                 if (ret_var.is_owned) {
24103                         ret_ref |= 1;
24104                 }
24105         }
24106         return ret_ref;
24107 }
24108
24109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24110         LDKChannelDetails this_ptr_conv;
24111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24112         this_ptr_conv.is_owned = false;
24113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24114         LDKOutPoint val_conv;
24115         val_conv.inner = (void*)(val & (~1));
24116         val_conv.is_owned = (val & 1) || (val == 0);
24117         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24118         val_conv = OutPoint_clone(&val_conv);
24119         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24120 }
24121
24122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24123         LDKChannelDetails this_ptr_conv;
24124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24125         this_ptr_conv.is_owned = false;
24126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24127         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24128         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24129         uint64_t ret_ref = (uint64_t)ret_copy;
24130         return ret_ref;
24131 }
24132
24133 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24134         LDKChannelDetails this_ptr_conv;
24135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24136         this_ptr_conv.is_owned = false;
24137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24138         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24139         CHECK_ACCESS(val_ptr);
24140         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24141         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24142         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24143 }
24144
24145 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24146         LDKChannelDetails this_ptr_conv;
24147         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24148         this_ptr_conv.is_owned = false;
24149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24150         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24151         return ret_val;
24152 }
24153
24154 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24155         LDKChannelDetails this_ptr_conv;
24156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24157         this_ptr_conv.is_owned = false;
24158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24159         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24160 }
24161
24162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
24163         LDKChannelDetails this_ptr_conv;
24164         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24165         this_ptr_conv.is_owned = false;
24166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24167         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24168         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24169         uint64_t ret_ref = (uint64_t)ret_copy;
24170         return ret_ref;
24171 }
24172
24173 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24174         LDKChannelDetails this_ptr_conv;
24175         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24176         this_ptr_conv.is_owned = false;
24177         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24178         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24179         CHECK_ACCESS(val_ptr);
24180         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24181         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24182         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24183 }
24184
24185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24186         LDKChannelDetails this_ptr_conv;
24187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24188         this_ptr_conv.is_owned = false;
24189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24190         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24191         return ret_val;
24192 }
24193
24194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24195         LDKChannelDetails this_ptr_conv;
24196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24197         this_ptr_conv.is_owned = false;
24198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24199         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24200 }
24201
24202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24203         LDKChannelDetails this_ptr_conv;
24204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24205         this_ptr_conv.is_owned = false;
24206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24207         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24208         return ret_val;
24209 }
24210
24211 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24212         LDKChannelDetails this_ptr_conv;
24213         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24214         this_ptr_conv.is_owned = false;
24215         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24216         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24217 }
24218
24219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24220         LDKChannelDetails this_ptr_conv;
24221         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24222         this_ptr_conv.is_owned = false;
24223         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24224         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24225         return ret_val;
24226 }
24227
24228 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24229         LDKChannelDetails this_ptr_conv;
24230         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24231         this_ptr_conv.is_owned = false;
24232         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24233         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24234 }
24235
24236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
24237         LDKChannelDetails this_ptr_conv;
24238         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24239         this_ptr_conv.is_owned = false;
24240         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24241         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24242         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24243         uint64_t ret_ref = (uint64_t)ret_copy;
24244         return ret_ref;
24245 }
24246
24247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24248         LDKChannelDetails this_ptr_conv;
24249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24250         this_ptr_conv.is_owned = false;
24251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24252         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24253         CHECK_ACCESS(val_ptr);
24254         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24255         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
24256         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24257 }
24258
24259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24260         LDKChannelDetails this_ptr_conv;
24261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24262         this_ptr_conv.is_owned = false;
24263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24264         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24265         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24266         uint64_t ret_ref = (uint64_t)ret_copy;
24267         return ret_ref;
24268 }
24269
24270 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) {
24271         LDKChannelDetails this_ptr_conv;
24272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24273         this_ptr_conv.is_owned = false;
24274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24275         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24276         CHECK_ACCESS(val_ptr);
24277         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24278         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
24279         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24280 }
24281
24282 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
24283         LDKChannelDetails this_ptr_conv;
24284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24285         this_ptr_conv.is_owned = false;
24286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24287         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
24288         return ret_val;
24289 }
24290
24291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24292         LDKChannelDetails this_ptr_conv;
24293         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24294         this_ptr_conv.is_owned = false;
24295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24296         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
24297 }
24298
24299 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
24300         LDKChannelDetails this_ptr_conv;
24301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24302         this_ptr_conv.is_owned = false;
24303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24304         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24305         return ret_val;
24306 }
24307
24308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24309         LDKChannelDetails this_ptr_conv;
24310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24311         this_ptr_conv.is_owned = false;
24312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24313         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24314 }
24315
24316 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
24317         LDKChannelDetails this_ptr_conv;
24318         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24319         this_ptr_conv.is_owned = false;
24320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24321         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
24322         return ret_val;
24323 }
24324
24325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24326         LDKChannelDetails this_ptr_conv;
24327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24328         this_ptr_conv.is_owned = false;
24329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24330         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24331 }
24332
24333 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
24334         LDKChannelDetails this_ptr_conv;
24335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24336         this_ptr_conv.is_owned = false;
24337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24338         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
24339         return ret_val;
24340 }
24341
24342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24343         LDKChannelDetails this_ptr_conv;
24344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24345         this_ptr_conv.is_owned = false;
24346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24347         ChannelDetails_set_is_public(&this_ptr_conv, val);
24348 }
24349
24350 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 short_channel_id_arg, int64_t channel_value_satoshis_arg, int64_t unspendable_punishment_reserve_arg, int64_t user_channel_id_arg, int64_t outbound_capacity_msat_arg, int64_t inbound_capacity_msat_arg, int64_t confirmations_required_arg, int64_t force_close_spend_delay_arg, jboolean is_outbound_arg, jboolean is_funding_locked_arg, jboolean is_usable_arg, jboolean is_public_arg) {
24351         LDKThirtyTwoBytes channel_id_arg_ref;
24352         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
24353         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
24354         LDKChannelCounterparty counterparty_arg_conv;
24355         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24356         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24357         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24358         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24359         LDKOutPoint funding_txo_arg_conv;
24360         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24361         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24362         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24363         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24364         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
24365         CHECK_ACCESS(short_channel_id_arg_ptr);
24366         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24367         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
24368         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
24369         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24370         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24371         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
24372         CHECK_ACCESS(confirmations_required_arg_ptr);
24373         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24374         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
24375         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
24376         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24377         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24378         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
24379         LDKChannelDetails ret_var = ChannelDetails_new(channel_id_arg_ref, counterparty_arg_conv, funding_txo_arg_conv, short_channel_id_arg_conv, channel_value_satoshis_arg, unspendable_punishment_reserve_arg_conv, user_channel_id_arg, outbound_capacity_msat_arg, inbound_capacity_msat_arg, confirmations_required_arg_conv, force_close_spend_delay_arg_conv, is_outbound_arg, is_funding_locked_arg, is_usable_arg, is_public_arg);
24380         uint64_t ret_ref = 0;
24381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24384         ret_ref = (uint64_t)ret_var.inner;
24385         if (ret_var.is_owned) {
24386                 ret_ref |= 1;
24387         }
24388         return ret_ref;
24389 }
24390
24391 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24392         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24393 uint64_t ret_ref = 0;
24394 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24395 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24396 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24397 ret_ref = (uint64_t)ret_var.inner;
24398 if (ret_var.is_owned) {
24399         ret_ref |= 1;
24400 }
24401         return ret_ref;
24402 }
24403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24404         LDKChannelDetails arg_conv;
24405         arg_conv.inner = (void*)(arg & (~1));
24406         arg_conv.is_owned = false;
24407         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24408         int64_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
24409         return ret_val;
24410 }
24411
24412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24413         LDKChannelDetails orig_conv;
24414         orig_conv.inner = (void*)(orig & (~1));
24415         orig_conv.is_owned = false;
24416         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24417         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24418         uint64_t ret_ref = 0;
24419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24422         ret_ref = (uint64_t)ret_var.inner;
24423         if (ret_var.is_owned) {
24424                 ret_ref |= 1;
24425         }
24426         return ret_ref;
24427 }
24428
24429 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24430         if ((this_ptr & 1) != 0) return;
24431         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
24432         CHECK_ACCESS(this_ptr_ptr);
24433         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24434         FREE((void*)this_ptr);
24435         PaymentSendFailure_free(this_ptr_conv);
24436 }
24437
24438 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24439         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24440         *ret_copy = PaymentSendFailure_clone(arg);
24441 uint64_t ret_ref = (uint64_t)ret_copy;
24442         return ret_ref;
24443 }
24444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24445         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
24446         int64_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
24447         return ret_val;
24448 }
24449
24450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24451         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
24452         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24453         *ret_copy = PaymentSendFailure_clone(orig_conv);
24454         uint64_t ret_ref = (uint64_t)ret_copy;
24455         return ret_ref;
24456 }
24457
24458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
24459         void* a_ptr = (void*)(((uint64_t)a) & ~1);
24460         CHECK_ACCESS(a_ptr);
24461         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
24462         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
24463         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24464         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
24465         uint64_t ret_ref = (uint64_t)ret_copy;
24466         return ret_ref;
24467 }
24468
24469 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
24470         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
24471         a_constr.datalen = (*env)->GetArrayLength(env, a);
24472         if (a_constr.datalen > 0)
24473                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24474         else
24475                 a_constr.data = NULL;
24476         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
24477         for (size_t w = 0; w < a_constr.datalen; w++) {
24478                 int64_t a_conv_22 = a_vals[w];
24479                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
24480                 CHECK_ACCESS(a_conv_22_ptr);
24481                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
24482                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
24483                 a_constr.data[w] = a_conv_22_conv;
24484         }
24485         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
24486         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24487         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
24488         uint64_t ret_ref = (uint64_t)ret_copy;
24489         return ret_ref;
24490 }
24491
24492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
24493         LDKCVec_APIErrorZ a_constr;
24494         a_constr.datalen = (*env)->GetArrayLength(env, a);
24495         if (a_constr.datalen > 0)
24496                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
24497         else
24498                 a_constr.data = NULL;
24499         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
24500         for (size_t k = 0; k < a_constr.datalen; k++) {
24501                 int64_t a_conv_10 = a_vals[k];
24502                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
24503                 CHECK_ACCESS(a_conv_10_ptr);
24504                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
24505                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
24506                 a_constr.data[k] = a_conv_10_conv;
24507         }
24508         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
24509         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24510         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
24511         uint64_t ret_ref = (uint64_t)ret_copy;
24512         return ret_ref;
24513 }
24514
24515 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) {
24516         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
24517         results_constr.datalen = (*env)->GetArrayLength(env, results);
24518         if (results_constr.datalen > 0)
24519                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24520         else
24521                 results_constr.data = NULL;
24522         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
24523         for (size_t w = 0; w < results_constr.datalen; w++) {
24524                 int64_t results_conv_22 = results_vals[w];
24525                 void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
24526                 CHECK_ACCESS(results_conv_22_ptr);
24527                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
24528                 results_constr.data[w] = results_conv_22_conv;
24529         }
24530         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
24531         LDKRouteParameters failed_paths_retry_conv;
24532         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
24533         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
24534         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
24535         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
24536         LDKThirtyTwoBytes payment_id_ref;
24537         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24538         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24539         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24540         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
24541         uint64_t ret_ref = (uint64_t)ret_copy;
24542         return ret_ref;
24543 }
24544
24545 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 logger, int64_t keys_manager, int64_t config, int64_t params) {
24546         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
24547         CHECK_ACCESS(fee_est_ptr);
24548         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
24549         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
24550                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24551                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
24552         }
24553         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
24554         CHECK_ACCESS(chain_monitor_ptr);
24555         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
24556         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
24557                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24558                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
24559         }
24560         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
24561         CHECK_ACCESS(tx_broadcaster_ptr);
24562         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
24563         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24564                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24565                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
24566         }
24567         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
24568         CHECK_ACCESS(logger_ptr);
24569         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24570         if (logger_conv.free == LDKLogger_JCalls_free) {
24571                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24572                 LDKLogger_JCalls_cloned(&logger_conv);
24573         }
24574         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
24575         CHECK_ACCESS(keys_manager_ptr);
24576         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
24577         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
24578                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24579                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
24580         }
24581         LDKUserConfig config_conv;
24582         config_conv.inner = (void*)(config & (~1));
24583         config_conv.is_owned = (config & 1) || (config == 0);
24584         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
24585         config_conv = UserConfig_clone(&config_conv);
24586         LDKChainParameters params_conv;
24587         params_conv.inner = (void*)(params & (~1));
24588         params_conv.is_owned = (params & 1) || (params == 0);
24589         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
24590         params_conv = ChainParameters_clone(&params_conv);
24591         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
24592         uint64_t ret_ref = 0;
24593         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24594         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24596         ret_ref = (uint64_t)ret_var.inner;
24597         if (ret_var.is_owned) {
24598                 ret_ref |= 1;
24599         }
24600         return ret_ref;
24601 }
24602
24603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
24604         LDKChannelManager this_arg_conv;
24605         this_arg_conv.inner = (void*)(this_arg & (~1));
24606         this_arg_conv.is_owned = false;
24607         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24608         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
24609         uint64_t ret_ref = 0;
24610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24613         ret_ref = (uint64_t)ret_var.inner;
24614         if (ret_var.is_owned) {
24615                 ret_ref |= 1;
24616         }
24617         return ret_ref;
24618 }
24619
24620 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, int64_t user_channel_id, int64_t override_config) {
24621         LDKChannelManager this_arg_conv;
24622         this_arg_conv.inner = (void*)(this_arg & (~1));
24623         this_arg_conv.is_owned = false;
24624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24625         LDKPublicKey their_network_key_ref;
24626         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
24627         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
24628         LDKUserConfig override_config_conv;
24629         override_config_conv.inner = (void*)(override_config & (~1));
24630         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
24631         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
24632         override_config_conv = UserConfig_clone(&override_config_conv);
24633         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
24634         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
24635         return (uint64_t)ret_conv;
24636 }
24637
24638 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
24639         LDKChannelManager this_arg_conv;
24640         this_arg_conv.inner = (void*)(this_arg & (~1));
24641         this_arg_conv.is_owned = false;
24642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24643         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
24644         int64_tArray ret_arr = NULL;
24645         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24646         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24647         for (size_t q = 0; q < ret_var.datalen; q++) {
24648                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24649                 uint64_t ret_conv_16_ref = 0;
24650                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24651                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24652                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24653                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
24654                 if (ret_conv_16_var.is_owned) {
24655                         ret_conv_16_ref |= 1;
24656                 }
24657                 ret_arr_ptr[q] = ret_conv_16_ref;
24658         }
24659         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24660         FREE(ret_var.data);
24661         return ret_arr;
24662 }
24663
24664 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
24665         LDKChannelManager this_arg_conv;
24666         this_arg_conv.inner = (void*)(this_arg & (~1));
24667         this_arg_conv.is_owned = false;
24668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24669         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
24670         int64_tArray ret_arr = NULL;
24671         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24672         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24673         for (size_t q = 0; q < ret_var.datalen; q++) {
24674                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24675                 uint64_t ret_conv_16_ref = 0;
24676                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24677                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24678                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24679                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
24680                 if (ret_conv_16_var.is_owned) {
24681                         ret_conv_16_ref |= 1;
24682                 }
24683                 ret_arr_ptr[q] = ret_conv_16_ref;
24684         }
24685         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24686         FREE(ret_var.data);
24687         return ret_arr;
24688 }
24689
24690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
24691         LDKChannelManager this_arg_conv;
24692         this_arg_conv.inner = (void*)(this_arg & (~1));
24693         this_arg_conv.is_owned = false;
24694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24695         unsigned char channel_id_arr[32];
24696         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24697         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
24698         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24699         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24700         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
24701         return (uint64_t)ret_conv;
24702 }
24703
24704 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, int32_t target_feerate_sats_per_1000_weight) {
24705         LDKChannelManager this_arg_conv;
24706         this_arg_conv.inner = (void*)(this_arg & (~1));
24707         this_arg_conv.is_owned = false;
24708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24709         unsigned char channel_id_arr[32];
24710         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24711         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
24712         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24713         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24714         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
24715         return (uint64_t)ret_conv;
24716 }
24717
24718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
24719         LDKChannelManager this_arg_conv;
24720         this_arg_conv.inner = (void*)(this_arg & (~1));
24721         this_arg_conv.is_owned = false;
24722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24723         unsigned char channel_id_arr[32];
24724         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24725         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
24726         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24727         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24728         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
24729         return (uint64_t)ret_conv;
24730 }
24731
24732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
24733         LDKChannelManager this_arg_conv;
24734         this_arg_conv.inner = (void*)(this_arg & (~1));
24735         this_arg_conv.is_owned = false;
24736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24737         ChannelManager_force_close_all_channels(&this_arg_conv);
24738 }
24739
24740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1send_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_hash, int8_tArray payment_secret) {
24741         LDKChannelManager this_arg_conv;
24742         this_arg_conv.inner = (void*)(this_arg & (~1));
24743         this_arg_conv.is_owned = false;
24744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24745         LDKRoute route_conv;
24746         route_conv.inner = (void*)(route & (~1));
24747         route_conv.is_owned = false;
24748         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24749         LDKThirtyTwoBytes payment_hash_ref;
24750         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24751         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24752         LDKThirtyTwoBytes payment_secret_ref;
24753         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
24754         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
24755         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
24756         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
24757         return (uint64_t)ret_conv;
24758 }
24759
24760 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1retry_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int64_t route, int8_tArray payment_id) {
24761         LDKChannelManager this_arg_conv;
24762         this_arg_conv.inner = (void*)(this_arg & (~1));
24763         this_arg_conv.is_owned = false;
24764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24765         LDKRoute route_conv;
24766         route_conv.inner = (void*)(route & (~1));
24767         route_conv.is_owned = false;
24768         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24769         LDKThirtyTwoBytes payment_id_ref;
24770         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24771         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24772         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
24773         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
24774         return (uint64_t)ret_conv;
24775 }
24776
24777 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) {
24778         LDKChannelManager this_arg_conv;
24779         this_arg_conv.inner = (void*)(this_arg & (~1));
24780         this_arg_conv.is_owned = false;
24781         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24782         LDKRoute route_conv;
24783         route_conv.inner = (void*)(route & (~1));
24784         route_conv.is_owned = false;
24785         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24786         LDKThirtyTwoBytes payment_preimage_ref;
24787         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24788         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24789         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
24790         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
24791         return (uint64_t)ret_conv;
24792 }
24793
24794 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 funding_transaction) {
24795         LDKChannelManager this_arg_conv;
24796         this_arg_conv.inner = (void*)(this_arg & (~1));
24797         this_arg_conv.is_owned = false;
24798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24799         unsigned char temporary_channel_id_arr[32];
24800         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24801         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
24802         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
24803         LDKTransaction funding_transaction_ref;
24804         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
24805         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
24806         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
24807         funding_transaction_ref.data_is_owned = true;
24808         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24809         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
24810         return (uint64_t)ret_conv;
24811 }
24812
24813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray rgb, int8_tArray alias, int64_tArray addresses) {
24814         LDKChannelManager this_arg_conv;
24815         this_arg_conv.inner = (void*)(this_arg & (~1));
24816         this_arg_conv.is_owned = false;
24817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24818         LDKThreeBytes rgb_ref;
24819         CHECK((*env)->GetArrayLength(env, rgb) == 3);
24820         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
24821         LDKThirtyTwoBytes alias_ref;
24822         CHECK((*env)->GetArrayLength(env, alias) == 32);
24823         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
24824         LDKCVec_NetAddressZ addresses_constr;
24825         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
24826         if (addresses_constr.datalen > 0)
24827                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24828         else
24829                 addresses_constr.data = NULL;
24830         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
24831         for (size_t m = 0; m < addresses_constr.datalen; m++) {
24832                 int64_t addresses_conv_12 = addresses_vals[m];
24833                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
24834                 CHECK_ACCESS(addresses_conv_12_ptr);
24835                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
24836                 addresses_constr.data[m] = addresses_conv_12_conv;
24837         }
24838         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
24839         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
24840 }
24841
24842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
24843         LDKChannelManager this_arg_conv;
24844         this_arg_conv.inner = (void*)(this_arg & (~1));
24845         this_arg_conv.is_owned = false;
24846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24847         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
24848 }
24849
24850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
24851         LDKChannelManager this_arg_conv;
24852         this_arg_conv.inner = (void*)(this_arg & (~1));
24853         this_arg_conv.is_owned = false;
24854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24855         ChannelManager_timer_tick_occurred(&this_arg_conv);
24856 }
24857
24858 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
24859         LDKChannelManager this_arg_conv;
24860         this_arg_conv.inner = (void*)(this_arg & (~1));
24861         this_arg_conv.is_owned = false;
24862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24863         unsigned char payment_hash_arr[32];
24864         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24865         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
24866         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
24867         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
24868         return ret_val;
24869 }
24870
24871 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
24872         LDKChannelManager this_arg_conv;
24873         this_arg_conv.inner = (void*)(this_arg & (~1));
24874         this_arg_conv.is_owned = false;
24875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24876         LDKThirtyTwoBytes payment_preimage_ref;
24877         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24878         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24879         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
24880         return ret_val;
24881 }
24882
24883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
24884         LDKChannelManager this_arg_conv;
24885         this_arg_conv.inner = (void*)(this_arg & (~1));
24886         this_arg_conv.is_owned = false;
24887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24888         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24889         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
24890         return ret_arr;
24891 }
24892
24893 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 user_payment_id) {
24894         LDKChannelManager this_arg_conv;
24895         this_arg_conv.inner = (void*)(this_arg & (~1));
24896         this_arg_conv.is_owned = false;
24897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24898         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
24899         CHECK_ACCESS(min_value_msat_ptr);
24900         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
24901         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
24902         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
24903         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
24904         return ((uint64_t)ret_conv);
24905 }
24906
24907 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 user_payment_id) {
24908         LDKChannelManager this_arg_conv;
24909         this_arg_conv.inner = (void*)(this_arg & (~1));
24910         this_arg_conv.is_owned = false;
24911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24912         LDKThirtyTwoBytes payment_hash_ref;
24913         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24914         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24915         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
24916         CHECK_ACCESS(min_value_msat_ptr);
24917         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
24918         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
24919         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
24920         *ret_conv = ChannelManager_create_inbound_payment_for_hash(&this_arg_conv, payment_hash_ref, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
24921         return (uint64_t)ret_conv;
24922 }
24923
24924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24925         LDKChannelManager this_arg_conv;
24926         this_arg_conv.inner = (void*)(this_arg & (~1));
24927         this_arg_conv.is_owned = false;
24928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24929         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24930         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
24931         return (uint64_t)ret_ret;
24932 }
24933
24934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24935         LDKChannelManager this_arg_conv;
24936         this_arg_conv.inner = (void*)(this_arg & (~1));
24937         this_arg_conv.is_owned = false;
24938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24939         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
24940         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
24941         return (uint64_t)ret_ret;
24942 }
24943
24944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
24945         LDKChannelManager this_arg_conv;
24946         this_arg_conv.inner = (void*)(this_arg & (~1));
24947         this_arg_conv.is_owned = false;
24948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24949         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
24950         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
24951         return (uint64_t)ret_ret;
24952 }
24953
24954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
24955         LDKChannelManager this_arg_conv;
24956         this_arg_conv.inner = (void*)(this_arg & (~1));
24957         this_arg_conv.is_owned = false;
24958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24959         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
24960         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
24961         return (uint64_t)ret_ret;
24962 }
24963
24964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update_1timeout(JNIEnv *env, jclass clz, int64_t this_arg, int64_t max_wait) {
24965         LDKChannelManager this_arg_conv;
24966         this_arg_conv.inner = (void*)(this_arg & (~1));
24967         this_arg_conv.is_owned = false;
24968         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24969         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
24970         return ret_val;
24971 }
24972
24973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
24974         LDKChannelManager this_arg_conv;
24975         this_arg_conv.inner = (void*)(this_arg & (~1));
24976         this_arg_conv.is_owned = false;
24977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24978         ChannelManager_await_persistable_update(&this_arg_conv);
24979 }
24980
24981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
24982         LDKChannelManager this_arg_conv;
24983         this_arg_conv.inner = (void*)(this_arg & (~1));
24984         this_arg_conv.is_owned = false;
24985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24986         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
24987         uint64_t ret_ref = 0;
24988         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24989         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24990         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24991         ret_ref = (uint64_t)ret_var.inner;
24992         if (ret_var.is_owned) {
24993                 ret_ref |= 1;
24994         }
24995         return ret_ref;
24996 }
24997
24998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
24999         LDKChannelManager this_arg_conv;
25000         this_arg_conv.inner = (void*)(this_arg & (~1));
25001         this_arg_conv.is_owned = false;
25002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25003         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25004         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25005         return (uint64_t)ret_ret;
25006 }
25007
25008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
25009         LDKChannelManager obj_conv;
25010         obj_conv.inner = (void*)(obj & (~1));
25011         obj_conv.is_owned = false;
25012         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25013         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25014         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25015         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25016         CVec_u8Z_free(ret_var);
25017         return ret_arr;
25018 }
25019
25020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25021         LDKChannelManagerReadArgs this_obj_conv;
25022         this_obj_conv.inner = (void*)(this_obj & (~1));
25023         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25025         ChannelManagerReadArgs_free(this_obj_conv);
25026 }
25027
25028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
25029         LDKChannelManagerReadArgs this_ptr_conv;
25030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25031         this_ptr_conv.is_owned = false;
25032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25033         // WARNING: This object doesn't live past this scope, needs clone!
25034         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25035         return ret_ret;
25036 }
25037
25038 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25039         LDKChannelManagerReadArgs this_ptr_conv;
25040         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25041         this_ptr_conv.is_owned = false;
25042         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25043         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25044         CHECK_ACCESS(val_ptr);
25045         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25046         if (val_conv.free == LDKKeysInterface_JCalls_free) {
25047                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25048                 LDKKeysInterface_JCalls_cloned(&val_conv);
25049         }
25050         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25051 }
25052
25053 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
25054         LDKChannelManagerReadArgs this_ptr_conv;
25055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25056         this_ptr_conv.is_owned = false;
25057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25058         // WARNING: This object doesn't live past this scope, needs clone!
25059         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25060         return ret_ret;
25061 }
25062
25063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25064         LDKChannelManagerReadArgs this_ptr_conv;
25065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25066         this_ptr_conv.is_owned = false;
25067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25068         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25069         CHECK_ACCESS(val_ptr);
25070         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25071         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
25072                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25073                 LDKFeeEstimator_JCalls_cloned(&val_conv);
25074         }
25075         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25076 }
25077
25078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
25079         LDKChannelManagerReadArgs this_ptr_conv;
25080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25081         this_ptr_conv.is_owned = false;
25082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25083         // WARNING: This object doesn't live past this scope, needs clone!
25084         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25085         return ret_ret;
25086 }
25087
25088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25089         LDKChannelManagerReadArgs this_ptr_conv;
25090         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25091         this_ptr_conv.is_owned = false;
25092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25093         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25094         CHECK_ACCESS(val_ptr);
25095         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25096         if (val_conv.free == LDKWatch_JCalls_free) {
25097                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25098                 LDKWatch_JCalls_cloned(&val_conv);
25099         }
25100         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25101 }
25102
25103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
25104         LDKChannelManagerReadArgs this_ptr_conv;
25105         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25106         this_ptr_conv.is_owned = false;
25107         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25108         // WARNING: This object doesn't live past this scope, needs clone!
25109         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
25110         return ret_ret;
25111 }
25112
25113 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25114         LDKChannelManagerReadArgs this_ptr_conv;
25115         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25116         this_ptr_conv.is_owned = false;
25117         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25118         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25119         CHECK_ACCESS(val_ptr);
25120         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
25121         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
25122                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25123                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
25124         }
25125         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
25126 }
25127
25128 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
25129         LDKChannelManagerReadArgs this_ptr_conv;
25130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25131         this_ptr_conv.is_owned = false;
25132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25133         // WARNING: This object doesn't live past this scope, needs clone!
25134         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
25135         return ret_ret;
25136 }
25137
25138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25139         LDKChannelManagerReadArgs this_ptr_conv;
25140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25141         this_ptr_conv.is_owned = false;
25142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25143         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25144         CHECK_ACCESS(val_ptr);
25145         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
25146         if (val_conv.free == LDKLogger_JCalls_free) {
25147                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25148                 LDKLogger_JCalls_cloned(&val_conv);
25149         }
25150         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
25151 }
25152
25153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25154         LDKChannelManagerReadArgs this_ptr_conv;
25155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25156         this_ptr_conv.is_owned = false;
25157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25158         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
25159         uint64_t ret_ref = 0;
25160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25163         ret_ref = (uint64_t)ret_var.inner;
25164         if (ret_var.is_owned) {
25165                 ret_ref |= 1;
25166         }
25167         return ret_ref;
25168 }
25169
25170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25171         LDKChannelManagerReadArgs this_ptr_conv;
25172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25173         this_ptr_conv.is_owned = false;
25174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25175         LDKUserConfig val_conv;
25176         val_conv.inner = (void*)(val & (~1));
25177         val_conv.is_owned = (val & 1) || (val == 0);
25178         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25179         val_conv = UserConfig_clone(&val_conv);
25180         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
25181 }
25182
25183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1new(JNIEnv *env, jclass clz, int64_t keys_manager, int64_t fee_estimator, int64_t chain_monitor, int64_t tx_broadcaster, int64_t logger, int64_t default_config, int64_tArray channel_monitors) {
25184         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
25185         CHECK_ACCESS(keys_manager_ptr);
25186         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25187         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25188                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25189                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25190         }
25191         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
25192         CHECK_ACCESS(fee_estimator_ptr);
25193         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25194         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25195                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25196                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25197         }
25198         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
25199         CHECK_ACCESS(chain_monitor_ptr);
25200         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25201         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
25202                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25203                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
25204         }
25205         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
25206         CHECK_ACCESS(tx_broadcaster_ptr);
25207         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25208         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25209                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25210                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
25211         }
25212         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
25213         CHECK_ACCESS(logger_ptr);
25214         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25215         if (logger_conv.free == LDKLogger_JCalls_free) {
25216                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25217                 LDKLogger_JCalls_cloned(&logger_conv);
25218         }
25219         LDKUserConfig default_config_conv;
25220         default_config_conv.inner = (void*)(default_config & (~1));
25221         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
25222         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
25223         default_config_conv = UserConfig_clone(&default_config_conv);
25224         LDKCVec_ChannelMonitorZ channel_monitors_constr;
25225         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
25226         if (channel_monitors_constr.datalen > 0)
25227                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
25228         else
25229                 channel_monitors_constr.data = NULL;
25230         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
25231         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
25232                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
25233                 LDKChannelMonitor channel_monitors_conv_16_conv;
25234                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
25235                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
25236                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
25237                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
25238         }
25239         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
25240         LDKChannelManagerReadArgs ret_var = ChannelManagerReadArgs_new(keys_manager_conv, fee_estimator_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, default_config_conv, channel_monitors_constr);
25241         uint64_t ret_ref = 0;
25242         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25243         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25244         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25245         ret_ref = (uint64_t)ret_var.inner;
25246         if (ret_var.is_owned) {
25247                 ret_ref |= 1;
25248         }
25249         return ret_ref;
25250 }
25251
25252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
25253         LDKu8slice ser_ref;
25254         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25255         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25256         LDKChannelManagerReadArgs arg_conv;
25257         arg_conv.inner = (void*)(arg & (~1));
25258         arg_conv.is_owned = (arg & 1) || (arg == 0);
25259         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25260         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
25261         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
25262         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
25263         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25264         return (uint64_t)ret_conv;
25265 }
25266
25267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25268         LDKDecodeError this_obj_conv;
25269         this_obj_conv.inner = (void*)(this_obj & (~1));
25270         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25272         DecodeError_free(this_obj_conv);
25273 }
25274
25275 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
25276         LDKDecodeError ret_var = DecodeError_clone(arg);
25277 uint64_t ret_ref = 0;
25278 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25279 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25280 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25281 ret_ref = (uint64_t)ret_var.inner;
25282 if (ret_var.is_owned) {
25283         ret_ref |= 1;
25284 }
25285         return ret_ref;
25286 }
25287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25288         LDKDecodeError arg_conv;
25289         arg_conv.inner = (void*)(arg & (~1));
25290         arg_conv.is_owned = false;
25291         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25292         int64_t ret_val = DecodeError_clone_ptr(&arg_conv);
25293         return ret_val;
25294 }
25295
25296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25297         LDKDecodeError orig_conv;
25298         orig_conv.inner = (void*)(orig & (~1));
25299         orig_conv.is_owned = false;
25300         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25301         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
25302         uint64_t ret_ref = 0;
25303         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25304         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25305         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25306         ret_ref = (uint64_t)ret_var.inner;
25307         if (ret_var.is_owned) {
25308                 ret_ref |= 1;
25309         }
25310         return ret_ref;
25311 }
25312
25313 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25314         LDKInit this_obj_conv;
25315         this_obj_conv.inner = (void*)(this_obj & (~1));
25316         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25317         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25318         Init_free(this_obj_conv);
25319 }
25320
25321 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
25322         LDKInit this_ptr_conv;
25323         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25324         this_ptr_conv.is_owned = false;
25325         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25326         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
25327         uint64_t ret_ref = 0;
25328         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25329         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25330         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25331         ret_ref = (uint64_t)ret_var.inner;
25332         if (ret_var.is_owned) {
25333                 ret_ref |= 1;
25334         }
25335         return ret_ref;
25336 }
25337
25338 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25339         LDKInit this_ptr_conv;
25340         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25341         this_ptr_conv.is_owned = false;
25342         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25343         LDKInitFeatures val_conv;
25344         val_conv.inner = (void*)(val & (~1));
25345         val_conv.is_owned = (val & 1) || (val == 0);
25346         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25347         val_conv = InitFeatures_clone(&val_conv);
25348         Init_set_features(&this_ptr_conv, val_conv);
25349 }
25350
25351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
25352         LDKInitFeatures features_arg_conv;
25353         features_arg_conv.inner = (void*)(features_arg & (~1));
25354         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25355         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
25356         features_arg_conv = InitFeatures_clone(&features_arg_conv);
25357         LDKInit ret_var = Init_new(features_arg_conv);
25358         uint64_t ret_ref = 0;
25359         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25360         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25361         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25362         ret_ref = (uint64_t)ret_var.inner;
25363         if (ret_var.is_owned) {
25364                 ret_ref |= 1;
25365         }
25366         return ret_ref;
25367 }
25368
25369 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
25370         LDKInit ret_var = Init_clone(arg);
25371 uint64_t ret_ref = 0;
25372 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25373 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25374 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25375 ret_ref = (uint64_t)ret_var.inner;
25376 if (ret_var.is_owned) {
25377         ret_ref |= 1;
25378 }
25379         return ret_ref;
25380 }
25381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25382         LDKInit arg_conv;
25383         arg_conv.inner = (void*)(arg & (~1));
25384         arg_conv.is_owned = false;
25385         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25386         int64_t ret_val = Init_clone_ptr(&arg_conv);
25387         return ret_val;
25388 }
25389
25390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25391         LDKInit orig_conv;
25392         orig_conv.inner = (void*)(orig & (~1));
25393         orig_conv.is_owned = false;
25394         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25395         LDKInit ret_var = Init_clone(&orig_conv);
25396         uint64_t ret_ref = 0;
25397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25400         ret_ref = (uint64_t)ret_var.inner;
25401         if (ret_var.is_owned) {
25402                 ret_ref |= 1;
25403         }
25404         return ret_ref;
25405 }
25406
25407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25408         LDKErrorMessage this_obj_conv;
25409         this_obj_conv.inner = (void*)(this_obj & (~1));
25410         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25412         ErrorMessage_free(this_obj_conv);
25413 }
25414
25415 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25416         LDKErrorMessage this_ptr_conv;
25417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25418         this_ptr_conv.is_owned = false;
25419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25420         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25421         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
25422         return ret_arr;
25423 }
25424
25425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25426         LDKErrorMessage this_ptr_conv;
25427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25428         this_ptr_conv.is_owned = false;
25429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25430         LDKThirtyTwoBytes val_ref;
25431         CHECK((*env)->GetArrayLength(env, val) == 32);
25432         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25433         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
25434 }
25435
25436 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
25437         LDKErrorMessage this_ptr_conv;
25438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25439         this_ptr_conv.is_owned = false;
25440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25441         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
25442         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25443         Str_free(ret_str);
25444         return ret_conv;
25445 }
25446
25447 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25448         LDKErrorMessage this_ptr_conv;
25449         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25450         this_ptr_conv.is_owned = false;
25451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25452         LDKStr val_conv = java_to_owned_str(env, val);
25453         ErrorMessage_set_data(&this_ptr_conv, val_conv);
25454 }
25455
25456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
25457         LDKThirtyTwoBytes channel_id_arg_ref;
25458         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
25459         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
25460         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
25461         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
25462         uint64_t ret_ref = 0;
25463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25466         ret_ref = (uint64_t)ret_var.inner;
25467         if (ret_var.is_owned) {
25468                 ret_ref |= 1;
25469         }
25470         return ret_ref;
25471 }
25472
25473 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
25474         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
25475 uint64_t ret_ref = 0;
25476 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25477 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25478 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25479 ret_ref = (uint64_t)ret_var.inner;
25480 if (ret_var.is_owned) {
25481         ret_ref |= 1;
25482 }
25483         return ret_ref;
25484 }
25485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25486         LDKErrorMessage arg_conv;
25487         arg_conv.inner = (void*)(arg & (~1));
25488         arg_conv.is_owned = false;
25489         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25490         int64_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
25491         return ret_val;
25492 }
25493
25494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25495         LDKErrorMessage orig_conv;
25496         orig_conv.inner = (void*)(orig & (~1));
25497         orig_conv.is_owned = false;
25498         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25499         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
25500         uint64_t ret_ref = 0;
25501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25504         ret_ref = (uint64_t)ret_var.inner;
25505         if (ret_var.is_owned) {
25506                 ret_ref |= 1;
25507         }
25508         return ret_ref;
25509 }
25510
25511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25512         LDKPing this_obj_conv;
25513         this_obj_conv.inner = (void*)(this_obj & (~1));
25514         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25516         Ping_free(this_obj_conv);
25517 }
25518
25519 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
25520         LDKPing this_ptr_conv;
25521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25522         this_ptr_conv.is_owned = false;
25523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25524         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
25525         return ret_val;
25526 }
25527
25528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25529         LDKPing this_ptr_conv;
25530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25531         this_ptr_conv.is_owned = false;
25532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25533         Ping_set_ponglen(&this_ptr_conv, val);
25534 }
25535
25536 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
25537         LDKPing this_ptr_conv;
25538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25539         this_ptr_conv.is_owned = false;
25540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25541         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
25542         return ret_val;
25543 }
25544
25545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25546         LDKPing this_ptr_conv;
25547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25548         this_ptr_conv.is_owned = false;
25549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25550         Ping_set_byteslen(&this_ptr_conv, val);
25551 }
25552
25553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
25554         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
25555         uint64_t ret_ref = 0;
25556         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25557         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25558         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25559         ret_ref = (uint64_t)ret_var.inner;
25560         if (ret_var.is_owned) {
25561                 ret_ref |= 1;
25562         }
25563         return ret_ref;
25564 }
25565
25566 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
25567         LDKPing ret_var = Ping_clone(arg);
25568 uint64_t ret_ref = 0;
25569 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25570 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25571 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25572 ret_ref = (uint64_t)ret_var.inner;
25573 if (ret_var.is_owned) {
25574         ret_ref |= 1;
25575 }
25576         return ret_ref;
25577 }
25578 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25579         LDKPing arg_conv;
25580         arg_conv.inner = (void*)(arg & (~1));
25581         arg_conv.is_owned = false;
25582         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25583         int64_t ret_val = Ping_clone_ptr(&arg_conv);
25584         return ret_val;
25585 }
25586
25587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25588         LDKPing orig_conv;
25589         orig_conv.inner = (void*)(orig & (~1));
25590         orig_conv.is_owned = false;
25591         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25592         LDKPing ret_var = Ping_clone(&orig_conv);
25593         uint64_t ret_ref = 0;
25594         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25595         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25596         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25597         ret_ref = (uint64_t)ret_var.inner;
25598         if (ret_var.is_owned) {
25599                 ret_ref |= 1;
25600         }
25601         return ret_ref;
25602 }
25603
25604 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25605         LDKPong this_obj_conv;
25606         this_obj_conv.inner = (void*)(this_obj & (~1));
25607         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25608         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25609         Pong_free(this_obj_conv);
25610 }
25611
25612 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
25613         LDKPong this_ptr_conv;
25614         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25615         this_ptr_conv.is_owned = false;
25616         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25617         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
25618         return ret_val;
25619 }
25620
25621 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25622         LDKPong this_ptr_conv;
25623         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25624         this_ptr_conv.is_owned = false;
25625         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25626         Pong_set_byteslen(&this_ptr_conv, val);
25627 }
25628
25629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
25630         LDKPong ret_var = Pong_new(byteslen_arg);
25631         uint64_t ret_ref = 0;
25632         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25633         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25634         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25635         ret_ref = (uint64_t)ret_var.inner;
25636         if (ret_var.is_owned) {
25637                 ret_ref |= 1;
25638         }
25639         return ret_ref;
25640 }
25641
25642 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
25643         LDKPong ret_var = Pong_clone(arg);
25644 uint64_t ret_ref = 0;
25645 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25646 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25647 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25648 ret_ref = (uint64_t)ret_var.inner;
25649 if (ret_var.is_owned) {
25650         ret_ref |= 1;
25651 }
25652         return ret_ref;
25653 }
25654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25655         LDKPong arg_conv;
25656         arg_conv.inner = (void*)(arg & (~1));
25657         arg_conv.is_owned = false;
25658         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25659         int64_t ret_val = Pong_clone_ptr(&arg_conv);
25660         return ret_val;
25661 }
25662
25663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25664         LDKPong orig_conv;
25665         orig_conv.inner = (void*)(orig & (~1));
25666         orig_conv.is_owned = false;
25667         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25668         LDKPong ret_var = Pong_clone(&orig_conv);
25669         uint64_t ret_ref = 0;
25670         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25671         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25672         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25673         ret_ref = (uint64_t)ret_var.inner;
25674         if (ret_var.is_owned) {
25675                 ret_ref |= 1;
25676         }
25677         return ret_ref;
25678 }
25679
25680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25681         LDKOpenChannel this_obj_conv;
25682         this_obj_conv.inner = (void*)(this_obj & (~1));
25683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25685         OpenChannel_free(this_obj_conv);
25686 }
25687
25688 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25689         LDKOpenChannel this_ptr_conv;
25690         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25691         this_ptr_conv.is_owned = false;
25692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25693         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25694         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
25695         return ret_arr;
25696 }
25697
25698 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25699         LDKOpenChannel this_ptr_conv;
25700         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25701         this_ptr_conv.is_owned = false;
25702         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25703         LDKThirtyTwoBytes val_ref;
25704         CHECK((*env)->GetArrayLength(env, val) == 32);
25705         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25706         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
25707 }
25708
25709 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25710         LDKOpenChannel this_ptr_conv;
25711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25712         this_ptr_conv.is_owned = false;
25713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25714         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25715         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
25716         return ret_arr;
25717 }
25718
25719 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25720         LDKOpenChannel this_ptr_conv;
25721         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25722         this_ptr_conv.is_owned = false;
25723         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25724         LDKThirtyTwoBytes val_ref;
25725         CHECK((*env)->GetArrayLength(env, val) == 32);
25726         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25727         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
25728 }
25729
25730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25731         LDKOpenChannel this_ptr_conv;
25732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25733         this_ptr_conv.is_owned = false;
25734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25735         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
25736         return ret_val;
25737 }
25738
25739 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25740         LDKOpenChannel this_ptr_conv;
25741         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25742         this_ptr_conv.is_owned = false;
25743         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25744         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
25745 }
25746
25747 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25748         LDKOpenChannel this_ptr_conv;
25749         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25750         this_ptr_conv.is_owned = false;
25751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25752         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
25753         return ret_val;
25754 }
25755
25756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25757         LDKOpenChannel this_ptr_conv;
25758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25759         this_ptr_conv.is_owned = false;
25760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25761         OpenChannel_set_push_msat(&this_ptr_conv, val);
25762 }
25763
25764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25765         LDKOpenChannel this_ptr_conv;
25766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25767         this_ptr_conv.is_owned = false;
25768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25769         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
25770         return ret_val;
25771 }
25772
25773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25774         LDKOpenChannel this_ptr_conv;
25775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25776         this_ptr_conv.is_owned = false;
25777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25778         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
25779 }
25780
25781 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) {
25782         LDKOpenChannel this_ptr_conv;
25783         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25784         this_ptr_conv.is_owned = false;
25785         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25786         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
25787         return ret_val;
25788 }
25789
25790 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) {
25791         LDKOpenChannel this_ptr_conv;
25792         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25793         this_ptr_conv.is_owned = false;
25794         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25795         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
25796 }
25797
25798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25799         LDKOpenChannel this_ptr_conv;
25800         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25801         this_ptr_conv.is_owned = false;
25802         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25803         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
25804         return ret_val;
25805 }
25806
25807 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25808         LDKOpenChannel this_ptr_conv;
25809         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25810         this_ptr_conv.is_owned = false;
25811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25812         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
25813 }
25814
25815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25816         LDKOpenChannel this_ptr_conv;
25817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25818         this_ptr_conv.is_owned = false;
25819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25820         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
25821         return ret_val;
25822 }
25823
25824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25825         LDKOpenChannel this_ptr_conv;
25826         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25827         this_ptr_conv.is_owned = false;
25828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25829         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
25830 }
25831
25832 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
25833         LDKOpenChannel this_ptr_conv;
25834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25835         this_ptr_conv.is_owned = false;
25836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25837         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
25838         return ret_val;
25839 }
25840
25841 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25842         LDKOpenChannel this_ptr_conv;
25843         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25844         this_ptr_conv.is_owned = false;
25845         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25846         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
25847 }
25848
25849 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25850         LDKOpenChannel this_ptr_conv;
25851         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25852         this_ptr_conv.is_owned = false;
25853         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25854         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
25855         return ret_val;
25856 }
25857
25858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25859         LDKOpenChannel this_ptr_conv;
25860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25861         this_ptr_conv.is_owned = false;
25862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25863         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
25864 }
25865
25866 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25867         LDKOpenChannel this_ptr_conv;
25868         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25869         this_ptr_conv.is_owned = false;
25870         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25871         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
25872         return ret_val;
25873 }
25874
25875 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25876         LDKOpenChannel this_ptr_conv;
25877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25878         this_ptr_conv.is_owned = false;
25879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25880         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
25881 }
25882
25883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25884         LDKOpenChannel this_ptr_conv;
25885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25886         this_ptr_conv.is_owned = false;
25887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25888         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25889         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
25890         return ret_arr;
25891 }
25892
25893 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25894         LDKOpenChannel this_ptr_conv;
25895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25896         this_ptr_conv.is_owned = false;
25897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25898         LDKPublicKey val_ref;
25899         CHECK((*env)->GetArrayLength(env, val) == 33);
25900         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25901         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
25902 }
25903
25904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25905         LDKOpenChannel this_ptr_conv;
25906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25907         this_ptr_conv.is_owned = false;
25908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25909         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
25911         return ret_arr;
25912 }
25913
25914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25915         LDKOpenChannel this_ptr_conv;
25916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25917         this_ptr_conv.is_owned = false;
25918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25919         LDKPublicKey val_ref;
25920         CHECK((*env)->GetArrayLength(env, val) == 33);
25921         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25922         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
25923 }
25924
25925 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
25926         LDKOpenChannel this_ptr_conv;
25927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25928         this_ptr_conv.is_owned = false;
25929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25930         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25931         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
25932         return ret_arr;
25933 }
25934
25935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25936         LDKOpenChannel this_ptr_conv;
25937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25938         this_ptr_conv.is_owned = false;
25939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25940         LDKPublicKey val_ref;
25941         CHECK((*env)->GetArrayLength(env, val) == 33);
25942         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25943         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
25944 }
25945
25946 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25947         LDKOpenChannel this_ptr_conv;
25948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25949         this_ptr_conv.is_owned = false;
25950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25951         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25952         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
25953         return ret_arr;
25954 }
25955
25956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25957         LDKOpenChannel this_ptr_conv;
25958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25959         this_ptr_conv.is_owned = false;
25960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25961         LDKPublicKey val_ref;
25962         CHECK((*env)->GetArrayLength(env, val) == 33);
25963         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25964         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
25965 }
25966
25967 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25968         LDKOpenChannel this_ptr_conv;
25969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25970         this_ptr_conv.is_owned = false;
25971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25972         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25973         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
25974         return ret_arr;
25975 }
25976
25977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25978         LDKOpenChannel this_ptr_conv;
25979         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25980         this_ptr_conv.is_owned = false;
25981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25982         LDKPublicKey val_ref;
25983         CHECK((*env)->GetArrayLength(env, val) == 33);
25984         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25985         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
25986 }
25987
25988 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
25989         LDKOpenChannel this_ptr_conv;
25990         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25991         this_ptr_conv.is_owned = false;
25992         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25993         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25994         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
25995         return ret_arr;
25996 }
25997
25998 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) {
25999         LDKOpenChannel this_ptr_conv;
26000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26001         this_ptr_conv.is_owned = false;
26002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26003         LDKPublicKey val_ref;
26004         CHECK((*env)->GetArrayLength(env, val) == 33);
26005         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26006         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26007 }
26008
26009 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
26010         LDKOpenChannel this_ptr_conv;
26011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26012         this_ptr_conv.is_owned = false;
26013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26014         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
26015         return ret_val;
26016 }
26017
26018 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
26019         LDKOpenChannel this_ptr_conv;
26020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26021         this_ptr_conv.is_owned = false;
26022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26023         OpenChannel_set_channel_flags(&this_ptr_conv, val);
26024 }
26025
26026 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
26027         LDKOpenChannel ret_var = OpenChannel_clone(arg);
26028 uint64_t ret_ref = 0;
26029 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26030 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26031 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26032 ret_ref = (uint64_t)ret_var.inner;
26033 if (ret_var.is_owned) {
26034         ret_ref |= 1;
26035 }
26036         return ret_ref;
26037 }
26038 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26039         LDKOpenChannel arg_conv;
26040         arg_conv.inner = (void*)(arg & (~1));
26041         arg_conv.is_owned = false;
26042         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26043         int64_t ret_val = OpenChannel_clone_ptr(&arg_conv);
26044         return ret_val;
26045 }
26046
26047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26048         LDKOpenChannel orig_conv;
26049         orig_conv.inner = (void*)(orig & (~1));
26050         orig_conv.is_owned = false;
26051         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26052         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
26053         uint64_t ret_ref = 0;
26054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26057         ret_ref = (uint64_t)ret_var.inner;
26058         if (ret_var.is_owned) {
26059                 ret_ref |= 1;
26060         }
26061         return ret_ref;
26062 }
26063
26064 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26065         LDKAcceptChannel this_obj_conv;
26066         this_obj_conv.inner = (void*)(this_obj & (~1));
26067         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26068         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26069         AcceptChannel_free(this_obj_conv);
26070 }
26071
26072 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26073         LDKAcceptChannel this_ptr_conv;
26074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26075         this_ptr_conv.is_owned = false;
26076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26077         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26078         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
26079         return ret_arr;
26080 }
26081
26082 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26083         LDKAcceptChannel this_ptr_conv;
26084         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26085         this_ptr_conv.is_owned = false;
26086         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26087         LDKThirtyTwoBytes val_ref;
26088         CHECK((*env)->GetArrayLength(env, val) == 32);
26089         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26090         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26091 }
26092
26093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26094         LDKAcceptChannel this_ptr_conv;
26095         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26096         this_ptr_conv.is_owned = false;
26097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26098         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
26099         return ret_val;
26100 }
26101
26102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26103         LDKAcceptChannel this_ptr_conv;
26104         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26105         this_ptr_conv.is_owned = false;
26106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26107         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26108 }
26109
26110 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) {
26111         LDKAcceptChannel this_ptr_conv;
26112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26113         this_ptr_conv.is_owned = false;
26114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26115         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26116         return ret_val;
26117 }
26118
26119 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) {
26120         LDKAcceptChannel this_ptr_conv;
26121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26122         this_ptr_conv.is_owned = false;
26123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26124         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26125 }
26126
26127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26128         LDKAcceptChannel this_ptr_conv;
26129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26130         this_ptr_conv.is_owned = false;
26131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26132         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26133         return ret_val;
26134 }
26135
26136 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26137         LDKAcceptChannel this_ptr_conv;
26138         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26139         this_ptr_conv.is_owned = false;
26140         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26141         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26142 }
26143
26144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26145         LDKAcceptChannel this_ptr_conv;
26146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26147         this_ptr_conv.is_owned = false;
26148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26149         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
26150         return ret_val;
26151 }
26152
26153 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26154         LDKAcceptChannel this_ptr_conv;
26155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26156         this_ptr_conv.is_owned = false;
26157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26158         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26159 }
26160
26161 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26162         LDKAcceptChannel this_ptr_conv;
26163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26164         this_ptr_conv.is_owned = false;
26165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26166         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
26167         return ret_val;
26168 }
26169
26170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26171         LDKAcceptChannel this_ptr_conv;
26172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26173         this_ptr_conv.is_owned = false;
26174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26175         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
26176 }
26177
26178 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26179         LDKAcceptChannel this_ptr_conv;
26180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26181         this_ptr_conv.is_owned = false;
26182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26183         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
26184         return ret_val;
26185 }
26186
26187 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26188         LDKAcceptChannel this_ptr_conv;
26189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26190         this_ptr_conv.is_owned = false;
26191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26192         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
26193 }
26194
26195 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
26196         LDKAcceptChannel this_ptr_conv;
26197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26198         this_ptr_conv.is_owned = false;
26199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26200         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
26201         return ret_val;
26202 }
26203
26204 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26205         LDKAcceptChannel this_ptr_conv;
26206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26207         this_ptr_conv.is_owned = false;
26208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26209         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26210 }
26211
26212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26213         LDKAcceptChannel this_ptr_conv;
26214         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26215         this_ptr_conv.is_owned = false;
26216         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26217         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26218         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
26219         return ret_arr;
26220 }
26221
26222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26223         LDKAcceptChannel this_ptr_conv;
26224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26225         this_ptr_conv.is_owned = false;
26226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26227         LDKPublicKey val_ref;
26228         CHECK((*env)->GetArrayLength(env, val) == 33);
26229         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26230         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26231 }
26232
26233 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26234         LDKAcceptChannel this_ptr_conv;
26235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26236         this_ptr_conv.is_owned = false;
26237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26238         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26239         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
26240         return ret_arr;
26241 }
26242
26243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26244         LDKAcceptChannel this_ptr_conv;
26245         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26246         this_ptr_conv.is_owned = false;
26247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26248         LDKPublicKey val_ref;
26249         CHECK((*env)->GetArrayLength(env, val) == 33);
26250         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26251         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26252 }
26253
26254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26255         LDKAcceptChannel this_ptr_conv;
26256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26257         this_ptr_conv.is_owned = false;
26258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26259         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
26261         return ret_arr;
26262 }
26263
26264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26265         LDKAcceptChannel this_ptr_conv;
26266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26267         this_ptr_conv.is_owned = false;
26268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26269         LDKPublicKey val_ref;
26270         CHECK((*env)->GetArrayLength(env, val) == 33);
26271         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26272         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
26273 }
26274
26275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26276         LDKAcceptChannel this_ptr_conv;
26277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26278         this_ptr_conv.is_owned = false;
26279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26280         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26281         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
26282         return ret_arr;
26283 }
26284
26285 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26286         LDKAcceptChannel this_ptr_conv;
26287         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26288         this_ptr_conv.is_owned = false;
26289         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26290         LDKPublicKey val_ref;
26291         CHECK((*env)->GetArrayLength(env, val) == 33);
26292         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26293         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26294 }
26295
26296 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26297         LDKAcceptChannel this_ptr_conv;
26298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26299         this_ptr_conv.is_owned = false;
26300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26301         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26302         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
26303         return ret_arr;
26304 }
26305
26306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26307         LDKAcceptChannel this_ptr_conv;
26308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26309         this_ptr_conv.is_owned = false;
26310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26311         LDKPublicKey val_ref;
26312         CHECK((*env)->GetArrayLength(env, val) == 33);
26313         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26314         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26315 }
26316
26317 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26318         LDKAcceptChannel this_ptr_conv;
26319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26320         this_ptr_conv.is_owned = false;
26321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26322         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26323         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
26324         return ret_arr;
26325 }
26326
26327 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) {
26328         LDKAcceptChannel this_ptr_conv;
26329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26330         this_ptr_conv.is_owned = false;
26331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26332         LDKPublicKey val_ref;
26333         CHECK((*env)->GetArrayLength(env, val) == 33);
26334         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26335         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26336 }
26337
26338 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
26339         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
26340 uint64_t ret_ref = 0;
26341 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26342 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26343 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26344 ret_ref = (uint64_t)ret_var.inner;
26345 if (ret_var.is_owned) {
26346         ret_ref |= 1;
26347 }
26348         return ret_ref;
26349 }
26350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26351         LDKAcceptChannel arg_conv;
26352         arg_conv.inner = (void*)(arg & (~1));
26353         arg_conv.is_owned = false;
26354         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26355         int64_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
26356         return ret_val;
26357 }
26358
26359 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26360         LDKAcceptChannel orig_conv;
26361         orig_conv.inner = (void*)(orig & (~1));
26362         orig_conv.is_owned = false;
26363         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26364         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
26365         uint64_t ret_ref = 0;
26366         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26367         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26369         ret_ref = (uint64_t)ret_var.inner;
26370         if (ret_var.is_owned) {
26371                 ret_ref |= 1;
26372         }
26373         return ret_ref;
26374 }
26375
26376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26377         LDKFundingCreated this_obj_conv;
26378         this_obj_conv.inner = (void*)(this_obj & (~1));
26379         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26381         FundingCreated_free(this_obj_conv);
26382 }
26383
26384 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26385         LDKFundingCreated this_ptr_conv;
26386         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26387         this_ptr_conv.is_owned = false;
26388         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26389         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26390         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
26391         return ret_arr;
26392 }
26393
26394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26395         LDKFundingCreated this_ptr_conv;
26396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26397         this_ptr_conv.is_owned = false;
26398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26399         LDKThirtyTwoBytes val_ref;
26400         CHECK((*env)->GetArrayLength(env, val) == 32);
26401         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26402         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
26403 }
26404
26405 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26406         LDKFundingCreated this_ptr_conv;
26407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26408         this_ptr_conv.is_owned = false;
26409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26410         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26411         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
26412         return ret_arr;
26413 }
26414
26415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26416         LDKFundingCreated this_ptr_conv;
26417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26418         this_ptr_conv.is_owned = false;
26419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26420         LDKThirtyTwoBytes val_ref;
26421         CHECK((*env)->GetArrayLength(env, val) == 32);
26422         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26423         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
26424 }
26425
26426 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
26427         LDKFundingCreated this_ptr_conv;
26428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26429         this_ptr_conv.is_owned = false;
26430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26431         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
26432         return ret_val;
26433 }
26434
26435 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26436         LDKFundingCreated this_ptr_conv;
26437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26438         this_ptr_conv.is_owned = false;
26439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26440         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
26441 }
26442
26443 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
26444         LDKFundingCreated this_ptr_conv;
26445         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26446         this_ptr_conv.is_owned = false;
26447         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26448         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26449         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
26450         return ret_arr;
26451 }
26452
26453 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26454         LDKFundingCreated this_ptr_conv;
26455         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26456         this_ptr_conv.is_owned = false;
26457         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26458         LDKSignature val_ref;
26459         CHECK((*env)->GetArrayLength(env, val) == 64);
26460         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
26461         FundingCreated_set_signature(&this_ptr_conv, val_ref);
26462 }
26463
26464 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) {
26465         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
26466         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
26467         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
26468         LDKThirtyTwoBytes funding_txid_arg_ref;
26469         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
26470         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
26471         LDKSignature signature_arg_ref;
26472         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
26473         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
26474         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
26475         uint64_t ret_ref = 0;
26476         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26477         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26478         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26479         ret_ref = (uint64_t)ret_var.inner;
26480         if (ret_var.is_owned) {
26481                 ret_ref |= 1;
26482         }
26483         return ret_ref;
26484 }
26485
26486 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
26487         LDKFundingCreated ret_var = FundingCreated_clone(arg);
26488 uint64_t ret_ref = 0;
26489 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26490 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26491 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26492 ret_ref = (uint64_t)ret_var.inner;
26493 if (ret_var.is_owned) {
26494         ret_ref |= 1;
26495 }
26496         return ret_ref;
26497 }
26498 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26499         LDKFundingCreated arg_conv;
26500         arg_conv.inner = (void*)(arg & (~1));
26501         arg_conv.is_owned = false;
26502         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26503         int64_t ret_val = FundingCreated_clone_ptr(&arg_conv);
26504         return ret_val;
26505 }
26506
26507 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26508         LDKFundingCreated orig_conv;
26509         orig_conv.inner = (void*)(orig & (~1));
26510         orig_conv.is_owned = false;
26511         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26512         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
26513         uint64_t ret_ref = 0;
26514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26517         ret_ref = (uint64_t)ret_var.inner;
26518         if (ret_var.is_owned) {
26519                 ret_ref |= 1;
26520         }
26521         return ret_ref;
26522 }
26523
26524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26525         LDKFundingSigned this_obj_conv;
26526         this_obj_conv.inner = (void*)(this_obj & (~1));
26527         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26529         FundingSigned_free(this_obj_conv);
26530 }
26531
26532 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26533         LDKFundingSigned this_ptr_conv;
26534         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26535         this_ptr_conv.is_owned = false;
26536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26537         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26538         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
26539         return ret_arr;
26540 }
26541
26542 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26543         LDKFundingSigned this_ptr_conv;
26544         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26545         this_ptr_conv.is_owned = false;
26546         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26547         LDKThirtyTwoBytes val_ref;
26548         CHECK((*env)->GetArrayLength(env, val) == 32);
26549         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26550         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
26551 }
26552
26553 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
26554         LDKFundingSigned this_ptr_conv;
26555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26556         this_ptr_conv.is_owned = false;
26557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26558         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26559         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
26560         return ret_arr;
26561 }
26562
26563 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26564         LDKFundingSigned this_ptr_conv;
26565         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26566         this_ptr_conv.is_owned = false;
26567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26568         LDKSignature val_ref;
26569         CHECK((*env)->GetArrayLength(env, val) == 64);
26570         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
26571         FundingSigned_set_signature(&this_ptr_conv, val_ref);
26572 }
26573
26574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
26575         LDKThirtyTwoBytes channel_id_arg_ref;
26576         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
26577         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
26578         LDKSignature signature_arg_ref;
26579         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
26580         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
26581         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
26582         uint64_t ret_ref = 0;
26583         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26584         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26585         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26586         ret_ref = (uint64_t)ret_var.inner;
26587         if (ret_var.is_owned) {
26588                 ret_ref |= 1;
26589         }
26590         return ret_ref;
26591 }
26592
26593 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
26594         LDKFundingSigned ret_var = FundingSigned_clone(arg);
26595 uint64_t ret_ref = 0;
26596 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26597 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26598 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26599 ret_ref = (uint64_t)ret_var.inner;
26600 if (ret_var.is_owned) {
26601         ret_ref |= 1;
26602 }
26603         return ret_ref;
26604 }
26605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26606         LDKFundingSigned arg_conv;
26607         arg_conv.inner = (void*)(arg & (~1));
26608         arg_conv.is_owned = false;
26609         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26610         int64_t ret_val = FundingSigned_clone_ptr(&arg_conv);
26611         return ret_val;
26612 }
26613
26614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26615         LDKFundingSigned orig_conv;
26616         orig_conv.inner = (void*)(orig & (~1));
26617         orig_conv.is_owned = false;
26618         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26619         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
26620         uint64_t ret_ref = 0;
26621         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26622         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26624         ret_ref = (uint64_t)ret_var.inner;
26625         if (ret_var.is_owned) {
26626                 ret_ref |= 1;
26627         }
26628         return ret_ref;
26629 }
26630
26631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26632         LDKFundingLocked this_obj_conv;
26633         this_obj_conv.inner = (void*)(this_obj & (~1));
26634         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26636         FundingLocked_free(this_obj_conv);
26637 }
26638
26639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26640         LDKFundingLocked this_ptr_conv;
26641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26642         this_ptr_conv.is_owned = false;
26643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26644         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26645         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
26646         return ret_arr;
26647 }
26648
26649 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26650         LDKFundingLocked this_ptr_conv;
26651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26652         this_ptr_conv.is_owned = false;
26653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26654         LDKThirtyTwoBytes val_ref;
26655         CHECK((*env)->GetArrayLength(env, val) == 32);
26656         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26657         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
26658 }
26659
26660 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26661         LDKFundingLocked this_ptr_conv;
26662         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26663         this_ptr_conv.is_owned = false;
26664         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26665         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26666         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
26667         return ret_arr;
26668 }
26669
26670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26671         LDKFundingLocked this_ptr_conv;
26672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26673         this_ptr_conv.is_owned = false;
26674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26675         LDKPublicKey val_ref;
26676         CHECK((*env)->GetArrayLength(env, val) == 33);
26677         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26678         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
26679 }
26680
26681 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray next_per_commitment_point_arg) {
26682         LDKThirtyTwoBytes channel_id_arg_ref;
26683         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
26684         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
26685         LDKPublicKey next_per_commitment_point_arg_ref;
26686         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
26687         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
26688         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
26689         uint64_t ret_ref = 0;
26690         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26691         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26692         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26693         ret_ref = (uint64_t)ret_var.inner;
26694         if (ret_var.is_owned) {
26695                 ret_ref |= 1;
26696         }
26697         return ret_ref;
26698 }
26699
26700 static inline uint64_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
26701         LDKFundingLocked ret_var = FundingLocked_clone(arg);
26702 uint64_t ret_ref = 0;
26703 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26704 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26705 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26706 ret_ref = (uint64_t)ret_var.inner;
26707 if (ret_var.is_owned) {
26708         ret_ref |= 1;
26709 }
26710         return ret_ref;
26711 }
26712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26713         LDKFundingLocked arg_conv;
26714         arg_conv.inner = (void*)(arg & (~1));
26715         arg_conv.is_owned = false;
26716         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26717         int64_t ret_val = FundingLocked_clone_ptr(&arg_conv);
26718         return ret_val;
26719 }
26720
26721 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26722         LDKFundingLocked orig_conv;
26723         orig_conv.inner = (void*)(orig & (~1));
26724         orig_conv.is_owned = false;
26725         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26726         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
26727         uint64_t ret_ref = 0;
26728         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26729         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26730         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26731         ret_ref = (uint64_t)ret_var.inner;
26732         if (ret_var.is_owned) {
26733                 ret_ref |= 1;
26734         }
26735         return ret_ref;
26736 }
26737
26738 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26739         LDKShutdown this_obj_conv;
26740         this_obj_conv.inner = (void*)(this_obj & (~1));
26741         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26742         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26743         Shutdown_free(this_obj_conv);
26744 }
26745
26746 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26747         LDKShutdown this_ptr_conv;
26748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26749         this_ptr_conv.is_owned = false;
26750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26751         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26752         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
26753         return ret_arr;
26754 }
26755
26756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26757         LDKShutdown this_ptr_conv;
26758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26759         this_ptr_conv.is_owned = false;
26760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26761         LDKThirtyTwoBytes val_ref;
26762         CHECK((*env)->GetArrayLength(env, val) == 32);
26763         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26764         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
26765 }
26766
26767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26768         LDKShutdown this_ptr_conv;
26769         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26770         this_ptr_conv.is_owned = false;
26771         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26772         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
26773         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26774         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26775         return ret_arr;
26776 }
26777
26778 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26779         LDKShutdown this_ptr_conv;
26780         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26781         this_ptr_conv.is_owned = false;
26782         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26783         LDKCVec_u8Z val_ref;
26784         val_ref.datalen = (*env)->GetArrayLength(env, val);
26785         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
26786         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26787         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
26788 }
26789
26790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
26791         LDKThirtyTwoBytes channel_id_arg_ref;
26792         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
26793         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
26794         LDKCVec_u8Z scriptpubkey_arg_ref;
26795         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
26796         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
26797         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
26798         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
26799         uint64_t ret_ref = 0;
26800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26803         ret_ref = (uint64_t)ret_var.inner;
26804         if (ret_var.is_owned) {
26805                 ret_ref |= 1;
26806         }
26807         return ret_ref;
26808 }
26809
26810 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
26811         LDKShutdown ret_var = Shutdown_clone(arg);
26812 uint64_t ret_ref = 0;
26813 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26814 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26815 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26816 ret_ref = (uint64_t)ret_var.inner;
26817 if (ret_var.is_owned) {
26818         ret_ref |= 1;
26819 }
26820         return ret_ref;
26821 }
26822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26823         LDKShutdown arg_conv;
26824         arg_conv.inner = (void*)(arg & (~1));
26825         arg_conv.is_owned = false;
26826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26827         int64_t ret_val = Shutdown_clone_ptr(&arg_conv);
26828         return ret_val;
26829 }
26830
26831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26832         LDKShutdown orig_conv;
26833         orig_conv.inner = (void*)(orig & (~1));
26834         orig_conv.is_owned = false;
26835         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26836         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
26837         uint64_t ret_ref = 0;
26838         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26839         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26841         ret_ref = (uint64_t)ret_var.inner;
26842         if (ret_var.is_owned) {
26843                 ret_ref |= 1;
26844         }
26845         return ret_ref;
26846 }
26847
26848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26849         LDKClosingSignedFeeRange this_obj_conv;
26850         this_obj_conv.inner = (void*)(this_obj & (~1));
26851         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26853         ClosingSignedFeeRange_free(this_obj_conv);
26854 }
26855
26856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26857         LDKClosingSignedFeeRange this_ptr_conv;
26858         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26859         this_ptr_conv.is_owned = false;
26860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26861         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
26862         return ret_val;
26863 }
26864
26865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26866         LDKClosingSignedFeeRange this_ptr_conv;
26867         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26868         this_ptr_conv.is_owned = false;
26869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26870         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
26871 }
26872
26873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26874         LDKClosingSignedFeeRange this_ptr_conv;
26875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26876         this_ptr_conv.is_owned = false;
26877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26878         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
26879         return ret_val;
26880 }
26881
26882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26883         LDKClosingSignedFeeRange this_ptr_conv;
26884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26885         this_ptr_conv.is_owned = false;
26886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26887         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
26888 }
26889
26890 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) {
26891         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
26892         uint64_t ret_ref = 0;
26893         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26894         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26895         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26896         ret_ref = (uint64_t)ret_var.inner;
26897         if (ret_var.is_owned) {
26898                 ret_ref |= 1;
26899         }
26900         return ret_ref;
26901 }
26902
26903 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
26904         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
26905 uint64_t ret_ref = 0;
26906 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26907 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26908 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26909 ret_ref = (uint64_t)ret_var.inner;
26910 if (ret_var.is_owned) {
26911         ret_ref |= 1;
26912 }
26913         return ret_ref;
26914 }
26915 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26916         LDKClosingSignedFeeRange arg_conv;
26917         arg_conv.inner = (void*)(arg & (~1));
26918         arg_conv.is_owned = false;
26919         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26920         int64_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
26921         return ret_val;
26922 }
26923
26924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26925         LDKClosingSignedFeeRange orig_conv;
26926         orig_conv.inner = (void*)(orig & (~1));
26927         orig_conv.is_owned = false;
26928         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26929         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
26930         uint64_t ret_ref = 0;
26931         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26932         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26934         ret_ref = (uint64_t)ret_var.inner;
26935         if (ret_var.is_owned) {
26936                 ret_ref |= 1;
26937         }
26938         return ret_ref;
26939 }
26940
26941 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26942         LDKClosingSigned this_obj_conv;
26943         this_obj_conv.inner = (void*)(this_obj & (~1));
26944         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26946         ClosingSigned_free(this_obj_conv);
26947 }
26948
26949 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26950         LDKClosingSigned this_ptr_conv;
26951         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26952         this_ptr_conv.is_owned = false;
26953         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26954         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26955         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
26956         return ret_arr;
26957 }
26958
26959 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26960         LDKClosingSigned this_ptr_conv;
26961         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26962         this_ptr_conv.is_owned = false;
26963         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26964         LDKThirtyTwoBytes val_ref;
26965         CHECK((*env)->GetArrayLength(env, val) == 32);
26966         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26967         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
26968 }
26969
26970 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26971         LDKClosingSigned this_ptr_conv;
26972         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26973         this_ptr_conv.is_owned = false;
26974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26975         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
26976         return ret_val;
26977 }
26978
26979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26980         LDKClosingSigned this_ptr_conv;
26981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26982         this_ptr_conv.is_owned = false;
26983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26984         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
26985 }
26986
26987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
26988         LDKClosingSigned this_ptr_conv;
26989         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26990         this_ptr_conv.is_owned = false;
26991         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26992         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26993         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
26994         return ret_arr;
26995 }
26996
26997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26998         LDKClosingSigned this_ptr_conv;
26999         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27000         this_ptr_conv.is_owned = false;
27001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27002         LDKSignature val_ref;
27003         CHECK((*env)->GetArrayLength(env, val) == 64);
27004         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
27005         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
27006 }
27007
27008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
27009         LDKClosingSigned this_ptr_conv;
27010         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27011         this_ptr_conv.is_owned = false;
27012         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27013         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
27014         uint64_t ret_ref = 0;
27015         if ((uint64_t)ret_var.inner > 4096) {
27016                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27017                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27018         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27019                 ret_ref = (uint64_t)ret_var.inner;
27020                 if (ret_var.is_owned) {
27021                         ret_ref |= 1;
27022                 }
27023         }
27024         return ret_ref;
27025 }
27026
27027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27028         LDKClosingSigned this_ptr_conv;
27029         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27030         this_ptr_conv.is_owned = false;
27031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27032         LDKClosingSignedFeeRange val_conv;
27033         val_conv.inner = (void*)(val & (~1));
27034         val_conv.is_owned = (val & 1) || (val == 0);
27035         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27036         val_conv = ClosingSignedFeeRange_clone(&val_conv);
27037         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
27038 }
27039
27040 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) {
27041         LDKThirtyTwoBytes channel_id_arg_ref;
27042         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27043         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27044         LDKSignature signature_arg_ref;
27045         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
27046         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
27047         LDKClosingSignedFeeRange fee_range_arg_conv;
27048         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
27049         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
27050         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
27051         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
27052         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
27053         uint64_t ret_ref = 0;
27054         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27055         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27056         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27057         ret_ref = (uint64_t)ret_var.inner;
27058         if (ret_var.is_owned) {
27059                 ret_ref |= 1;
27060         }
27061         return ret_ref;
27062 }
27063
27064 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
27065         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
27066 uint64_t ret_ref = 0;
27067 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27068 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27069 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27070 ret_ref = (uint64_t)ret_var.inner;
27071 if (ret_var.is_owned) {
27072         ret_ref |= 1;
27073 }
27074         return ret_ref;
27075 }
27076 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27077         LDKClosingSigned arg_conv;
27078         arg_conv.inner = (void*)(arg & (~1));
27079         arg_conv.is_owned = false;
27080         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27081         int64_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
27082         return ret_val;
27083 }
27084
27085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27086         LDKClosingSigned orig_conv;
27087         orig_conv.inner = (void*)(orig & (~1));
27088         orig_conv.is_owned = false;
27089         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27090         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
27091         uint64_t ret_ref = 0;
27092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27095         ret_ref = (uint64_t)ret_var.inner;
27096         if (ret_var.is_owned) {
27097                 ret_ref |= 1;
27098         }
27099         return ret_ref;
27100 }
27101
27102 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27103         LDKUpdateAddHTLC this_obj_conv;
27104         this_obj_conv.inner = (void*)(this_obj & (~1));
27105         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27107         UpdateAddHTLC_free(this_obj_conv);
27108 }
27109
27110 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27111         LDKUpdateAddHTLC this_ptr_conv;
27112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27113         this_ptr_conv.is_owned = false;
27114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27115         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27116         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
27117         return ret_arr;
27118 }
27119
27120 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27121         LDKUpdateAddHTLC this_ptr_conv;
27122         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27123         this_ptr_conv.is_owned = false;
27124         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27125         LDKThirtyTwoBytes val_ref;
27126         CHECK((*env)->GetArrayLength(env, val) == 32);
27127         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27128         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
27129 }
27130
27131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27132         LDKUpdateAddHTLC this_ptr_conv;
27133         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27134         this_ptr_conv.is_owned = false;
27135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27136         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
27137         return ret_val;
27138 }
27139
27140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27141         LDKUpdateAddHTLC this_ptr_conv;
27142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27143         this_ptr_conv.is_owned = false;
27144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27145         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
27146 }
27147
27148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27149         LDKUpdateAddHTLC this_ptr_conv;
27150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27151         this_ptr_conv.is_owned = false;
27152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27153         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
27154         return ret_val;
27155 }
27156
27157 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27158         LDKUpdateAddHTLC this_ptr_conv;
27159         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27160         this_ptr_conv.is_owned = false;
27161         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27162         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
27163 }
27164
27165 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
27166         LDKUpdateAddHTLC this_ptr_conv;
27167         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27168         this_ptr_conv.is_owned = false;
27169         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27170         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27171         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
27172         return ret_arr;
27173 }
27174
27175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27176         LDKUpdateAddHTLC this_ptr_conv;
27177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27178         this_ptr_conv.is_owned = false;
27179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27180         LDKThirtyTwoBytes val_ref;
27181         CHECK((*env)->GetArrayLength(env, val) == 32);
27182         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27183         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
27184 }
27185
27186 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
27187         LDKUpdateAddHTLC this_ptr_conv;
27188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27189         this_ptr_conv.is_owned = false;
27190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27191         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
27192         return ret_val;
27193 }
27194
27195 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27196         LDKUpdateAddHTLC this_ptr_conv;
27197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27198         this_ptr_conv.is_owned = false;
27199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27200         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
27201 }
27202
27203 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
27204         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
27205 uint64_t ret_ref = 0;
27206 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27207 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27208 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27209 ret_ref = (uint64_t)ret_var.inner;
27210 if (ret_var.is_owned) {
27211         ret_ref |= 1;
27212 }
27213         return ret_ref;
27214 }
27215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27216         LDKUpdateAddHTLC arg_conv;
27217         arg_conv.inner = (void*)(arg & (~1));
27218         arg_conv.is_owned = false;
27219         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27220         int64_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
27221         return ret_val;
27222 }
27223
27224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27225         LDKUpdateAddHTLC orig_conv;
27226         orig_conv.inner = (void*)(orig & (~1));
27227         orig_conv.is_owned = false;
27228         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27229         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
27230         uint64_t ret_ref = 0;
27231         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27232         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27233         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27234         ret_ref = (uint64_t)ret_var.inner;
27235         if (ret_var.is_owned) {
27236                 ret_ref |= 1;
27237         }
27238         return ret_ref;
27239 }
27240
27241 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27242         LDKUpdateFulfillHTLC this_obj_conv;
27243         this_obj_conv.inner = (void*)(this_obj & (~1));
27244         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27245         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27246         UpdateFulfillHTLC_free(this_obj_conv);
27247 }
27248
27249 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27250         LDKUpdateFulfillHTLC this_ptr_conv;
27251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27252         this_ptr_conv.is_owned = false;
27253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27254         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27255         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
27256         return ret_arr;
27257 }
27258
27259 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27260         LDKUpdateFulfillHTLC this_ptr_conv;
27261         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27262         this_ptr_conv.is_owned = false;
27263         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27264         LDKThirtyTwoBytes val_ref;
27265         CHECK((*env)->GetArrayLength(env, val) == 32);
27266         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27267         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
27268 }
27269
27270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27271         LDKUpdateFulfillHTLC this_ptr_conv;
27272         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27273         this_ptr_conv.is_owned = false;
27274         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27275         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
27276         return ret_val;
27277 }
27278
27279 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27280         LDKUpdateFulfillHTLC this_ptr_conv;
27281         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27282         this_ptr_conv.is_owned = false;
27283         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27284         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
27285 }
27286
27287 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
27288         LDKUpdateFulfillHTLC this_ptr_conv;
27289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27290         this_ptr_conv.is_owned = false;
27291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27292         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27293         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
27294         return ret_arr;
27295 }
27296
27297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27298         LDKUpdateFulfillHTLC this_ptr_conv;
27299         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27300         this_ptr_conv.is_owned = false;
27301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27302         LDKThirtyTwoBytes val_ref;
27303         CHECK((*env)->GetArrayLength(env, val) == 32);
27304         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27305         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
27306 }
27307
27308 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) {
27309         LDKThirtyTwoBytes channel_id_arg_ref;
27310         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27311         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27312         LDKThirtyTwoBytes payment_preimage_arg_ref;
27313         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
27314         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
27315         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
27316         uint64_t ret_ref = 0;
27317         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27318         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27319         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27320         ret_ref = (uint64_t)ret_var.inner;
27321         if (ret_var.is_owned) {
27322                 ret_ref |= 1;
27323         }
27324         return ret_ref;
27325 }
27326
27327 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
27328         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
27329 uint64_t ret_ref = 0;
27330 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27331 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27332 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27333 ret_ref = (uint64_t)ret_var.inner;
27334 if (ret_var.is_owned) {
27335         ret_ref |= 1;
27336 }
27337         return ret_ref;
27338 }
27339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27340         LDKUpdateFulfillHTLC arg_conv;
27341         arg_conv.inner = (void*)(arg & (~1));
27342         arg_conv.is_owned = false;
27343         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27344         int64_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
27345         return ret_val;
27346 }
27347
27348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27349         LDKUpdateFulfillHTLC orig_conv;
27350         orig_conv.inner = (void*)(orig & (~1));
27351         orig_conv.is_owned = false;
27352         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27353         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
27354         uint64_t ret_ref = 0;
27355         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27356         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27357         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27358         ret_ref = (uint64_t)ret_var.inner;
27359         if (ret_var.is_owned) {
27360                 ret_ref |= 1;
27361         }
27362         return ret_ref;
27363 }
27364
27365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27366         LDKUpdateFailHTLC this_obj_conv;
27367         this_obj_conv.inner = (void*)(this_obj & (~1));
27368         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27370         UpdateFailHTLC_free(this_obj_conv);
27371 }
27372
27373 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27374         LDKUpdateFailHTLC this_ptr_conv;
27375         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27376         this_ptr_conv.is_owned = false;
27377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27378         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27379         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
27380         return ret_arr;
27381 }
27382
27383 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27384         LDKUpdateFailHTLC this_ptr_conv;
27385         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27386         this_ptr_conv.is_owned = false;
27387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27388         LDKThirtyTwoBytes val_ref;
27389         CHECK((*env)->GetArrayLength(env, val) == 32);
27390         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27391         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
27392 }
27393
27394 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27395         LDKUpdateFailHTLC this_ptr_conv;
27396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27397         this_ptr_conv.is_owned = false;
27398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27399         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
27400         return ret_val;
27401 }
27402
27403 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27404         LDKUpdateFailHTLC this_ptr_conv;
27405         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27406         this_ptr_conv.is_owned = false;
27407         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27408         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
27409 }
27410
27411 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
27412         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
27413 uint64_t ret_ref = 0;
27414 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27415 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27416 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27417 ret_ref = (uint64_t)ret_var.inner;
27418 if (ret_var.is_owned) {
27419         ret_ref |= 1;
27420 }
27421         return ret_ref;
27422 }
27423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27424         LDKUpdateFailHTLC arg_conv;
27425         arg_conv.inner = (void*)(arg & (~1));
27426         arg_conv.is_owned = false;
27427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27428         int64_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
27429         return ret_val;
27430 }
27431
27432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27433         LDKUpdateFailHTLC orig_conv;
27434         orig_conv.inner = (void*)(orig & (~1));
27435         orig_conv.is_owned = false;
27436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27437         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
27438         uint64_t ret_ref = 0;
27439         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27440         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27442         ret_ref = (uint64_t)ret_var.inner;
27443         if (ret_var.is_owned) {
27444                 ret_ref |= 1;
27445         }
27446         return ret_ref;
27447 }
27448
27449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27450         LDKUpdateFailMalformedHTLC this_obj_conv;
27451         this_obj_conv.inner = (void*)(this_obj & (~1));
27452         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27454         UpdateFailMalformedHTLC_free(this_obj_conv);
27455 }
27456
27457 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27458         LDKUpdateFailMalformedHTLC this_ptr_conv;
27459         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27460         this_ptr_conv.is_owned = false;
27461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27462         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27463         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
27464         return ret_arr;
27465 }
27466
27467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27468         LDKUpdateFailMalformedHTLC this_ptr_conv;
27469         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27470         this_ptr_conv.is_owned = false;
27471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27472         LDKThirtyTwoBytes val_ref;
27473         CHECK((*env)->GetArrayLength(env, val) == 32);
27474         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27475         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
27476 }
27477
27478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27479         LDKUpdateFailMalformedHTLC this_ptr_conv;
27480         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27481         this_ptr_conv.is_owned = false;
27482         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27483         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
27484         return ret_val;
27485 }
27486
27487 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27488         LDKUpdateFailMalformedHTLC this_ptr_conv;
27489         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27490         this_ptr_conv.is_owned = false;
27491         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27492         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
27493 }
27494
27495 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
27496         LDKUpdateFailMalformedHTLC this_ptr_conv;
27497         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27498         this_ptr_conv.is_owned = false;
27499         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27500         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
27501         return ret_val;
27502 }
27503
27504 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27505         LDKUpdateFailMalformedHTLC this_ptr_conv;
27506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27507         this_ptr_conv.is_owned = false;
27508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27509         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
27510 }
27511
27512 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
27513         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
27514 uint64_t ret_ref = 0;
27515 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27516 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27517 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27518 ret_ref = (uint64_t)ret_var.inner;
27519 if (ret_var.is_owned) {
27520         ret_ref |= 1;
27521 }
27522         return ret_ref;
27523 }
27524 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27525         LDKUpdateFailMalformedHTLC arg_conv;
27526         arg_conv.inner = (void*)(arg & (~1));
27527         arg_conv.is_owned = false;
27528         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27529         int64_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
27530         return ret_val;
27531 }
27532
27533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27534         LDKUpdateFailMalformedHTLC orig_conv;
27535         orig_conv.inner = (void*)(orig & (~1));
27536         orig_conv.is_owned = false;
27537         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27538         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
27539         uint64_t ret_ref = 0;
27540         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27541         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27542         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27543         ret_ref = (uint64_t)ret_var.inner;
27544         if (ret_var.is_owned) {
27545                 ret_ref |= 1;
27546         }
27547         return ret_ref;
27548 }
27549
27550 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27551         LDKCommitmentSigned this_obj_conv;
27552         this_obj_conv.inner = (void*)(this_obj & (~1));
27553         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27554         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27555         CommitmentSigned_free(this_obj_conv);
27556 }
27557
27558 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27559         LDKCommitmentSigned this_ptr_conv;
27560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27561         this_ptr_conv.is_owned = false;
27562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27563         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27564         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
27565         return ret_arr;
27566 }
27567
27568 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27569         LDKCommitmentSigned this_ptr_conv;
27570         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27571         this_ptr_conv.is_owned = false;
27572         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27573         LDKThirtyTwoBytes val_ref;
27574         CHECK((*env)->GetArrayLength(env, val) == 32);
27575         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27576         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
27577 }
27578
27579 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
27580         LDKCommitmentSigned this_ptr_conv;
27581         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27582         this_ptr_conv.is_owned = false;
27583         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27584         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
27585         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
27586         return ret_arr;
27587 }
27588
27589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27590         LDKCommitmentSigned this_ptr_conv;
27591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27592         this_ptr_conv.is_owned = false;
27593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27594         LDKSignature val_ref;
27595         CHECK((*env)->GetArrayLength(env, val) == 64);
27596         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
27597         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
27598 }
27599
27600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
27601         LDKCommitmentSigned this_ptr_conv;
27602         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27603         this_ptr_conv.is_owned = false;
27604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27605         LDKCVec_SignatureZ val_constr;
27606         val_constr.datalen = (*env)->GetArrayLength(env, val);
27607         if (val_constr.datalen > 0)
27608                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
27609         else
27610                 val_constr.data = NULL;
27611         for (size_t i = 0; i < val_constr.datalen; i++) {
27612                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
27613                 LDKSignature val_conv_8_ref;
27614                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
27615                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
27616                 val_constr.data[i] = val_conv_8_ref;
27617         }
27618         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
27619 }
27620
27621 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) {
27622         LDKThirtyTwoBytes channel_id_arg_ref;
27623         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27624         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27625         LDKSignature signature_arg_ref;
27626         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
27627         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
27628         LDKCVec_SignatureZ htlc_signatures_arg_constr;
27629         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
27630         if (htlc_signatures_arg_constr.datalen > 0)
27631                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
27632         else
27633                 htlc_signatures_arg_constr.data = NULL;
27634         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
27635                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
27636                 LDKSignature htlc_signatures_arg_conv_8_ref;
27637                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
27638                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
27639                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
27640         }
27641         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
27642         uint64_t ret_ref = 0;
27643         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27644         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27646         ret_ref = (uint64_t)ret_var.inner;
27647         if (ret_var.is_owned) {
27648                 ret_ref |= 1;
27649         }
27650         return ret_ref;
27651 }
27652
27653 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
27654         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
27655 uint64_t ret_ref = 0;
27656 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27657 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27658 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27659 ret_ref = (uint64_t)ret_var.inner;
27660 if (ret_var.is_owned) {
27661         ret_ref |= 1;
27662 }
27663         return ret_ref;
27664 }
27665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27666         LDKCommitmentSigned arg_conv;
27667         arg_conv.inner = (void*)(arg & (~1));
27668         arg_conv.is_owned = false;
27669         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27670         int64_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
27671         return ret_val;
27672 }
27673
27674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27675         LDKCommitmentSigned orig_conv;
27676         orig_conv.inner = (void*)(orig & (~1));
27677         orig_conv.is_owned = false;
27678         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27679         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
27680         uint64_t ret_ref = 0;
27681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27684         ret_ref = (uint64_t)ret_var.inner;
27685         if (ret_var.is_owned) {
27686                 ret_ref |= 1;
27687         }
27688         return ret_ref;
27689 }
27690
27691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27692         LDKRevokeAndACK this_obj_conv;
27693         this_obj_conv.inner = (void*)(this_obj & (~1));
27694         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27696         RevokeAndACK_free(this_obj_conv);
27697 }
27698
27699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27700         LDKRevokeAndACK this_ptr_conv;
27701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27702         this_ptr_conv.is_owned = false;
27703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27704         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27705         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
27706         return ret_arr;
27707 }
27708
27709 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27710         LDKRevokeAndACK this_ptr_conv;
27711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27712         this_ptr_conv.is_owned = false;
27713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27714         LDKThirtyTwoBytes val_ref;
27715         CHECK((*env)->GetArrayLength(env, val) == 32);
27716         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27717         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
27718 }
27719
27720 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
27721         LDKRevokeAndACK this_ptr_conv;
27722         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27723         this_ptr_conv.is_owned = false;
27724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27725         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27726         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
27727         return ret_arr;
27728 }
27729
27730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27731         LDKRevokeAndACK this_ptr_conv;
27732         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27733         this_ptr_conv.is_owned = false;
27734         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27735         LDKThirtyTwoBytes val_ref;
27736         CHECK((*env)->GetArrayLength(env, val) == 32);
27737         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27738         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
27739 }
27740
27741 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27742         LDKRevokeAndACK this_ptr_conv;
27743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27744         this_ptr_conv.is_owned = false;
27745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27746         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27747         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
27748         return ret_arr;
27749 }
27750
27751 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) {
27752         LDKRevokeAndACK this_ptr_conv;
27753         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27754         this_ptr_conv.is_owned = false;
27755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27756         LDKPublicKey val_ref;
27757         CHECK((*env)->GetArrayLength(env, val) == 33);
27758         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27759         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27760 }
27761
27762 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) {
27763         LDKThirtyTwoBytes channel_id_arg_ref;
27764         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27765         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27766         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
27767         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
27768         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
27769         LDKPublicKey next_per_commitment_point_arg_ref;
27770         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
27771         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
27772         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
27773         uint64_t ret_ref = 0;
27774         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27775         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27777         ret_ref = (uint64_t)ret_var.inner;
27778         if (ret_var.is_owned) {
27779                 ret_ref |= 1;
27780         }
27781         return ret_ref;
27782 }
27783
27784 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
27785         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
27786 uint64_t ret_ref = 0;
27787 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27788 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27789 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27790 ret_ref = (uint64_t)ret_var.inner;
27791 if (ret_var.is_owned) {
27792         ret_ref |= 1;
27793 }
27794         return ret_ref;
27795 }
27796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27797         LDKRevokeAndACK arg_conv;
27798         arg_conv.inner = (void*)(arg & (~1));
27799         arg_conv.is_owned = false;
27800         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27801         int64_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
27802         return ret_val;
27803 }
27804
27805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27806         LDKRevokeAndACK orig_conv;
27807         orig_conv.inner = (void*)(orig & (~1));
27808         orig_conv.is_owned = false;
27809         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27810         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
27811         uint64_t ret_ref = 0;
27812         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27813         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27815         ret_ref = (uint64_t)ret_var.inner;
27816         if (ret_var.is_owned) {
27817                 ret_ref |= 1;
27818         }
27819         return ret_ref;
27820 }
27821
27822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27823         LDKUpdateFee this_obj_conv;
27824         this_obj_conv.inner = (void*)(this_obj & (~1));
27825         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27826         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27827         UpdateFee_free(this_obj_conv);
27828 }
27829
27830 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27831         LDKUpdateFee this_ptr_conv;
27832         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27833         this_ptr_conv.is_owned = false;
27834         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27835         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27836         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
27837         return ret_arr;
27838 }
27839
27840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27841         LDKUpdateFee this_ptr_conv;
27842         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27843         this_ptr_conv.is_owned = false;
27844         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27845         LDKThirtyTwoBytes val_ref;
27846         CHECK((*env)->GetArrayLength(env, val) == 32);
27847         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27848         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
27849 }
27850
27851 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
27852         LDKUpdateFee this_ptr_conv;
27853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27854         this_ptr_conv.is_owned = false;
27855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27856         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
27857         return ret_val;
27858 }
27859
27860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27861         LDKUpdateFee this_ptr_conv;
27862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27863         this_ptr_conv.is_owned = false;
27864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27865         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
27866 }
27867
27868 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) {
27869         LDKThirtyTwoBytes channel_id_arg_ref;
27870         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27871         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27872         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
27873         uint64_t ret_ref = 0;
27874         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27875         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27877         ret_ref = (uint64_t)ret_var.inner;
27878         if (ret_var.is_owned) {
27879                 ret_ref |= 1;
27880         }
27881         return ret_ref;
27882 }
27883
27884 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
27885         LDKUpdateFee ret_var = UpdateFee_clone(arg);
27886 uint64_t ret_ref = 0;
27887 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27888 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27889 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27890 ret_ref = (uint64_t)ret_var.inner;
27891 if (ret_var.is_owned) {
27892         ret_ref |= 1;
27893 }
27894         return ret_ref;
27895 }
27896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27897         LDKUpdateFee arg_conv;
27898         arg_conv.inner = (void*)(arg & (~1));
27899         arg_conv.is_owned = false;
27900         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27901         int64_t ret_val = UpdateFee_clone_ptr(&arg_conv);
27902         return ret_val;
27903 }
27904
27905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27906         LDKUpdateFee orig_conv;
27907         orig_conv.inner = (void*)(orig & (~1));
27908         orig_conv.is_owned = false;
27909         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27910         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
27911         uint64_t ret_ref = 0;
27912         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27913         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27915         ret_ref = (uint64_t)ret_var.inner;
27916         if (ret_var.is_owned) {
27917                 ret_ref |= 1;
27918         }
27919         return ret_ref;
27920 }
27921
27922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27923         LDKDataLossProtect this_obj_conv;
27924         this_obj_conv.inner = (void*)(this_obj & (~1));
27925         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27927         DataLossProtect_free(this_obj_conv);
27928 }
27929
27930 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
27931         LDKDataLossProtect this_ptr_conv;
27932         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27933         this_ptr_conv.is_owned = false;
27934         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27935         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27936         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
27937         return ret_arr;
27938 }
27939
27940 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) {
27941         LDKDataLossProtect this_ptr_conv;
27942         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27943         this_ptr_conv.is_owned = false;
27944         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27945         LDKThirtyTwoBytes val_ref;
27946         CHECK((*env)->GetArrayLength(env, val) == 32);
27947         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27948         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
27949 }
27950
27951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27952         LDKDataLossProtect this_ptr_conv;
27953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27954         this_ptr_conv.is_owned = false;
27955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27956         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
27958         return ret_arr;
27959 }
27960
27961 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) {
27962         LDKDataLossProtect this_ptr_conv;
27963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27964         this_ptr_conv.is_owned = false;
27965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27966         LDKPublicKey val_ref;
27967         CHECK((*env)->GetArrayLength(env, val) == 33);
27968         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27969         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
27970 }
27971
27972 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) {
27973         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
27974         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
27975         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
27976         LDKPublicKey my_current_per_commitment_point_arg_ref;
27977         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
27978         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
27979         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
27980         uint64_t ret_ref = 0;
27981         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27982         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27983         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27984         ret_ref = (uint64_t)ret_var.inner;
27985         if (ret_var.is_owned) {
27986                 ret_ref |= 1;
27987         }
27988         return ret_ref;
27989 }
27990
27991 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
27992         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
27993 uint64_t ret_ref = 0;
27994 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27995 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27996 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27997 ret_ref = (uint64_t)ret_var.inner;
27998 if (ret_var.is_owned) {
27999         ret_ref |= 1;
28000 }
28001         return ret_ref;
28002 }
28003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28004         LDKDataLossProtect arg_conv;
28005         arg_conv.inner = (void*)(arg & (~1));
28006         arg_conv.is_owned = false;
28007         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28008         int64_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
28009         return ret_val;
28010 }
28011
28012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28013         LDKDataLossProtect orig_conv;
28014         orig_conv.inner = (void*)(orig & (~1));
28015         orig_conv.is_owned = false;
28016         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28017         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
28018         uint64_t ret_ref = 0;
28019         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28020         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28021         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28022         ret_ref = (uint64_t)ret_var.inner;
28023         if (ret_var.is_owned) {
28024                 ret_ref |= 1;
28025         }
28026         return ret_ref;
28027 }
28028
28029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28030         LDKChannelReestablish this_obj_conv;
28031         this_obj_conv.inner = (void*)(this_obj & (~1));
28032         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28034         ChannelReestablish_free(this_obj_conv);
28035 }
28036
28037 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28038         LDKChannelReestablish this_ptr_conv;
28039         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28040         this_ptr_conv.is_owned = false;
28041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28042         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28043         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
28044         return ret_arr;
28045 }
28046
28047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28048         LDKChannelReestablish this_ptr_conv;
28049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28050         this_ptr_conv.is_owned = false;
28051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28052         LDKThirtyTwoBytes val_ref;
28053         CHECK((*env)->GetArrayLength(env, val) == 32);
28054         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28055         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
28056 }
28057
28058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
28059         LDKChannelReestablish this_ptr_conv;
28060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28061         this_ptr_conv.is_owned = false;
28062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28063         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
28064         return ret_val;
28065 }
28066
28067 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) {
28068         LDKChannelReestablish this_ptr_conv;
28069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28070         this_ptr_conv.is_owned = false;
28071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28072         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
28073 }
28074
28075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
28076         LDKChannelReestablish this_ptr_conv;
28077         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28078         this_ptr_conv.is_owned = false;
28079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28080         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
28081         return ret_val;
28082 }
28083
28084 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) {
28085         LDKChannelReestablish this_ptr_conv;
28086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28087         this_ptr_conv.is_owned = false;
28088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28089         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
28090 }
28091
28092 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
28093         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
28094 uint64_t ret_ref = 0;
28095 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28096 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28097 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28098 ret_ref = (uint64_t)ret_var.inner;
28099 if (ret_var.is_owned) {
28100         ret_ref |= 1;
28101 }
28102         return ret_ref;
28103 }
28104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28105         LDKChannelReestablish arg_conv;
28106         arg_conv.inner = (void*)(arg & (~1));
28107         arg_conv.is_owned = false;
28108         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28109         int64_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
28110         return ret_val;
28111 }
28112
28113 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28114         LDKChannelReestablish orig_conv;
28115         orig_conv.inner = (void*)(orig & (~1));
28116         orig_conv.is_owned = false;
28117         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28118         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
28119         uint64_t ret_ref = 0;
28120         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28121         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28122         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28123         ret_ref = (uint64_t)ret_var.inner;
28124         if (ret_var.is_owned) {
28125                 ret_ref |= 1;
28126         }
28127         return ret_ref;
28128 }
28129
28130 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28131         LDKAnnouncementSignatures this_obj_conv;
28132         this_obj_conv.inner = (void*)(this_obj & (~1));
28133         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28135         AnnouncementSignatures_free(this_obj_conv);
28136 }
28137
28138 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28139         LDKAnnouncementSignatures this_ptr_conv;
28140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28141         this_ptr_conv.is_owned = false;
28142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28143         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28144         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
28145         return ret_arr;
28146 }
28147
28148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28149         LDKAnnouncementSignatures this_ptr_conv;
28150         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28151         this_ptr_conv.is_owned = false;
28152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28153         LDKThirtyTwoBytes val_ref;
28154         CHECK((*env)->GetArrayLength(env, val) == 32);
28155         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28156         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
28157 }
28158
28159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28160         LDKAnnouncementSignatures this_ptr_conv;
28161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28162         this_ptr_conv.is_owned = false;
28163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28164         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
28165         return ret_val;
28166 }
28167
28168 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28169         LDKAnnouncementSignatures this_ptr_conv;
28170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28171         this_ptr_conv.is_owned = false;
28172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28173         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
28174 }
28175
28176 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28177         LDKAnnouncementSignatures this_ptr_conv;
28178         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28179         this_ptr_conv.is_owned = false;
28180         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28181         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28182         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
28183         return ret_arr;
28184 }
28185
28186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28187         LDKAnnouncementSignatures this_ptr_conv;
28188         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28189         this_ptr_conv.is_owned = false;
28190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28191         LDKSignature val_ref;
28192         CHECK((*env)->GetArrayLength(env, val) == 64);
28193         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28194         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
28195 }
28196
28197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28198         LDKAnnouncementSignatures this_ptr_conv;
28199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28200         this_ptr_conv.is_owned = false;
28201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28202         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28203         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
28204         return ret_arr;
28205 }
28206
28207 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28208         LDKAnnouncementSignatures this_ptr_conv;
28209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28210         this_ptr_conv.is_owned = false;
28211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28212         LDKSignature val_ref;
28213         CHECK((*env)->GetArrayLength(env, val) == 64);
28214         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28215         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
28216 }
28217
28218 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) {
28219         LDKThirtyTwoBytes channel_id_arg_ref;
28220         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28221         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28222         LDKSignature node_signature_arg_ref;
28223         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
28224         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
28225         LDKSignature bitcoin_signature_arg_ref;
28226         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
28227         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
28228         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
28229         uint64_t ret_ref = 0;
28230         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28231         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28233         ret_ref = (uint64_t)ret_var.inner;
28234         if (ret_var.is_owned) {
28235                 ret_ref |= 1;
28236         }
28237         return ret_ref;
28238 }
28239
28240 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
28241         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
28242 uint64_t ret_ref = 0;
28243 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28244 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28245 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28246 ret_ref = (uint64_t)ret_var.inner;
28247 if (ret_var.is_owned) {
28248         ret_ref |= 1;
28249 }
28250         return ret_ref;
28251 }
28252 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28253         LDKAnnouncementSignatures arg_conv;
28254         arg_conv.inner = (void*)(arg & (~1));
28255         arg_conv.is_owned = false;
28256         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28257         int64_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
28258         return ret_val;
28259 }
28260
28261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28262         LDKAnnouncementSignatures orig_conv;
28263         orig_conv.inner = (void*)(orig & (~1));
28264         orig_conv.is_owned = false;
28265         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28266         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
28267         uint64_t ret_ref = 0;
28268         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28269         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28270         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28271         ret_ref = (uint64_t)ret_var.inner;
28272         if (ret_var.is_owned) {
28273                 ret_ref |= 1;
28274         }
28275         return ret_ref;
28276 }
28277
28278 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28279         if ((this_ptr & 1) != 0) return;
28280         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28281         CHECK_ACCESS(this_ptr_ptr);
28282         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
28283         FREE((void*)this_ptr);
28284         NetAddress_free(this_ptr_conv);
28285 }
28286
28287 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
28288         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28289         *ret_copy = NetAddress_clone(arg);
28290 uint64_t ret_ref = (uint64_t)ret_copy;
28291         return ret_ref;
28292 }
28293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28294         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
28295         int64_t ret_val = NetAddress_clone_ptr(arg_conv);
28296         return ret_val;
28297 }
28298
28299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28300         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
28301         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28302         *ret_copy = NetAddress_clone(orig_conv);
28303         uint64_t ret_ref = (uint64_t)ret_copy;
28304         return ret_ref;
28305 }
28306
28307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
28308         LDKFourBytes addr_ref;
28309         CHECK((*env)->GetArrayLength(env, addr) == 4);
28310         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
28311         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28312         *ret_copy = NetAddress_ipv4(addr_ref, port);
28313         uint64_t ret_ref = (uint64_t)ret_copy;
28314         return ret_ref;
28315 }
28316
28317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
28318         LDKSixteenBytes addr_ref;
28319         CHECK((*env)->GetArrayLength(env, addr) == 16);
28320         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
28321         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28322         *ret_copy = NetAddress_ipv6(addr_ref, port);
28323         uint64_t ret_ref = (uint64_t)ret_copy;
28324         return ret_ref;
28325 }
28326
28327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
28328         LDKTenBytes addr_ref;
28329         CHECK((*env)->GetArrayLength(env, addr) == 10);
28330         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
28331         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28332         *ret_copy = NetAddress_onion_v2(addr_ref, port);
28333         uint64_t ret_ref = (uint64_t)ret_copy;
28334         return ret_ref;
28335 }
28336
28337 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) {
28338         LDKThirtyTwoBytes ed25519_pubkey_ref;
28339         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
28340         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
28341         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28342         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
28343         uint64_t ret_ref = (uint64_t)ret_copy;
28344         return ret_ref;
28345 }
28346
28347 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
28348         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
28349         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
28350         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28351         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28352         CVec_u8Z_free(ret_var);
28353         return ret_arr;
28354 }
28355
28356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28357         LDKu8slice ser_ref;
28358         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28359         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28360         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
28361         *ret_conv = NetAddress_read(ser_ref);
28362         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28363         return (uint64_t)ret_conv;
28364 }
28365
28366 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28367         LDKUnsignedNodeAnnouncement this_obj_conv;
28368         this_obj_conv.inner = (void*)(this_obj & (~1));
28369         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28371         UnsignedNodeAnnouncement_free(this_obj_conv);
28372 }
28373
28374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28375         LDKUnsignedNodeAnnouncement this_ptr_conv;
28376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28377         this_ptr_conv.is_owned = false;
28378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28379         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
28380         uint64_t ret_ref = 0;
28381         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28382         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28383         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28384         ret_ref = (uint64_t)ret_var.inner;
28385         if (ret_var.is_owned) {
28386                 ret_ref |= 1;
28387         }
28388         return ret_ref;
28389 }
28390
28391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28392         LDKUnsignedNodeAnnouncement this_ptr_conv;
28393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28394         this_ptr_conv.is_owned = false;
28395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28396         LDKNodeFeatures val_conv;
28397         val_conv.inner = (void*)(val & (~1));
28398         val_conv.is_owned = (val & 1) || (val == 0);
28399         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28400         val_conv = NodeFeatures_clone(&val_conv);
28401         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
28402 }
28403
28404 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
28405         LDKUnsignedNodeAnnouncement this_ptr_conv;
28406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28407         this_ptr_conv.is_owned = false;
28408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28409         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
28410         return ret_val;
28411 }
28412
28413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28414         LDKUnsignedNodeAnnouncement this_ptr_conv;
28415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28416         this_ptr_conv.is_owned = false;
28417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28418         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
28419 }
28420
28421 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28422         LDKUnsignedNodeAnnouncement this_ptr_conv;
28423         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28424         this_ptr_conv.is_owned = false;
28425         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28426         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28427         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
28428         return ret_arr;
28429 }
28430
28431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28432         LDKUnsignedNodeAnnouncement this_ptr_conv;
28433         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28434         this_ptr_conv.is_owned = false;
28435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28436         LDKPublicKey val_ref;
28437         CHECK((*env)->GetArrayLength(env, val) == 33);
28438         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28439         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
28440 }
28441
28442 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
28443         LDKUnsignedNodeAnnouncement this_ptr_conv;
28444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28445         this_ptr_conv.is_owned = false;
28446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28447         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
28448         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
28449         return ret_arr;
28450 }
28451
28452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28453         LDKUnsignedNodeAnnouncement this_ptr_conv;
28454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28455         this_ptr_conv.is_owned = false;
28456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28457         LDKThreeBytes val_ref;
28458         CHECK((*env)->GetArrayLength(env, val) == 3);
28459         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
28460         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
28461 }
28462
28463 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28464         LDKUnsignedNodeAnnouncement this_ptr_conv;
28465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28466         this_ptr_conv.is_owned = false;
28467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28468         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28469         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
28470         return ret_arr;
28471 }
28472
28473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28474         LDKUnsignedNodeAnnouncement this_ptr_conv;
28475         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28476         this_ptr_conv.is_owned = false;
28477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28478         LDKThirtyTwoBytes val_ref;
28479         CHECK((*env)->GetArrayLength(env, val) == 32);
28480         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28481         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
28482 }
28483
28484 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28485         LDKUnsignedNodeAnnouncement this_ptr_conv;
28486         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28487         this_ptr_conv.is_owned = false;
28488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28489         LDKCVec_NetAddressZ val_constr;
28490         val_constr.datalen = (*env)->GetArrayLength(env, val);
28491         if (val_constr.datalen > 0)
28492                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28493         else
28494                 val_constr.data = NULL;
28495         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28496         for (size_t m = 0; m < val_constr.datalen; m++) {
28497                 int64_t val_conv_12 = val_vals[m];
28498                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
28499                 CHECK_ACCESS(val_conv_12_ptr);
28500                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
28501                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
28502                 val_constr.data[m] = val_conv_12_conv;
28503         }
28504         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28505         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
28506 }
28507
28508 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
28509         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
28510 uint64_t ret_ref = 0;
28511 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28512 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28513 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28514 ret_ref = (uint64_t)ret_var.inner;
28515 if (ret_var.is_owned) {
28516         ret_ref |= 1;
28517 }
28518         return ret_ref;
28519 }
28520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28521         LDKUnsignedNodeAnnouncement arg_conv;
28522         arg_conv.inner = (void*)(arg & (~1));
28523         arg_conv.is_owned = false;
28524         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28525         int64_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
28526         return ret_val;
28527 }
28528
28529 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28530         LDKUnsignedNodeAnnouncement orig_conv;
28531         orig_conv.inner = (void*)(orig & (~1));
28532         orig_conv.is_owned = false;
28533         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28534         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
28535         uint64_t ret_ref = 0;
28536         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28537         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28538         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28539         ret_ref = (uint64_t)ret_var.inner;
28540         if (ret_var.is_owned) {
28541                 ret_ref |= 1;
28542         }
28543         return ret_ref;
28544 }
28545
28546 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28547         LDKNodeAnnouncement this_obj_conv;
28548         this_obj_conv.inner = (void*)(this_obj & (~1));
28549         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28551         NodeAnnouncement_free(this_obj_conv);
28552 }
28553
28554 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28555         LDKNodeAnnouncement this_ptr_conv;
28556         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28557         this_ptr_conv.is_owned = false;
28558         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28559         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28560         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
28561         return ret_arr;
28562 }
28563
28564 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28565         LDKNodeAnnouncement this_ptr_conv;
28566         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28567         this_ptr_conv.is_owned = false;
28568         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28569         LDKSignature val_ref;
28570         CHECK((*env)->GetArrayLength(env, val) == 64);
28571         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28572         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
28573 }
28574
28575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
28576         LDKNodeAnnouncement this_ptr_conv;
28577         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28578         this_ptr_conv.is_owned = false;
28579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28580         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
28581         uint64_t ret_ref = 0;
28582         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28583         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28584         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28585         ret_ref = (uint64_t)ret_var.inner;
28586         if (ret_var.is_owned) {
28587                 ret_ref |= 1;
28588         }
28589         return ret_ref;
28590 }
28591
28592 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28593         LDKNodeAnnouncement this_ptr_conv;
28594         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28595         this_ptr_conv.is_owned = false;
28596         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28597         LDKUnsignedNodeAnnouncement val_conv;
28598         val_conv.inner = (void*)(val & (~1));
28599         val_conv.is_owned = (val & 1) || (val == 0);
28600         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28601         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
28602         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
28603 }
28604
28605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
28606         LDKSignature signature_arg_ref;
28607         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
28608         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
28609         LDKUnsignedNodeAnnouncement contents_arg_conv;
28610         contents_arg_conv.inner = (void*)(contents_arg & (~1));
28611         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
28612         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
28613         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
28614         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
28615         uint64_t ret_ref = 0;
28616         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28617         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28618         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28619         ret_ref = (uint64_t)ret_var.inner;
28620         if (ret_var.is_owned) {
28621                 ret_ref |= 1;
28622         }
28623         return ret_ref;
28624 }
28625
28626 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
28627         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
28628 uint64_t ret_ref = 0;
28629 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28630 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28631 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28632 ret_ref = (uint64_t)ret_var.inner;
28633 if (ret_var.is_owned) {
28634         ret_ref |= 1;
28635 }
28636         return ret_ref;
28637 }
28638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28639         LDKNodeAnnouncement arg_conv;
28640         arg_conv.inner = (void*)(arg & (~1));
28641         arg_conv.is_owned = false;
28642         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28643         int64_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
28644         return ret_val;
28645 }
28646
28647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28648         LDKNodeAnnouncement orig_conv;
28649         orig_conv.inner = (void*)(orig & (~1));
28650         orig_conv.is_owned = false;
28651         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28652         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
28653         uint64_t ret_ref = 0;
28654         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28655         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28656         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28657         ret_ref = (uint64_t)ret_var.inner;
28658         if (ret_var.is_owned) {
28659                 ret_ref |= 1;
28660         }
28661         return ret_ref;
28662 }
28663
28664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28665         LDKUnsignedChannelAnnouncement this_obj_conv;
28666         this_obj_conv.inner = (void*)(this_obj & (~1));
28667         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28669         UnsignedChannelAnnouncement_free(this_obj_conv);
28670 }
28671
28672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28673         LDKUnsignedChannelAnnouncement this_ptr_conv;
28674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28675         this_ptr_conv.is_owned = false;
28676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28677         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
28678         uint64_t ret_ref = 0;
28679         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28680         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28681         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28682         ret_ref = (uint64_t)ret_var.inner;
28683         if (ret_var.is_owned) {
28684                 ret_ref |= 1;
28685         }
28686         return ret_ref;
28687 }
28688
28689 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28690         LDKUnsignedChannelAnnouncement this_ptr_conv;
28691         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28692         this_ptr_conv.is_owned = false;
28693         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28694         LDKChannelFeatures val_conv;
28695         val_conv.inner = (void*)(val & (~1));
28696         val_conv.is_owned = (val & 1) || (val == 0);
28697         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28698         val_conv = ChannelFeatures_clone(&val_conv);
28699         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
28700 }
28701
28702 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28703         LDKUnsignedChannelAnnouncement this_ptr_conv;
28704         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28705         this_ptr_conv.is_owned = false;
28706         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28707         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28708         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
28709         return ret_arr;
28710 }
28711
28712 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28713         LDKUnsignedChannelAnnouncement this_ptr_conv;
28714         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28715         this_ptr_conv.is_owned = false;
28716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28717         LDKThirtyTwoBytes val_ref;
28718         CHECK((*env)->GetArrayLength(env, val) == 32);
28719         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28720         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
28721 }
28722
28723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28724         LDKUnsignedChannelAnnouncement this_ptr_conv;
28725         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28726         this_ptr_conv.is_owned = false;
28727         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28728         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
28729         return ret_val;
28730 }
28731
28732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28733         LDKUnsignedChannelAnnouncement this_ptr_conv;
28734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28735         this_ptr_conv.is_owned = false;
28736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28737         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
28738 }
28739
28740 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
28741         LDKUnsignedChannelAnnouncement this_ptr_conv;
28742         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28743         this_ptr_conv.is_owned = false;
28744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28745         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28746         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
28747         return ret_arr;
28748 }
28749
28750 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28751         LDKUnsignedChannelAnnouncement this_ptr_conv;
28752         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28753         this_ptr_conv.is_owned = false;
28754         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28755         LDKPublicKey val_ref;
28756         CHECK((*env)->GetArrayLength(env, val) == 33);
28757         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28758         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
28759 }
28760
28761 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
28762         LDKUnsignedChannelAnnouncement this_ptr_conv;
28763         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28764         this_ptr_conv.is_owned = false;
28765         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28766         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28767         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
28768         return ret_arr;
28769 }
28770
28771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28772         LDKUnsignedChannelAnnouncement this_ptr_conv;
28773         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28774         this_ptr_conv.is_owned = false;
28775         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28776         LDKPublicKey val_ref;
28777         CHECK((*env)->GetArrayLength(env, val) == 33);
28778         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28779         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
28780 }
28781
28782 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
28783         LDKUnsignedChannelAnnouncement this_ptr_conv;
28784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28785         this_ptr_conv.is_owned = false;
28786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28787         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28788         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
28789         return ret_arr;
28790 }
28791
28792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28793         LDKUnsignedChannelAnnouncement this_ptr_conv;
28794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28795         this_ptr_conv.is_owned = false;
28796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28797         LDKPublicKey val_ref;
28798         CHECK((*env)->GetArrayLength(env, val) == 33);
28799         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28800         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
28801 }
28802
28803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
28804         LDKUnsignedChannelAnnouncement this_ptr_conv;
28805         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28806         this_ptr_conv.is_owned = false;
28807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28808         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28809         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
28810         return ret_arr;
28811 }
28812
28813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28814         LDKUnsignedChannelAnnouncement this_ptr_conv;
28815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28816         this_ptr_conv.is_owned = false;
28817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28818         LDKPublicKey val_ref;
28819         CHECK((*env)->GetArrayLength(env, val) == 33);
28820         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28821         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
28822 }
28823
28824 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
28825         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
28826 uint64_t ret_ref = 0;
28827 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28828 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28829 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28830 ret_ref = (uint64_t)ret_var.inner;
28831 if (ret_var.is_owned) {
28832         ret_ref |= 1;
28833 }
28834         return ret_ref;
28835 }
28836 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28837         LDKUnsignedChannelAnnouncement arg_conv;
28838         arg_conv.inner = (void*)(arg & (~1));
28839         arg_conv.is_owned = false;
28840         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28841         int64_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
28842         return ret_val;
28843 }
28844
28845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28846         LDKUnsignedChannelAnnouncement orig_conv;
28847         orig_conv.inner = (void*)(orig & (~1));
28848         orig_conv.is_owned = false;
28849         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28850         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
28851         uint64_t ret_ref = 0;
28852         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28853         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28854         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28855         ret_ref = (uint64_t)ret_var.inner;
28856         if (ret_var.is_owned) {
28857                 ret_ref |= 1;
28858         }
28859         return ret_ref;
28860 }
28861
28862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28863         LDKChannelAnnouncement this_obj_conv;
28864         this_obj_conv.inner = (void*)(this_obj & (~1));
28865         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28867         ChannelAnnouncement_free(this_obj_conv);
28868 }
28869
28870 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
28871         LDKChannelAnnouncement this_ptr_conv;
28872         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28873         this_ptr_conv.is_owned = false;
28874         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28875         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28876         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
28877         return ret_arr;
28878 }
28879
28880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28881         LDKChannelAnnouncement this_ptr_conv;
28882         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28883         this_ptr_conv.is_owned = false;
28884         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28885         LDKSignature val_ref;
28886         CHECK((*env)->GetArrayLength(env, val) == 64);
28887         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28888         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
28889 }
28890
28891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
28892         LDKChannelAnnouncement this_ptr_conv;
28893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28894         this_ptr_conv.is_owned = false;
28895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28896         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28897         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
28898         return ret_arr;
28899 }
28900
28901 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28902         LDKChannelAnnouncement this_ptr_conv;
28903         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28904         this_ptr_conv.is_owned = false;
28905         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28906         LDKSignature val_ref;
28907         CHECK((*env)->GetArrayLength(env, val) == 64);
28908         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28909         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
28910 }
28911
28912 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
28913         LDKChannelAnnouncement this_ptr_conv;
28914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28915         this_ptr_conv.is_owned = false;
28916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28917         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28918         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
28919         return ret_arr;
28920 }
28921
28922 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28923         LDKChannelAnnouncement this_ptr_conv;
28924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28925         this_ptr_conv.is_owned = false;
28926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28927         LDKSignature val_ref;
28928         CHECK((*env)->GetArrayLength(env, val) == 64);
28929         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28930         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
28931 }
28932
28933 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
28934         LDKChannelAnnouncement this_ptr_conv;
28935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28936         this_ptr_conv.is_owned = false;
28937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28938         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28939         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
28940         return ret_arr;
28941 }
28942
28943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28944         LDKChannelAnnouncement this_ptr_conv;
28945         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28946         this_ptr_conv.is_owned = false;
28947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28948         LDKSignature val_ref;
28949         CHECK((*env)->GetArrayLength(env, val) == 64);
28950         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28951         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
28952 }
28953
28954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
28955         LDKChannelAnnouncement this_ptr_conv;
28956         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28957         this_ptr_conv.is_owned = false;
28958         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28959         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
28960         uint64_t ret_ref = 0;
28961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28964         ret_ref = (uint64_t)ret_var.inner;
28965         if (ret_var.is_owned) {
28966                 ret_ref |= 1;
28967         }
28968         return ret_ref;
28969 }
28970
28971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28972         LDKChannelAnnouncement this_ptr_conv;
28973         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28974         this_ptr_conv.is_owned = false;
28975         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28976         LDKUnsignedChannelAnnouncement val_conv;
28977         val_conv.inner = (void*)(val & (~1));
28978         val_conv.is_owned = (val & 1) || (val == 0);
28979         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28980         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
28981         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
28982 }
28983
28984 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) {
28985         LDKSignature node_signature_1_arg_ref;
28986         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
28987         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
28988         LDKSignature node_signature_2_arg_ref;
28989         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
28990         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
28991         LDKSignature bitcoin_signature_1_arg_ref;
28992         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
28993         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
28994         LDKSignature bitcoin_signature_2_arg_ref;
28995         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
28996         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
28997         LDKUnsignedChannelAnnouncement contents_arg_conv;
28998         contents_arg_conv.inner = (void*)(contents_arg & (~1));
28999         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29000         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29001         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
29002         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);
29003         uint64_t ret_ref = 0;
29004         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29005         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29006         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29007         ret_ref = (uint64_t)ret_var.inner;
29008         if (ret_var.is_owned) {
29009                 ret_ref |= 1;
29010         }
29011         return ret_ref;
29012 }
29013
29014 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
29015         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
29016 uint64_t ret_ref = 0;
29017 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29018 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29019 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29020 ret_ref = (uint64_t)ret_var.inner;
29021 if (ret_var.is_owned) {
29022         ret_ref |= 1;
29023 }
29024         return ret_ref;
29025 }
29026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29027         LDKChannelAnnouncement arg_conv;
29028         arg_conv.inner = (void*)(arg & (~1));
29029         arg_conv.is_owned = false;
29030         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29031         int64_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
29032         return ret_val;
29033 }
29034
29035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29036         LDKChannelAnnouncement orig_conv;
29037         orig_conv.inner = (void*)(orig & (~1));
29038         orig_conv.is_owned = false;
29039         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29040         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
29041         uint64_t ret_ref = 0;
29042         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29043         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29044         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29045         ret_ref = (uint64_t)ret_var.inner;
29046         if (ret_var.is_owned) {
29047                 ret_ref |= 1;
29048         }
29049         return ret_ref;
29050 }
29051
29052 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29053         LDKUnsignedChannelUpdate this_obj_conv;
29054         this_obj_conv.inner = (void*)(this_obj & (~1));
29055         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29056         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29057         UnsignedChannelUpdate_free(this_obj_conv);
29058 }
29059
29060 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29061         LDKUnsignedChannelUpdate this_ptr_conv;
29062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29063         this_ptr_conv.is_owned = false;
29064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29065         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29066         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
29067         return ret_arr;
29068 }
29069
29070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29071         LDKUnsignedChannelUpdate this_ptr_conv;
29072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29073         this_ptr_conv.is_owned = false;
29074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29075         LDKThirtyTwoBytes val_ref;
29076         CHECK((*env)->GetArrayLength(env, val) == 32);
29077         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29078         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
29079 }
29080
29081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29082         LDKUnsignedChannelUpdate this_ptr_conv;
29083         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29084         this_ptr_conv.is_owned = false;
29085         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29086         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
29087         return ret_val;
29088 }
29089
29090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29091         LDKUnsignedChannelUpdate this_ptr_conv;
29092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29093         this_ptr_conv.is_owned = false;
29094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29095         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
29096 }
29097
29098 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
29099         LDKUnsignedChannelUpdate this_ptr_conv;
29100         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29101         this_ptr_conv.is_owned = false;
29102         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29103         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
29104         return ret_val;
29105 }
29106
29107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29108         LDKUnsignedChannelUpdate this_ptr_conv;
29109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29110         this_ptr_conv.is_owned = false;
29111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29112         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
29113 }
29114
29115 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
29116         LDKUnsignedChannelUpdate this_ptr_conv;
29117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29118         this_ptr_conv.is_owned = false;
29119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29120         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
29121         return ret_val;
29122 }
29123
29124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
29125         LDKUnsignedChannelUpdate this_ptr_conv;
29126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29127         this_ptr_conv.is_owned = false;
29128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29129         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
29130 }
29131
29132 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29133         LDKUnsignedChannelUpdate this_ptr_conv;
29134         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29135         this_ptr_conv.is_owned = false;
29136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29137         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
29138         return ret_val;
29139 }
29140
29141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29142         LDKUnsignedChannelUpdate this_ptr_conv;
29143         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29144         this_ptr_conv.is_owned = false;
29145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29146         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
29147 }
29148
29149 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29150         LDKUnsignedChannelUpdate this_ptr_conv;
29151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29152         this_ptr_conv.is_owned = false;
29153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29154         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
29155         return ret_val;
29156 }
29157
29158 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29159         LDKUnsignedChannelUpdate this_ptr_conv;
29160         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29161         this_ptr_conv.is_owned = false;
29162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29163         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
29164 }
29165
29166 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29167         LDKUnsignedChannelUpdate this_ptr_conv;
29168         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29169         this_ptr_conv.is_owned = false;
29170         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29171         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
29172         return ret_val;
29173 }
29174
29175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29176         LDKUnsignedChannelUpdate this_ptr_conv;
29177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29178         this_ptr_conv.is_owned = false;
29179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29180         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
29181 }
29182
29183 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
29184         LDKUnsignedChannelUpdate this_ptr_conv;
29185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29186         this_ptr_conv.is_owned = false;
29187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29188         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
29189         return ret_val;
29190 }
29191
29192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29193         LDKUnsignedChannelUpdate this_ptr_conv;
29194         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29195         this_ptr_conv.is_owned = false;
29196         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29197         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
29198 }
29199
29200 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
29201         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
29202 uint64_t ret_ref = 0;
29203 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29204 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29205 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29206 ret_ref = (uint64_t)ret_var.inner;
29207 if (ret_var.is_owned) {
29208         ret_ref |= 1;
29209 }
29210         return ret_ref;
29211 }
29212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29213         LDKUnsignedChannelUpdate arg_conv;
29214         arg_conv.inner = (void*)(arg & (~1));
29215         arg_conv.is_owned = false;
29216         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29217         int64_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
29218         return ret_val;
29219 }
29220
29221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29222         LDKUnsignedChannelUpdate orig_conv;
29223         orig_conv.inner = (void*)(orig & (~1));
29224         orig_conv.is_owned = false;
29225         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29226         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
29227         uint64_t ret_ref = 0;
29228         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29229         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29231         ret_ref = (uint64_t)ret_var.inner;
29232         if (ret_var.is_owned) {
29233                 ret_ref |= 1;
29234         }
29235         return ret_ref;
29236 }
29237
29238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29239         LDKChannelUpdate this_obj_conv;
29240         this_obj_conv.inner = (void*)(this_obj & (~1));
29241         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29243         ChannelUpdate_free(this_obj_conv);
29244 }
29245
29246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
29247         LDKChannelUpdate this_ptr_conv;
29248         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29249         this_ptr_conv.is_owned = false;
29250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29251         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29252         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
29253         return ret_arr;
29254 }
29255
29256 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29257         LDKChannelUpdate this_ptr_conv;
29258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29259         this_ptr_conv.is_owned = false;
29260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29261         LDKSignature val_ref;
29262         CHECK((*env)->GetArrayLength(env, val) == 64);
29263         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29264         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
29265 }
29266
29267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
29268         LDKChannelUpdate this_ptr_conv;
29269         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29270         this_ptr_conv.is_owned = false;
29271         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29272         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
29273         uint64_t ret_ref = 0;
29274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29277         ret_ref = (uint64_t)ret_var.inner;
29278         if (ret_var.is_owned) {
29279                 ret_ref |= 1;
29280         }
29281         return ret_ref;
29282 }
29283
29284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29285         LDKChannelUpdate this_ptr_conv;
29286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29287         this_ptr_conv.is_owned = false;
29288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29289         LDKUnsignedChannelUpdate val_conv;
29290         val_conv.inner = (void*)(val & (~1));
29291         val_conv.is_owned = (val & 1) || (val == 0);
29292         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29293         val_conv = UnsignedChannelUpdate_clone(&val_conv);
29294         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
29295 }
29296
29297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
29298         LDKSignature signature_arg_ref;
29299         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
29300         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
29301         LDKUnsignedChannelUpdate contents_arg_conv;
29302         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29303         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29304         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29305         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
29306         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
29307         uint64_t ret_ref = 0;
29308         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29309         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29310         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29311         ret_ref = (uint64_t)ret_var.inner;
29312         if (ret_var.is_owned) {
29313                 ret_ref |= 1;
29314         }
29315         return ret_ref;
29316 }
29317
29318 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
29319         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
29320 uint64_t ret_ref = 0;
29321 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29322 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29323 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29324 ret_ref = (uint64_t)ret_var.inner;
29325 if (ret_var.is_owned) {
29326         ret_ref |= 1;
29327 }
29328         return ret_ref;
29329 }
29330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29331         LDKChannelUpdate arg_conv;
29332         arg_conv.inner = (void*)(arg & (~1));
29333         arg_conv.is_owned = false;
29334         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29335         int64_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
29336         return ret_val;
29337 }
29338
29339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29340         LDKChannelUpdate orig_conv;
29341         orig_conv.inner = (void*)(orig & (~1));
29342         orig_conv.is_owned = false;
29343         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29344         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
29345         uint64_t ret_ref = 0;
29346         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29347         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29349         ret_ref = (uint64_t)ret_var.inner;
29350         if (ret_var.is_owned) {
29351                 ret_ref |= 1;
29352         }
29353         return ret_ref;
29354 }
29355
29356 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29357         LDKQueryChannelRange this_obj_conv;
29358         this_obj_conv.inner = (void*)(this_obj & (~1));
29359         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29360         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29361         QueryChannelRange_free(this_obj_conv);
29362 }
29363
29364 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29365         LDKQueryChannelRange this_ptr_conv;
29366         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29367         this_ptr_conv.is_owned = false;
29368         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29369         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29370         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
29371         return ret_arr;
29372 }
29373
29374 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29375         LDKQueryChannelRange this_ptr_conv;
29376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29377         this_ptr_conv.is_owned = false;
29378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29379         LDKThirtyTwoBytes val_ref;
29380         CHECK((*env)->GetArrayLength(env, val) == 32);
29381         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29382         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
29383 }
29384
29385 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
29386         LDKQueryChannelRange this_ptr_conv;
29387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29388         this_ptr_conv.is_owned = false;
29389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29390         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
29391         return ret_val;
29392 }
29393
29394 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29395         LDKQueryChannelRange this_ptr_conv;
29396         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29397         this_ptr_conv.is_owned = false;
29398         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29399         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
29400 }
29401
29402 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
29403         LDKQueryChannelRange this_ptr_conv;
29404         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29405         this_ptr_conv.is_owned = false;
29406         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29407         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
29408         return ret_val;
29409 }
29410
29411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29412         LDKQueryChannelRange this_ptr_conv;
29413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29414         this_ptr_conv.is_owned = false;
29415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29416         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
29417 }
29418
29419 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) {
29420         LDKThirtyTwoBytes chain_hash_arg_ref;
29421         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29422         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29423         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
29424         uint64_t ret_ref = 0;
29425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29428         ret_ref = (uint64_t)ret_var.inner;
29429         if (ret_var.is_owned) {
29430                 ret_ref |= 1;
29431         }
29432         return ret_ref;
29433 }
29434
29435 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
29436         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
29437 uint64_t ret_ref = 0;
29438 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29439 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29440 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29441 ret_ref = (uint64_t)ret_var.inner;
29442 if (ret_var.is_owned) {
29443         ret_ref |= 1;
29444 }
29445         return ret_ref;
29446 }
29447 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29448         LDKQueryChannelRange arg_conv;
29449         arg_conv.inner = (void*)(arg & (~1));
29450         arg_conv.is_owned = false;
29451         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29452         int64_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
29453         return ret_val;
29454 }
29455
29456 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29457         LDKQueryChannelRange orig_conv;
29458         orig_conv.inner = (void*)(orig & (~1));
29459         orig_conv.is_owned = false;
29460         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29461         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
29462         uint64_t ret_ref = 0;
29463         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29464         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29465         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29466         ret_ref = (uint64_t)ret_var.inner;
29467         if (ret_var.is_owned) {
29468                 ret_ref |= 1;
29469         }
29470         return ret_ref;
29471 }
29472
29473 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29474         LDKReplyChannelRange this_obj_conv;
29475         this_obj_conv.inner = (void*)(this_obj & (~1));
29476         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29478         ReplyChannelRange_free(this_obj_conv);
29479 }
29480
29481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29482         LDKReplyChannelRange this_ptr_conv;
29483         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29484         this_ptr_conv.is_owned = false;
29485         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29486         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29487         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
29488         return ret_arr;
29489 }
29490
29491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29492         LDKReplyChannelRange this_ptr_conv;
29493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29494         this_ptr_conv.is_owned = false;
29495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29496         LDKThirtyTwoBytes val_ref;
29497         CHECK((*env)->GetArrayLength(env, val) == 32);
29498         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29499         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
29500 }
29501
29502 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
29503         LDKReplyChannelRange this_ptr_conv;
29504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29505         this_ptr_conv.is_owned = false;
29506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29507         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
29508         return ret_val;
29509 }
29510
29511 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29512         LDKReplyChannelRange this_ptr_conv;
29513         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29514         this_ptr_conv.is_owned = false;
29515         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29516         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
29517 }
29518
29519 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
29520         LDKReplyChannelRange this_ptr_conv;
29521         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29522         this_ptr_conv.is_owned = false;
29523         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29524         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
29525         return ret_val;
29526 }
29527
29528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29529         LDKReplyChannelRange this_ptr_conv;
29530         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29531         this_ptr_conv.is_owned = false;
29532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29533         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
29534 }
29535
29536 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
29537         LDKReplyChannelRange this_ptr_conv;
29538         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29539         this_ptr_conv.is_owned = false;
29540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29541         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
29542         return ret_val;
29543 }
29544
29545 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29546         LDKReplyChannelRange this_ptr_conv;
29547         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29548         this_ptr_conv.is_owned = false;
29549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29550         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
29551 }
29552
29553 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29554         LDKReplyChannelRange this_ptr_conv;
29555         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29556         this_ptr_conv.is_owned = false;
29557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29558         LDKCVec_u64Z val_constr;
29559         val_constr.datalen = (*env)->GetArrayLength(env, val);
29560         if (val_constr.datalen > 0)
29561                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29562         else
29563                 val_constr.data = NULL;
29564         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29565         for (size_t g = 0; g < val_constr.datalen; g++) {
29566                 int64_t val_conv_6 = val_vals[g];
29567                 val_constr.data[g] = val_conv_6;
29568         }
29569         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29570         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
29571 }
29572
29573 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) {
29574         LDKThirtyTwoBytes chain_hash_arg_ref;
29575         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29576         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29577         LDKCVec_u64Z short_channel_ids_arg_constr;
29578         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
29579         if (short_channel_ids_arg_constr.datalen > 0)
29580                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29581         else
29582                 short_channel_ids_arg_constr.data = NULL;
29583         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
29584         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
29585                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
29586                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
29587         }
29588         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
29589         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
29590         uint64_t ret_ref = 0;
29591         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29592         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29593         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29594         ret_ref = (uint64_t)ret_var.inner;
29595         if (ret_var.is_owned) {
29596                 ret_ref |= 1;
29597         }
29598         return ret_ref;
29599 }
29600
29601 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
29602         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
29603 uint64_t ret_ref = 0;
29604 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29605 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29606 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29607 ret_ref = (uint64_t)ret_var.inner;
29608 if (ret_var.is_owned) {
29609         ret_ref |= 1;
29610 }
29611         return ret_ref;
29612 }
29613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29614         LDKReplyChannelRange arg_conv;
29615         arg_conv.inner = (void*)(arg & (~1));
29616         arg_conv.is_owned = false;
29617         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29618         int64_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
29619         return ret_val;
29620 }
29621
29622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29623         LDKReplyChannelRange orig_conv;
29624         orig_conv.inner = (void*)(orig & (~1));
29625         orig_conv.is_owned = false;
29626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29627         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
29628         uint64_t ret_ref = 0;
29629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29632         ret_ref = (uint64_t)ret_var.inner;
29633         if (ret_var.is_owned) {
29634                 ret_ref |= 1;
29635         }
29636         return ret_ref;
29637 }
29638
29639 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29640         LDKQueryShortChannelIds this_obj_conv;
29641         this_obj_conv.inner = (void*)(this_obj & (~1));
29642         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29644         QueryShortChannelIds_free(this_obj_conv);
29645 }
29646
29647 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29648         LDKQueryShortChannelIds this_ptr_conv;
29649         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29650         this_ptr_conv.is_owned = false;
29651         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29652         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29653         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
29654         return ret_arr;
29655 }
29656
29657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29658         LDKQueryShortChannelIds this_ptr_conv;
29659         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29660         this_ptr_conv.is_owned = false;
29661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29662         LDKThirtyTwoBytes val_ref;
29663         CHECK((*env)->GetArrayLength(env, val) == 32);
29664         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29665         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
29666 }
29667
29668 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29669         LDKQueryShortChannelIds this_ptr_conv;
29670         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29671         this_ptr_conv.is_owned = false;
29672         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29673         LDKCVec_u64Z val_constr;
29674         val_constr.datalen = (*env)->GetArrayLength(env, val);
29675         if (val_constr.datalen > 0)
29676                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29677         else
29678                 val_constr.data = NULL;
29679         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29680         for (size_t g = 0; g < val_constr.datalen; g++) {
29681                 int64_t val_conv_6 = val_vals[g];
29682                 val_constr.data[g] = val_conv_6;
29683         }
29684         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29685         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
29686 }
29687
29688 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) {
29689         LDKThirtyTwoBytes chain_hash_arg_ref;
29690         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29691         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29692         LDKCVec_u64Z short_channel_ids_arg_constr;
29693         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
29694         if (short_channel_ids_arg_constr.datalen > 0)
29695                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29696         else
29697                 short_channel_ids_arg_constr.data = NULL;
29698         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
29699         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
29700                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
29701                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
29702         }
29703         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
29704         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
29705         uint64_t ret_ref = 0;
29706         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29707         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29708         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29709         ret_ref = (uint64_t)ret_var.inner;
29710         if (ret_var.is_owned) {
29711                 ret_ref |= 1;
29712         }
29713         return ret_ref;
29714 }
29715
29716 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
29717         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
29718 uint64_t ret_ref = 0;
29719 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29720 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29721 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29722 ret_ref = (uint64_t)ret_var.inner;
29723 if (ret_var.is_owned) {
29724         ret_ref |= 1;
29725 }
29726         return ret_ref;
29727 }
29728 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29729         LDKQueryShortChannelIds arg_conv;
29730         arg_conv.inner = (void*)(arg & (~1));
29731         arg_conv.is_owned = false;
29732         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29733         int64_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
29734         return ret_val;
29735 }
29736
29737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29738         LDKQueryShortChannelIds orig_conv;
29739         orig_conv.inner = (void*)(orig & (~1));
29740         orig_conv.is_owned = false;
29741         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29742         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
29743         uint64_t ret_ref = 0;
29744         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29745         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29746         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29747         ret_ref = (uint64_t)ret_var.inner;
29748         if (ret_var.is_owned) {
29749                 ret_ref |= 1;
29750         }
29751         return ret_ref;
29752 }
29753
29754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29755         LDKReplyShortChannelIdsEnd this_obj_conv;
29756         this_obj_conv.inner = (void*)(this_obj & (~1));
29757         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29759         ReplyShortChannelIdsEnd_free(this_obj_conv);
29760 }
29761
29762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29763         LDKReplyShortChannelIdsEnd this_ptr_conv;
29764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29765         this_ptr_conv.is_owned = false;
29766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29767         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
29769         return ret_arr;
29770 }
29771
29772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29773         LDKReplyShortChannelIdsEnd this_ptr_conv;
29774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29775         this_ptr_conv.is_owned = false;
29776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29777         LDKThirtyTwoBytes val_ref;
29778         CHECK((*env)->GetArrayLength(env, val) == 32);
29779         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29780         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
29781 }
29782
29783 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
29784         LDKReplyShortChannelIdsEnd this_ptr_conv;
29785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29786         this_ptr_conv.is_owned = false;
29787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29788         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
29789         return ret_val;
29790 }
29791
29792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29793         LDKReplyShortChannelIdsEnd this_ptr_conv;
29794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29795         this_ptr_conv.is_owned = false;
29796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29797         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
29798 }
29799
29800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
29801         LDKThirtyTwoBytes chain_hash_arg_ref;
29802         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29803         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29804         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
29805         uint64_t ret_ref = 0;
29806         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29807         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29808         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29809         ret_ref = (uint64_t)ret_var.inner;
29810         if (ret_var.is_owned) {
29811                 ret_ref |= 1;
29812         }
29813         return ret_ref;
29814 }
29815
29816 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
29817         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
29818 uint64_t ret_ref = 0;
29819 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29820 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29821 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29822 ret_ref = (uint64_t)ret_var.inner;
29823 if (ret_var.is_owned) {
29824         ret_ref |= 1;
29825 }
29826         return ret_ref;
29827 }
29828 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29829         LDKReplyShortChannelIdsEnd arg_conv;
29830         arg_conv.inner = (void*)(arg & (~1));
29831         arg_conv.is_owned = false;
29832         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29833         int64_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
29834         return ret_val;
29835 }
29836
29837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29838         LDKReplyShortChannelIdsEnd orig_conv;
29839         orig_conv.inner = (void*)(orig & (~1));
29840         orig_conv.is_owned = false;
29841         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29842         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
29843         uint64_t ret_ref = 0;
29844         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29845         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29846         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29847         ret_ref = (uint64_t)ret_var.inner;
29848         if (ret_var.is_owned) {
29849                 ret_ref |= 1;
29850         }
29851         return ret_ref;
29852 }
29853
29854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29855         LDKGossipTimestampFilter this_obj_conv;
29856         this_obj_conv.inner = (void*)(this_obj & (~1));
29857         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29859         GossipTimestampFilter_free(this_obj_conv);
29860 }
29861
29862 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29863         LDKGossipTimestampFilter this_ptr_conv;
29864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29865         this_ptr_conv.is_owned = false;
29866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29867         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29868         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
29869         return ret_arr;
29870 }
29871
29872 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29873         LDKGossipTimestampFilter this_ptr_conv;
29874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29875         this_ptr_conv.is_owned = false;
29876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29877         LDKThirtyTwoBytes val_ref;
29878         CHECK((*env)->GetArrayLength(env, val) == 32);
29879         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29880         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
29881 }
29882
29883 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
29884         LDKGossipTimestampFilter this_ptr_conv;
29885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29886         this_ptr_conv.is_owned = false;
29887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29888         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
29889         return ret_val;
29890 }
29891
29892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29893         LDKGossipTimestampFilter this_ptr_conv;
29894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29895         this_ptr_conv.is_owned = false;
29896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29897         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
29898 }
29899
29900 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
29901         LDKGossipTimestampFilter this_ptr_conv;
29902         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29903         this_ptr_conv.is_owned = false;
29904         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29905         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
29906         return ret_val;
29907 }
29908
29909 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29910         LDKGossipTimestampFilter this_ptr_conv;
29911         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29912         this_ptr_conv.is_owned = false;
29913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29914         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
29915 }
29916
29917 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) {
29918         LDKThirtyTwoBytes chain_hash_arg_ref;
29919         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29920         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29921         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
29922         uint64_t ret_ref = 0;
29923         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29924         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29925         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29926         ret_ref = (uint64_t)ret_var.inner;
29927         if (ret_var.is_owned) {
29928                 ret_ref |= 1;
29929         }
29930         return ret_ref;
29931 }
29932
29933 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
29934         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
29935 uint64_t ret_ref = 0;
29936 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29937 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29938 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29939 ret_ref = (uint64_t)ret_var.inner;
29940 if (ret_var.is_owned) {
29941         ret_ref |= 1;
29942 }
29943         return ret_ref;
29944 }
29945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29946         LDKGossipTimestampFilter arg_conv;
29947         arg_conv.inner = (void*)(arg & (~1));
29948         arg_conv.is_owned = false;
29949         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29950         int64_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
29951         return ret_val;
29952 }
29953
29954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29955         LDKGossipTimestampFilter orig_conv;
29956         orig_conv.inner = (void*)(orig & (~1));
29957         orig_conv.is_owned = false;
29958         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29959         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
29960         uint64_t ret_ref = 0;
29961         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29962         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29963         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29964         ret_ref = (uint64_t)ret_var.inner;
29965         if (ret_var.is_owned) {
29966                 ret_ref |= 1;
29967         }
29968         return ret_ref;
29969 }
29970
29971 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29972         if ((this_ptr & 1) != 0) return;
29973         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
29974         CHECK_ACCESS(this_ptr_ptr);
29975         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
29976         FREE((void*)this_ptr);
29977         ErrorAction_free(this_ptr_conv);
29978 }
29979
29980 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
29981         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
29982         *ret_copy = ErrorAction_clone(arg);
29983 uint64_t ret_ref = (uint64_t)ret_copy;
29984         return ret_ref;
29985 }
29986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29987         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
29988         int64_t ret_val = ErrorAction_clone_ptr(arg_conv);
29989         return ret_val;
29990 }
29991
29992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29993         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
29994         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
29995         *ret_copy = ErrorAction_clone(orig_conv);
29996         uint64_t ret_ref = (uint64_t)ret_copy;
29997         return ret_ref;
29998 }
29999
30000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
30001         LDKErrorMessage msg_conv;
30002         msg_conv.inner = (void*)(msg & (~1));
30003         msg_conv.is_owned = (msg & 1) || (msg == 0);
30004         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30005         msg_conv = ErrorMessage_clone(&msg_conv);
30006         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30007         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
30008         uint64_t ret_ref = (uint64_t)ret_copy;
30009         return ret_ref;
30010 }
30011
30012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
30013         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30014         *ret_copy = ErrorAction_ignore_error();
30015         uint64_t ret_ref = (uint64_t)ret_copy;
30016         return ret_ref;
30017 }
30018
30019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
30020         LDKLevel a_conv = LDKLevel_from_java(env, a);
30021         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30022         *ret_copy = ErrorAction_ignore_and_log(a_conv);
30023         uint64_t ret_ref = (uint64_t)ret_copy;
30024         return ret_ref;
30025 }
30026
30027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
30028         LDKErrorMessage msg_conv;
30029         msg_conv.inner = (void*)(msg & (~1));
30030         msg_conv.is_owned = (msg & 1) || (msg == 0);
30031         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30032         msg_conv = ErrorMessage_clone(&msg_conv);
30033         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30034         *ret_copy = ErrorAction_send_error_message(msg_conv);
30035         uint64_t ret_ref = (uint64_t)ret_copy;
30036         return ret_ref;
30037 }
30038
30039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30040         LDKLightningError this_obj_conv;
30041         this_obj_conv.inner = (void*)(this_obj & (~1));
30042         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30044         LightningError_free(this_obj_conv);
30045 }
30046
30047 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
30048         LDKLightningError this_ptr_conv;
30049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30050         this_ptr_conv.is_owned = false;
30051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30052         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
30053         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30054         Str_free(ret_str);
30055         return ret_conv;
30056 }
30057
30058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30059         LDKLightningError this_ptr_conv;
30060         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30061         this_ptr_conv.is_owned = false;
30062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30063         LDKStr val_conv = java_to_owned_str(env, val);
30064         LightningError_set_err(&this_ptr_conv, val_conv);
30065 }
30066
30067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
30068         LDKLightningError this_ptr_conv;
30069         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30070         this_ptr_conv.is_owned = false;
30071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30072         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30073         *ret_copy = LightningError_get_action(&this_ptr_conv);
30074         uint64_t ret_ref = (uint64_t)ret_copy;
30075         return ret_ref;
30076 }
30077
30078 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30079         LDKLightningError this_ptr_conv;
30080         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30081         this_ptr_conv.is_owned = false;
30082         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30083         void* val_ptr = (void*)(((uint64_t)val) & ~1);
30084         CHECK_ACCESS(val_ptr);
30085         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
30086         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
30087         LightningError_set_action(&this_ptr_conv, val_conv);
30088 }
30089
30090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
30091         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
30092         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
30093         CHECK_ACCESS(action_arg_ptr);
30094         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
30095         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
30096         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
30097         uint64_t ret_ref = 0;
30098         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30099         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30100         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30101         ret_ref = (uint64_t)ret_var.inner;
30102         if (ret_var.is_owned) {
30103                 ret_ref |= 1;
30104         }
30105         return ret_ref;
30106 }
30107
30108 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
30109         LDKLightningError ret_var = LightningError_clone(arg);
30110 uint64_t ret_ref = 0;
30111 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30112 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30113 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30114 ret_ref = (uint64_t)ret_var.inner;
30115 if (ret_var.is_owned) {
30116         ret_ref |= 1;
30117 }
30118         return ret_ref;
30119 }
30120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30121         LDKLightningError arg_conv;
30122         arg_conv.inner = (void*)(arg & (~1));
30123         arg_conv.is_owned = false;
30124         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30125         int64_t ret_val = LightningError_clone_ptr(&arg_conv);
30126         return ret_val;
30127 }
30128
30129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30130         LDKLightningError orig_conv;
30131         orig_conv.inner = (void*)(orig & (~1));
30132         orig_conv.is_owned = false;
30133         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30134         LDKLightningError ret_var = LightningError_clone(&orig_conv);
30135         uint64_t ret_ref = 0;
30136         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30137         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30138         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30139         ret_ref = (uint64_t)ret_var.inner;
30140         if (ret_var.is_owned) {
30141                 ret_ref |= 1;
30142         }
30143         return ret_ref;
30144 }
30145
30146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30147         LDKCommitmentUpdate this_obj_conv;
30148         this_obj_conv.inner = (void*)(this_obj & (~1));
30149         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30151         CommitmentUpdate_free(this_obj_conv);
30152 }
30153
30154 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30155         LDKCommitmentUpdate this_ptr_conv;
30156         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30157         this_ptr_conv.is_owned = false;
30158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30159         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
30160         int64_tArray ret_arr = NULL;
30161         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30162         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30163         for (size_t p = 0; p < ret_var.datalen; p++) {
30164                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
30165                 uint64_t ret_conv_15_ref = 0;
30166                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30167                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30168                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
30169                 ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
30170                 if (ret_conv_15_var.is_owned) {
30171                         ret_conv_15_ref |= 1;
30172                 }
30173                 ret_arr_ptr[p] = ret_conv_15_ref;
30174         }
30175         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30176         FREE(ret_var.data);
30177         return ret_arr;
30178 }
30179
30180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30181         LDKCommitmentUpdate this_ptr_conv;
30182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30183         this_ptr_conv.is_owned = false;
30184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30185         LDKCVec_UpdateAddHTLCZ val_constr;
30186         val_constr.datalen = (*env)->GetArrayLength(env, val);
30187         if (val_constr.datalen > 0)
30188                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30189         else
30190                 val_constr.data = NULL;
30191         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30192         for (size_t p = 0; p < val_constr.datalen; p++) {
30193                 int64_t val_conv_15 = val_vals[p];
30194                 LDKUpdateAddHTLC val_conv_15_conv;
30195                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
30196                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
30197                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
30198                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
30199                 val_constr.data[p] = val_conv_15_conv;
30200         }
30201         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30202         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
30203 }
30204
30205 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30206         LDKCommitmentUpdate this_ptr_conv;
30207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30208         this_ptr_conv.is_owned = false;
30209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30210         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
30211         int64_tArray ret_arr = NULL;
30212         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30213         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30214         for (size_t t = 0; t < ret_var.datalen; t++) {
30215                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
30216                 uint64_t ret_conv_19_ref = 0;
30217                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30218                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30219                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
30220                 ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
30221                 if (ret_conv_19_var.is_owned) {
30222                         ret_conv_19_ref |= 1;
30223                 }
30224                 ret_arr_ptr[t] = ret_conv_19_ref;
30225         }
30226         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30227         FREE(ret_var.data);
30228         return ret_arr;
30229 }
30230
30231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30232         LDKCommitmentUpdate this_ptr_conv;
30233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30234         this_ptr_conv.is_owned = false;
30235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30236         LDKCVec_UpdateFulfillHTLCZ val_constr;
30237         val_constr.datalen = (*env)->GetArrayLength(env, val);
30238         if (val_constr.datalen > 0)
30239                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30240         else
30241                 val_constr.data = NULL;
30242         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30243         for (size_t t = 0; t < val_constr.datalen; t++) {
30244                 int64_t val_conv_19 = val_vals[t];
30245                 LDKUpdateFulfillHTLC val_conv_19_conv;
30246                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
30247                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
30248                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
30249                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
30250                 val_constr.data[t] = val_conv_19_conv;
30251         }
30252         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30253         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
30254 }
30255
30256 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30257         LDKCommitmentUpdate this_ptr_conv;
30258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30259         this_ptr_conv.is_owned = false;
30260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30261         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
30262         int64_tArray ret_arr = NULL;
30263         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30264         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30265         for (size_t q = 0; q < ret_var.datalen; q++) {
30266                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
30267                 uint64_t ret_conv_16_ref = 0;
30268                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30269                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30270                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30271                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
30272                 if (ret_conv_16_var.is_owned) {
30273                         ret_conv_16_ref |= 1;
30274                 }
30275                 ret_arr_ptr[q] = ret_conv_16_ref;
30276         }
30277         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30278         FREE(ret_var.data);
30279         return ret_arr;
30280 }
30281
30282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30283         LDKCommitmentUpdate this_ptr_conv;
30284         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30285         this_ptr_conv.is_owned = false;
30286         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30287         LDKCVec_UpdateFailHTLCZ val_constr;
30288         val_constr.datalen = (*env)->GetArrayLength(env, val);
30289         if (val_constr.datalen > 0)
30290                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30291         else
30292                 val_constr.data = NULL;
30293         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30294         for (size_t q = 0; q < val_constr.datalen; q++) {
30295                 int64_t val_conv_16 = val_vals[q];
30296                 LDKUpdateFailHTLC val_conv_16_conv;
30297                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30298                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30299                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30300                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
30301                 val_constr.data[q] = val_conv_16_conv;
30302         }
30303         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30304         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
30305 }
30306
30307 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30308         LDKCommitmentUpdate this_ptr_conv;
30309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30310         this_ptr_conv.is_owned = false;
30311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30312         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
30313         int64_tArray ret_arr = NULL;
30314         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30315         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30316         for (size_t z = 0; z < ret_var.datalen; z++) {
30317                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
30318                 uint64_t ret_conv_25_ref = 0;
30319                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30320                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30321                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
30322                 ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
30323                 if (ret_conv_25_var.is_owned) {
30324                         ret_conv_25_ref |= 1;
30325                 }
30326                 ret_arr_ptr[z] = ret_conv_25_ref;
30327         }
30328         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30329         FREE(ret_var.data);
30330         return ret_arr;
30331 }
30332
30333 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) {
30334         LDKCommitmentUpdate this_ptr_conv;
30335         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30336         this_ptr_conv.is_owned = false;
30337         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30338         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
30339         val_constr.datalen = (*env)->GetArrayLength(env, val);
30340         if (val_constr.datalen > 0)
30341                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30342         else
30343                 val_constr.data = NULL;
30344         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30345         for (size_t z = 0; z < val_constr.datalen; z++) {
30346                 int64_t val_conv_25 = val_vals[z];
30347                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
30348                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
30349                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
30350                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
30351                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
30352                 val_constr.data[z] = val_conv_25_conv;
30353         }
30354         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30355         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
30356 }
30357
30358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
30359         LDKCommitmentUpdate this_ptr_conv;
30360         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30361         this_ptr_conv.is_owned = false;
30362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30363         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
30364         uint64_t ret_ref = 0;
30365         if ((uint64_t)ret_var.inner > 4096) {
30366                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30367                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30368         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30369                 ret_ref = (uint64_t)ret_var.inner;
30370                 if (ret_var.is_owned) {
30371                         ret_ref |= 1;
30372                 }
30373         }
30374         return ret_ref;
30375 }
30376
30377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30378         LDKCommitmentUpdate this_ptr_conv;
30379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30380         this_ptr_conv.is_owned = false;
30381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30382         LDKUpdateFee val_conv;
30383         val_conv.inner = (void*)(val & (~1));
30384         val_conv.is_owned = (val & 1) || (val == 0);
30385         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30386         val_conv = UpdateFee_clone(&val_conv);
30387         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
30388 }
30389
30390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
30391         LDKCommitmentUpdate this_ptr_conv;
30392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30393         this_ptr_conv.is_owned = false;
30394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30395         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
30396         uint64_t ret_ref = 0;
30397         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30398         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30399         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30400         ret_ref = (uint64_t)ret_var.inner;
30401         if (ret_var.is_owned) {
30402                 ret_ref |= 1;
30403         }
30404         return ret_ref;
30405 }
30406
30407 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30408         LDKCommitmentUpdate this_ptr_conv;
30409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30410         this_ptr_conv.is_owned = false;
30411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30412         LDKCommitmentSigned val_conv;
30413         val_conv.inner = (void*)(val & (~1));
30414         val_conv.is_owned = (val & 1) || (val == 0);
30415         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30416         val_conv = CommitmentSigned_clone(&val_conv);
30417         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
30418 }
30419
30420 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) {
30421         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
30422         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
30423         if (update_add_htlcs_arg_constr.datalen > 0)
30424                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30425         else
30426                 update_add_htlcs_arg_constr.data = NULL;
30427         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
30428         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
30429                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
30430                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
30431                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
30432                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
30433                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
30434                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
30435                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
30436         }
30437         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
30438         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
30439         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
30440         if (update_fulfill_htlcs_arg_constr.datalen > 0)
30441                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30442         else
30443                 update_fulfill_htlcs_arg_constr.data = NULL;
30444         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
30445         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
30446                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
30447                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
30448                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
30449                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
30450                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
30451                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
30452                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
30453         }
30454         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
30455         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
30456         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
30457         if (update_fail_htlcs_arg_constr.datalen > 0)
30458                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30459         else
30460                 update_fail_htlcs_arg_constr.data = NULL;
30461         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
30462         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
30463                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
30464                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
30465                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
30466                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
30467                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
30468                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
30469                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
30470         }
30471         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
30472         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
30473         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
30474         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
30475                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30476         else
30477                 update_fail_malformed_htlcs_arg_constr.data = NULL;
30478         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
30479         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
30480                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
30481                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
30482                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
30483                 update_fail_malformed_htlcs_arg_conv_25_conv.is_owned = (update_fail_malformed_htlcs_arg_conv_25 & 1) || (update_fail_malformed_htlcs_arg_conv_25 == 0);
30484                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
30485                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
30486                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
30487         }
30488         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
30489         LDKUpdateFee update_fee_arg_conv;
30490         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
30491         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
30492         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
30493         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
30494         LDKCommitmentSigned commitment_signed_arg_conv;
30495         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
30496         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
30497         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
30498         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
30499         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);
30500         uint64_t ret_ref = 0;
30501         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30502         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30503         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30504         ret_ref = (uint64_t)ret_var.inner;
30505         if (ret_var.is_owned) {
30506                 ret_ref |= 1;
30507         }
30508         return ret_ref;
30509 }
30510
30511 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
30512         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
30513 uint64_t ret_ref = 0;
30514 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30515 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30516 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30517 ret_ref = (uint64_t)ret_var.inner;
30518 if (ret_var.is_owned) {
30519         ret_ref |= 1;
30520 }
30521         return ret_ref;
30522 }
30523 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30524         LDKCommitmentUpdate arg_conv;
30525         arg_conv.inner = (void*)(arg & (~1));
30526         arg_conv.is_owned = false;
30527         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30528         int64_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
30529         return ret_val;
30530 }
30531
30532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30533         LDKCommitmentUpdate orig_conv;
30534         orig_conv.inner = (void*)(orig & (~1));
30535         orig_conv.is_owned = false;
30536         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30537         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
30538         uint64_t ret_ref = 0;
30539         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30540         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30541         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30542         ret_ref = (uint64_t)ret_var.inner;
30543         if (ret_var.is_owned) {
30544                 ret_ref |= 1;
30545         }
30546         return ret_ref;
30547 }
30548
30549 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30550         if ((this_ptr & 1) != 0) return;
30551         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30552         CHECK_ACCESS(this_ptr_ptr);
30553         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
30554         FREE((void*)this_ptr);
30555         ChannelMessageHandler_free(this_ptr_conv);
30556 }
30557
30558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30559         if ((this_ptr & 1) != 0) return;
30560         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30561         CHECK_ACCESS(this_ptr_ptr);
30562         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
30563         FREE((void*)this_ptr);
30564         RoutingMessageHandler_free(this_ptr_conv);
30565 }
30566
30567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
30568         LDKAcceptChannel obj_conv;
30569         obj_conv.inner = (void*)(obj & (~1));
30570         obj_conv.is_owned = false;
30571         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30572         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
30573         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30574         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30575         CVec_u8Z_free(ret_var);
30576         return ret_arr;
30577 }
30578
30579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30580         LDKu8slice ser_ref;
30581         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30582         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30583         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
30584         *ret_conv = AcceptChannel_read(ser_ref);
30585         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30586         return (uint64_t)ret_conv;
30587 }
30588
30589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
30590         LDKAnnouncementSignatures obj_conv;
30591         obj_conv.inner = (void*)(obj & (~1));
30592         obj_conv.is_owned = false;
30593         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30594         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
30595         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30596         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30597         CVec_u8Z_free(ret_var);
30598         return ret_arr;
30599 }
30600
30601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30602         LDKu8slice ser_ref;
30603         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30604         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30605         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
30606         *ret_conv = AnnouncementSignatures_read(ser_ref);
30607         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30608         return (uint64_t)ret_conv;
30609 }
30610
30611 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
30612         LDKChannelReestablish obj_conv;
30613         obj_conv.inner = (void*)(obj & (~1));
30614         obj_conv.is_owned = false;
30615         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30616         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
30617         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30618         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30619         CVec_u8Z_free(ret_var);
30620         return ret_arr;
30621 }
30622
30623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30624         LDKu8slice ser_ref;
30625         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30626         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30627         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
30628         *ret_conv = ChannelReestablish_read(ser_ref);
30629         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30630         return (uint64_t)ret_conv;
30631 }
30632
30633 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
30634         LDKClosingSigned obj_conv;
30635         obj_conv.inner = (void*)(obj & (~1));
30636         obj_conv.is_owned = false;
30637         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30638         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
30639         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30640         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30641         CVec_u8Z_free(ret_var);
30642         return ret_arr;
30643 }
30644
30645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30646         LDKu8slice ser_ref;
30647         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30648         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30649         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
30650         *ret_conv = ClosingSigned_read(ser_ref);
30651         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30652         return (uint64_t)ret_conv;
30653 }
30654
30655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
30656         LDKClosingSignedFeeRange obj_conv;
30657         obj_conv.inner = (void*)(obj & (~1));
30658         obj_conv.is_owned = false;
30659         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30660         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
30661         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30662         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30663         CVec_u8Z_free(ret_var);
30664         return ret_arr;
30665 }
30666
30667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30668         LDKu8slice ser_ref;
30669         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30670         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30671         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
30672         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
30673         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30674         return (uint64_t)ret_conv;
30675 }
30676
30677 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
30678         LDKCommitmentSigned obj_conv;
30679         obj_conv.inner = (void*)(obj & (~1));
30680         obj_conv.is_owned = false;
30681         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30682         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
30683         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30684         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30685         CVec_u8Z_free(ret_var);
30686         return ret_arr;
30687 }
30688
30689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30690         LDKu8slice ser_ref;
30691         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30692         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30693         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
30694         *ret_conv = CommitmentSigned_read(ser_ref);
30695         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30696         return (uint64_t)ret_conv;
30697 }
30698
30699 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
30700         LDKFundingCreated obj_conv;
30701         obj_conv.inner = (void*)(obj & (~1));
30702         obj_conv.is_owned = false;
30703         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30704         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
30705         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30706         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30707         CVec_u8Z_free(ret_var);
30708         return ret_arr;
30709 }
30710
30711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30712         LDKu8slice ser_ref;
30713         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30714         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30715         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
30716         *ret_conv = FundingCreated_read(ser_ref);
30717         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30718         return (uint64_t)ret_conv;
30719 }
30720
30721 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
30722         LDKFundingSigned obj_conv;
30723         obj_conv.inner = (void*)(obj & (~1));
30724         obj_conv.is_owned = false;
30725         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30726         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
30727         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30728         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30729         CVec_u8Z_free(ret_var);
30730         return ret_arr;
30731 }
30732
30733 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30734         LDKu8slice ser_ref;
30735         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30736         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30737         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
30738         *ret_conv = FundingSigned_read(ser_ref);
30739         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30740         return (uint64_t)ret_conv;
30741 }
30742
30743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
30744         LDKFundingLocked obj_conv;
30745         obj_conv.inner = (void*)(obj & (~1));
30746         obj_conv.is_owned = false;
30747         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30748         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
30749         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30750         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30751         CVec_u8Z_free(ret_var);
30752         return ret_arr;
30753 }
30754
30755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30756         LDKu8slice ser_ref;
30757         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30758         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30759         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
30760         *ret_conv = FundingLocked_read(ser_ref);
30761         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30762         return (uint64_t)ret_conv;
30763 }
30764
30765 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
30766         LDKInit obj_conv;
30767         obj_conv.inner = (void*)(obj & (~1));
30768         obj_conv.is_owned = false;
30769         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30770         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
30771         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30772         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30773         CVec_u8Z_free(ret_var);
30774         return ret_arr;
30775 }
30776
30777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30778         LDKu8slice ser_ref;
30779         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30780         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30781         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
30782         *ret_conv = Init_read(ser_ref);
30783         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30784         return (uint64_t)ret_conv;
30785 }
30786
30787 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
30788         LDKOpenChannel obj_conv;
30789         obj_conv.inner = (void*)(obj & (~1));
30790         obj_conv.is_owned = false;
30791         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30792         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
30793         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30794         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30795         CVec_u8Z_free(ret_var);
30796         return ret_arr;
30797 }
30798
30799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30800         LDKu8slice ser_ref;
30801         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30802         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30803         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
30804         *ret_conv = OpenChannel_read(ser_ref);
30805         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30806         return (uint64_t)ret_conv;
30807 }
30808
30809 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
30810         LDKRevokeAndACK obj_conv;
30811         obj_conv.inner = (void*)(obj & (~1));
30812         obj_conv.is_owned = false;
30813         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30814         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
30815         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30816         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30817         CVec_u8Z_free(ret_var);
30818         return ret_arr;
30819 }
30820
30821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30822         LDKu8slice ser_ref;
30823         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30824         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30825         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
30826         *ret_conv = RevokeAndACK_read(ser_ref);
30827         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30828         return (uint64_t)ret_conv;
30829 }
30830
30831 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
30832         LDKShutdown obj_conv;
30833         obj_conv.inner = (void*)(obj & (~1));
30834         obj_conv.is_owned = false;
30835         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30836         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
30837         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30838         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30839         CVec_u8Z_free(ret_var);
30840         return ret_arr;
30841 }
30842
30843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30844         LDKu8slice ser_ref;
30845         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30846         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30847         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
30848         *ret_conv = Shutdown_read(ser_ref);
30849         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30850         return (uint64_t)ret_conv;
30851 }
30852
30853 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
30854         LDKUpdateFailHTLC obj_conv;
30855         obj_conv.inner = (void*)(obj & (~1));
30856         obj_conv.is_owned = false;
30857         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30858         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
30859         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30860         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30861         CVec_u8Z_free(ret_var);
30862         return ret_arr;
30863 }
30864
30865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30866         LDKu8slice ser_ref;
30867         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30868         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30869         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
30870         *ret_conv = UpdateFailHTLC_read(ser_ref);
30871         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30872         return (uint64_t)ret_conv;
30873 }
30874
30875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
30876         LDKUpdateFailMalformedHTLC obj_conv;
30877         obj_conv.inner = (void*)(obj & (~1));
30878         obj_conv.is_owned = false;
30879         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30880         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
30881         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30882         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30883         CVec_u8Z_free(ret_var);
30884         return ret_arr;
30885 }
30886
30887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30888         LDKu8slice ser_ref;
30889         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30890         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30891         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
30892         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
30893         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30894         return (uint64_t)ret_conv;
30895 }
30896
30897 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
30898         LDKUpdateFee obj_conv;
30899         obj_conv.inner = (void*)(obj & (~1));
30900         obj_conv.is_owned = false;
30901         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30902         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
30903         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30904         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30905         CVec_u8Z_free(ret_var);
30906         return ret_arr;
30907 }
30908
30909 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30910         LDKu8slice ser_ref;
30911         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30912         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30913         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
30914         *ret_conv = UpdateFee_read(ser_ref);
30915         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30916         return (uint64_t)ret_conv;
30917 }
30918
30919 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
30920         LDKUpdateFulfillHTLC obj_conv;
30921         obj_conv.inner = (void*)(obj & (~1));
30922         obj_conv.is_owned = false;
30923         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30924         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
30925         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30926         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30927         CVec_u8Z_free(ret_var);
30928         return ret_arr;
30929 }
30930
30931 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30932         LDKu8slice ser_ref;
30933         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30934         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30935         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
30936         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
30937         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30938         return (uint64_t)ret_conv;
30939 }
30940
30941 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
30942         LDKUpdateAddHTLC obj_conv;
30943         obj_conv.inner = (void*)(obj & (~1));
30944         obj_conv.is_owned = false;
30945         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30946         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
30947         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30948         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30949         CVec_u8Z_free(ret_var);
30950         return ret_arr;
30951 }
30952
30953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30954         LDKu8slice ser_ref;
30955         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30956         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30957         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
30958         *ret_conv = UpdateAddHTLC_read(ser_ref);
30959         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30960         return (uint64_t)ret_conv;
30961 }
30962
30963 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
30964         LDKPing obj_conv;
30965         obj_conv.inner = (void*)(obj & (~1));
30966         obj_conv.is_owned = false;
30967         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30968         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
30969         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30970         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30971         CVec_u8Z_free(ret_var);
30972         return ret_arr;
30973 }
30974
30975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30976         LDKu8slice ser_ref;
30977         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30978         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30979         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
30980         *ret_conv = Ping_read(ser_ref);
30981         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30982         return (uint64_t)ret_conv;
30983 }
30984
30985 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
30986         LDKPong obj_conv;
30987         obj_conv.inner = (void*)(obj & (~1));
30988         obj_conv.is_owned = false;
30989         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30990         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
30991         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30992         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30993         CVec_u8Z_free(ret_var);
30994         return ret_arr;
30995 }
30996
30997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30998         LDKu8slice ser_ref;
30999         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31000         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31001         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
31002         *ret_conv = Pong_read(ser_ref);
31003         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31004         return (uint64_t)ret_conv;
31005 }
31006
31007 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31008         LDKUnsignedChannelAnnouncement obj_conv;
31009         obj_conv.inner = (void*)(obj & (~1));
31010         obj_conv.is_owned = false;
31011         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31012         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
31013         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31014         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31015         CVec_u8Z_free(ret_var);
31016         return ret_arr;
31017 }
31018
31019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31020         LDKu8slice ser_ref;
31021         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31022         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31023         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
31024         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
31025         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31026         return (uint64_t)ret_conv;
31027 }
31028
31029 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31030         LDKChannelAnnouncement obj_conv;
31031         obj_conv.inner = (void*)(obj & (~1));
31032         obj_conv.is_owned = false;
31033         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31034         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
31035         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31036         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31037         CVec_u8Z_free(ret_var);
31038         return ret_arr;
31039 }
31040
31041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31042         LDKu8slice ser_ref;
31043         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31044         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31045         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
31046         *ret_conv = ChannelAnnouncement_read(ser_ref);
31047         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31048         return (uint64_t)ret_conv;
31049 }
31050
31051 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
31052         LDKUnsignedChannelUpdate obj_conv;
31053         obj_conv.inner = (void*)(obj & (~1));
31054         obj_conv.is_owned = false;
31055         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31056         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
31057         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31058         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31059         CVec_u8Z_free(ret_var);
31060         return ret_arr;
31061 }
31062
31063 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31064         LDKu8slice ser_ref;
31065         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31066         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31067         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
31068         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
31069         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31070         return (uint64_t)ret_conv;
31071 }
31072
31073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
31074         LDKChannelUpdate obj_conv;
31075         obj_conv.inner = (void*)(obj & (~1));
31076         obj_conv.is_owned = false;
31077         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31078         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
31079         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31080         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31081         CVec_u8Z_free(ret_var);
31082         return ret_arr;
31083 }
31084
31085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31086         LDKu8slice ser_ref;
31087         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31088         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31089         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
31090         *ret_conv = ChannelUpdate_read(ser_ref);
31091         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31092         return (uint64_t)ret_conv;
31093 }
31094
31095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
31096         LDKErrorMessage obj_conv;
31097         obj_conv.inner = (void*)(obj & (~1));
31098         obj_conv.is_owned = false;
31099         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31100         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
31101         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31102         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31103         CVec_u8Z_free(ret_var);
31104         return ret_arr;
31105 }
31106
31107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31108         LDKu8slice ser_ref;
31109         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31110         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31111         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
31112         *ret_conv = ErrorMessage_read(ser_ref);
31113         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31114         return (uint64_t)ret_conv;
31115 }
31116
31117 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31118         LDKUnsignedNodeAnnouncement obj_conv;
31119         obj_conv.inner = (void*)(obj & (~1));
31120         obj_conv.is_owned = false;
31121         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31122         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
31123         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31124         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31125         CVec_u8Z_free(ret_var);
31126         return ret_arr;
31127 }
31128
31129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31130         LDKu8slice ser_ref;
31131         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31132         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31133         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
31134         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
31135         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31136         return (uint64_t)ret_conv;
31137 }
31138
31139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31140         LDKNodeAnnouncement obj_conv;
31141         obj_conv.inner = (void*)(obj & (~1));
31142         obj_conv.is_owned = false;
31143         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31144         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
31145         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31146         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31147         CVec_u8Z_free(ret_var);
31148         return ret_arr;
31149 }
31150
31151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31152         LDKu8slice ser_ref;
31153         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31154         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31155         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
31156         *ret_conv = NodeAnnouncement_read(ser_ref);
31157         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31158         return (uint64_t)ret_conv;
31159 }
31160
31161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31162         LDKu8slice ser_ref;
31163         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31164         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31165         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
31166         *ret_conv = QueryShortChannelIds_read(ser_ref);
31167         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31168         return (uint64_t)ret_conv;
31169 }
31170
31171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
31172         LDKQueryShortChannelIds obj_conv;
31173         obj_conv.inner = (void*)(obj & (~1));
31174         obj_conv.is_owned = false;
31175         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31176         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
31177         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31178         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31179         CVec_u8Z_free(ret_var);
31180         return ret_arr;
31181 }
31182
31183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
31184         LDKReplyShortChannelIdsEnd obj_conv;
31185         obj_conv.inner = (void*)(obj & (~1));
31186         obj_conv.is_owned = false;
31187         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31188         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
31189         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31190         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31191         CVec_u8Z_free(ret_var);
31192         return ret_arr;
31193 }
31194
31195 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31196         LDKu8slice ser_ref;
31197         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31198         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31199         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
31200         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
31201         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31202         return (uint64_t)ret_conv;
31203 }
31204
31205 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
31206         LDKQueryChannelRange this_arg_conv;
31207         this_arg_conv.inner = (void*)(this_arg & (~1));
31208         this_arg_conv.is_owned = false;
31209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31210         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
31211         return ret_val;
31212 }
31213
31214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
31215         LDKQueryChannelRange obj_conv;
31216         obj_conv.inner = (void*)(obj & (~1));
31217         obj_conv.is_owned = false;
31218         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31219         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
31220         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31221         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31222         CVec_u8Z_free(ret_var);
31223         return ret_arr;
31224 }
31225
31226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31227         LDKu8slice ser_ref;
31228         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31229         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31230         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
31231         *ret_conv = QueryChannelRange_read(ser_ref);
31232         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31233         return (uint64_t)ret_conv;
31234 }
31235
31236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31237         LDKu8slice ser_ref;
31238         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31239         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31240         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
31241         *ret_conv = ReplyChannelRange_read(ser_ref);
31242         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31243         return (uint64_t)ret_conv;
31244 }
31245
31246 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
31247         LDKReplyChannelRange obj_conv;
31248         obj_conv.inner = (void*)(obj & (~1));
31249         obj_conv.is_owned = false;
31250         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31251         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
31252         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31253         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31254         CVec_u8Z_free(ret_var);
31255         return ret_arr;
31256 }
31257
31258 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
31259         LDKGossipTimestampFilter obj_conv;
31260         obj_conv.inner = (void*)(obj & (~1));
31261         obj_conv.is_owned = false;
31262         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31263         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
31264         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31265         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31266         CVec_u8Z_free(ret_var);
31267         return ret_arr;
31268 }
31269
31270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31271         LDKu8slice ser_ref;
31272         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31273         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31274         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
31275         *ret_conv = GossipTimestampFilter_read(ser_ref);
31276         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31277         return (uint64_t)ret_conv;
31278 }
31279
31280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31281         if ((this_ptr & 1) != 0) return;
31282         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31283         CHECK_ACCESS(this_ptr_ptr);
31284         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
31285         FREE((void*)this_ptr);
31286         CustomMessageHandler_free(this_ptr_conv);
31287 }
31288
31289 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31290         LDKIgnoringMessageHandler this_obj_conv;
31291         this_obj_conv.inner = (void*)(this_obj & (~1));
31292         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31294         IgnoringMessageHandler_free(this_obj_conv);
31295 }
31296
31297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
31298         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
31299         uint64_t ret_ref = 0;
31300         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31301         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31302         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31303         ret_ref = (uint64_t)ret_var.inner;
31304         if (ret_var.is_owned) {
31305                 ret_ref |= 1;
31306         }
31307         return ret_ref;
31308 }
31309
31310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31311         LDKIgnoringMessageHandler this_arg_conv;
31312         this_arg_conv.inner = (void*)(this_arg & (~1));
31313         this_arg_conv.is_owned = false;
31314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31315         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31316         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31317         return (uint64_t)ret_ret;
31318 }
31319
31320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31321         LDKIgnoringMessageHandler this_arg_conv;
31322         this_arg_conv.inner = (void*)(this_arg & (~1));
31323         this_arg_conv.is_owned = false;
31324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31325         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31326         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
31327         return (uint64_t)ret_ret;
31328 }
31329
31330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
31331         LDKIgnoringMessageHandler this_arg_conv;
31332         this_arg_conv.inner = (void*)(this_arg & (~1));
31333         this_arg_conv.is_owned = false;
31334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31335         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
31336         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
31337         return (uint64_t)ret_ret;
31338 }
31339
31340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31341         LDKIgnoringMessageHandler this_arg_conv;
31342         this_arg_conv.inner = (void*)(this_arg & (~1));
31343         this_arg_conv.is_owned = false;
31344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31345         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
31346         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
31347         return (uint64_t)ret_ret;
31348 }
31349
31350 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31351         LDKErroringMessageHandler this_obj_conv;
31352         this_obj_conv.inner = (void*)(this_obj & (~1));
31353         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31355         ErroringMessageHandler_free(this_obj_conv);
31356 }
31357
31358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
31359         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
31360         uint64_t ret_ref = 0;
31361         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31362         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31364         ret_ref = (uint64_t)ret_var.inner;
31365         if (ret_var.is_owned) {
31366                 ret_ref |= 1;
31367         }
31368         return ret_ref;
31369 }
31370
31371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31372         LDKErroringMessageHandler this_arg_conv;
31373         this_arg_conv.inner = (void*)(this_arg & (~1));
31374         this_arg_conv.is_owned = false;
31375         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31376         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31377         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31378         return (uint64_t)ret_ret;
31379 }
31380
31381 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31382         LDKErroringMessageHandler this_arg_conv;
31383         this_arg_conv.inner = (void*)(this_arg & (~1));
31384         this_arg_conv.is_owned = false;
31385         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31386         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31387         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
31388         return (uint64_t)ret_ret;
31389 }
31390
31391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31392         LDKMessageHandler this_obj_conv;
31393         this_obj_conv.inner = (void*)(this_obj & (~1));
31394         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31396         MessageHandler_free(this_obj_conv);
31397 }
31398
31399 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
31400         LDKMessageHandler this_ptr_conv;
31401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31402         this_ptr_conv.is_owned = false;
31403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31404         // WARNING: This object doesn't live past this scope, needs clone!
31405         uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
31406         return ret_ret;
31407 }
31408
31409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31410         LDKMessageHandler this_ptr_conv;
31411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31412         this_ptr_conv.is_owned = false;
31413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31414         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31415         CHECK_ACCESS(val_ptr);
31416         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
31417         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
31418                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31419                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
31420         }
31421         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
31422 }
31423
31424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
31425         LDKMessageHandler this_ptr_conv;
31426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31427         this_ptr_conv.is_owned = false;
31428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31429         // WARNING: This object doesn't live past this scope, needs clone!
31430         uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
31431         return ret_ret;
31432 }
31433
31434 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31435         LDKMessageHandler this_ptr_conv;
31436         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31437         this_ptr_conv.is_owned = false;
31438         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31439         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31440         CHECK_ACCESS(val_ptr);
31441         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
31442         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
31443                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31444                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
31445         }
31446         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
31447 }
31448
31449 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) {
31450         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
31451         CHECK_ACCESS(chan_handler_arg_ptr);
31452         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
31453         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
31454                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31455                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
31456         }
31457         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
31458         CHECK_ACCESS(route_handler_arg_ptr);
31459         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
31460         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
31461                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31462                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
31463         }
31464         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
31465         uint64_t ret_ref = 0;
31466         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31467         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31468         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31469         ret_ref = (uint64_t)ret_var.inner;
31470         if (ret_var.is_owned) {
31471                 ret_ref |= 1;
31472         }
31473         return ret_ref;
31474 }
31475
31476 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
31477         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
31478         *ret_ret = SocketDescriptor_clone(arg);
31479         return (uint64_t)ret_ret;
31480 }
31481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31482         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
31483         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31484         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
31485         int64_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
31486         return ret_val;
31487 }
31488
31489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31490         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
31491         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31492         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
31493         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
31494         *ret_ret = SocketDescriptor_clone(orig_conv);
31495         return (uint64_t)ret_ret;
31496 }
31497
31498 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31499         if ((this_ptr & 1) != 0) return;
31500         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31501         CHECK_ACCESS(this_ptr_ptr);
31502         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
31503         FREE((void*)this_ptr);
31504         SocketDescriptor_free(this_ptr_conv);
31505 }
31506
31507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31508         LDKPeerHandleError this_obj_conv;
31509         this_obj_conv.inner = (void*)(this_obj & (~1));
31510         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31512         PeerHandleError_free(this_obj_conv);
31513 }
31514
31515 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
31516         LDKPeerHandleError this_ptr_conv;
31517         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31518         this_ptr_conv.is_owned = false;
31519         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31520         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
31521         return ret_val;
31522 }
31523
31524 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31525         LDKPeerHandleError this_ptr_conv;
31526         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31527         this_ptr_conv.is_owned = false;
31528         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31529         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
31530 }
31531
31532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
31533         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
31534         uint64_t ret_ref = 0;
31535         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31536         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31537         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31538         ret_ref = (uint64_t)ret_var.inner;
31539         if (ret_var.is_owned) {
31540                 ret_ref |= 1;
31541         }
31542         return ret_ref;
31543 }
31544
31545 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
31546         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
31547 uint64_t ret_ref = 0;
31548 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31549 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31550 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31551 ret_ref = (uint64_t)ret_var.inner;
31552 if (ret_var.is_owned) {
31553         ret_ref |= 1;
31554 }
31555         return ret_ref;
31556 }
31557 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31558         LDKPeerHandleError arg_conv;
31559         arg_conv.inner = (void*)(arg & (~1));
31560         arg_conv.is_owned = false;
31561         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31562         int64_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
31563         return ret_val;
31564 }
31565
31566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31567         LDKPeerHandleError orig_conv;
31568         orig_conv.inner = (void*)(orig & (~1));
31569         orig_conv.is_owned = false;
31570         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31571         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
31572         uint64_t ret_ref = 0;
31573         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31574         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31575         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31576         ret_ref = (uint64_t)ret_var.inner;
31577         if (ret_var.is_owned) {
31578                 ret_ref |= 1;
31579         }
31580         return ret_ref;
31581 }
31582
31583 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31584         LDKPeerManager this_obj_conv;
31585         this_obj_conv.inner = (void*)(this_obj & (~1));
31586         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31588         PeerManager_free(this_obj_conv);
31589 }
31590
31591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new(JNIEnv *env, jclass clz, int64_t message_handler, int8_tArray our_node_secret, int8_tArray ephemeral_random_data, int64_t logger, int64_t custom_message_handler) {
31592         LDKMessageHandler message_handler_conv;
31593         message_handler_conv.inner = (void*)(message_handler & (~1));
31594         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
31595         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
31596         // Warning: we need a move here but no clone is available for LDKMessageHandler
31597         LDKSecretKey our_node_secret_ref;
31598         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
31599         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
31600         unsigned char ephemeral_random_data_arr[32];
31601         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
31602         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
31603         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
31604         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
31605         CHECK_ACCESS(logger_ptr);
31606         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31607         if (logger_conv.free == LDKLogger_JCalls_free) {
31608                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31609                 LDKLogger_JCalls_cloned(&logger_conv);
31610         }
31611         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
31612         CHECK_ACCESS(custom_message_handler_ptr);
31613         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
31614         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
31615                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31616                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
31617         }
31618         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
31619         uint64_t ret_ref = 0;
31620         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31621         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31622         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31623         ret_ref = (uint64_t)ret_var.inner;
31624         if (ret_var.is_owned) {
31625                 ret_ref |= 1;
31626         }
31627         return ret_ref;
31628 }
31629
31630 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
31631         LDKPeerManager this_arg_conv;
31632         this_arg_conv.inner = (void*)(this_arg & (~1));
31633         this_arg_conv.is_owned = false;
31634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31635         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
31636         jobjectArray ret_arr = NULL;
31637         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
31638         ;
31639         for (size_t i = 0; i < ret_var.datalen; i++) {
31640                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
31641                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
31642                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
31643         }
31644         
31645         FREE(ret_var.data);
31646         return ret_arr;
31647 }
31648
31649 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) {
31650         LDKPeerManager this_arg_conv;
31651         this_arg_conv.inner = (void*)(this_arg & (~1));
31652         this_arg_conv.is_owned = false;
31653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31654         LDKPublicKey their_node_id_ref;
31655         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
31656         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
31657         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
31658         CHECK_ACCESS(descriptor_ptr);
31659         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
31660         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
31661                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31662                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
31663         }
31664         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
31665         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
31666         return (uint64_t)ret_conv;
31667 }
31668
31669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
31670         LDKPeerManager this_arg_conv;
31671         this_arg_conv.inner = (void*)(this_arg & (~1));
31672         this_arg_conv.is_owned = false;
31673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31674         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
31675         CHECK_ACCESS(descriptor_ptr);
31676         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
31677         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
31678                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31679                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
31680         }
31681         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
31682         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
31683         return (uint64_t)ret_conv;
31684 }
31685
31686 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) {
31687         LDKPeerManager this_arg_conv;
31688         this_arg_conv.inner = (void*)(this_arg & (~1));
31689         this_arg_conv.is_owned = false;
31690         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31691         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
31692         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
31693         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
31694         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
31695         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
31696         return (uint64_t)ret_conv;
31697 }
31698
31699 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) {
31700         LDKPeerManager this_arg_conv;
31701         this_arg_conv.inner = (void*)(this_arg & (~1));
31702         this_arg_conv.is_owned = false;
31703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31704         void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
31705         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
31706         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
31707         LDKu8slice data_ref;
31708         data_ref.datalen = (*env)->GetArrayLength(env, data);
31709         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
31710         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
31711         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
31712         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
31713         return (uint64_t)ret_conv;
31714 }
31715
31716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
31717         LDKPeerManager this_arg_conv;
31718         this_arg_conv.inner = (void*)(this_arg & (~1));
31719         this_arg_conv.is_owned = false;
31720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31721         PeerManager_process_events(&this_arg_conv);
31722 }
31723
31724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
31725         LDKPeerManager this_arg_conv;
31726         this_arg_conv.inner = (void*)(this_arg & (~1));
31727         this_arg_conv.is_owned = false;
31728         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31729         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
31730         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
31731         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
31732         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
31733 }
31734
31735 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, jboolean no_connection_possible) {
31736         LDKPeerManager this_arg_conv;
31737         this_arg_conv.inner = (void*)(this_arg & (~1));
31738         this_arg_conv.is_owned = false;
31739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31740         LDKPublicKey node_id_ref;
31741         CHECK((*env)->GetArrayLength(env, node_id) == 33);
31742         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
31743         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
31744 }
31745
31746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
31747         LDKPeerManager this_arg_conv;
31748         this_arg_conv.inner = (void*)(this_arg & (~1));
31749         this_arg_conv.is_owned = false;
31750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31751         PeerManager_disconnect_all_peers(&this_arg_conv);
31752 }
31753
31754 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
31755         LDKPeerManager this_arg_conv;
31756         this_arg_conv.inner = (void*)(this_arg & (~1));
31757         this_arg_conv.is_owned = false;
31758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31759         PeerManager_timer_tick_occurred(&this_arg_conv);
31760 }
31761
31762 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
31763         unsigned char commitment_seed_arr[32];
31764         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
31765         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
31766         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
31767         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31768         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
31769         return ret_arr;
31770 }
31771
31772 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) {
31773         LDKCVec_u8Z to_holder_script_ref;
31774         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
31775         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
31776         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
31777         LDKCVec_u8Z to_counterparty_script_ref;
31778         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
31779         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
31780         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
31781         LDKOutPoint funding_outpoint_conv;
31782         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
31783         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
31784         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
31785         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
31786         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);
31787         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31788         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31789         Transaction_free(ret_var);
31790         return ret_arr;
31791 }
31792
31793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1private_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_secret) {
31794         LDKPublicKey per_commitment_point_ref;
31795         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
31796         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
31797         unsigned char base_secret_arr[32];
31798         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
31799         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
31800         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
31801         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
31802         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
31803         return (uint64_t)ret_conv;
31804 }
31805
31806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_derive_1public_1key(JNIEnv *env, jclass clz, int8_tArray per_commitment_point, int8_tArray base_point) {
31807         LDKPublicKey per_commitment_point_ref;
31808         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
31809         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
31810         LDKPublicKey base_point_ref;
31811         CHECK((*env)->GetArrayLength(env, base_point) == 33);
31812         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
31813         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
31814         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
31815         return (uint64_t)ret_conv;
31816 }
31817
31818 JNIEXPORT int64_t 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) {
31819         unsigned char per_commitment_secret_arr[32];
31820         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
31821         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
31822         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
31823         unsigned char countersignatory_revocation_base_secret_arr[32];
31824         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
31825         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
31826         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
31827         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
31828         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
31829         return (uint64_t)ret_conv;
31830 }
31831
31832 JNIEXPORT int64_t 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) {
31833         LDKPublicKey per_commitment_point_ref;
31834         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
31835         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
31836         LDKPublicKey countersignatory_revocation_base_point_ref;
31837         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
31838         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
31839         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
31840         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
31841         return (uint64_t)ret_conv;
31842 }
31843
31844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31845         LDKTxCreationKeys this_obj_conv;
31846         this_obj_conv.inner = (void*)(this_obj & (~1));
31847         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31849         TxCreationKeys_free(this_obj_conv);
31850 }
31851
31852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31853         LDKTxCreationKeys this_ptr_conv;
31854         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31855         this_ptr_conv.is_owned = false;
31856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31857         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31858         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
31859         return ret_arr;
31860 }
31861
31862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31863         LDKTxCreationKeys this_ptr_conv;
31864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31865         this_ptr_conv.is_owned = false;
31866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31867         LDKPublicKey val_ref;
31868         CHECK((*env)->GetArrayLength(env, val) == 33);
31869         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31870         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
31871 }
31872
31873 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31874         LDKTxCreationKeys this_ptr_conv;
31875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31876         this_ptr_conv.is_owned = false;
31877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31878         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31879         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
31880         return ret_arr;
31881 }
31882
31883 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31884         LDKTxCreationKeys this_ptr_conv;
31885         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31886         this_ptr_conv.is_owned = false;
31887         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31888         LDKPublicKey val_ref;
31889         CHECK((*env)->GetArrayLength(env, val) == 33);
31890         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31891         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
31892 }
31893
31894 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31895         LDKTxCreationKeys this_ptr_conv;
31896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31897         this_ptr_conv.is_owned = false;
31898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31899         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31900         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
31901         return ret_arr;
31902 }
31903
31904 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31905         LDKTxCreationKeys this_ptr_conv;
31906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31907         this_ptr_conv.is_owned = false;
31908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31909         LDKPublicKey val_ref;
31910         CHECK((*env)->GetArrayLength(env, val) == 33);
31911         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31912         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
31913 }
31914
31915 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31916         LDKTxCreationKeys this_ptr_conv;
31917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31918         this_ptr_conv.is_owned = false;
31919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31920         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31921         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
31922         return ret_arr;
31923 }
31924
31925 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31926         LDKTxCreationKeys this_ptr_conv;
31927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31928         this_ptr_conv.is_owned = false;
31929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31930         LDKPublicKey val_ref;
31931         CHECK((*env)->GetArrayLength(env, val) == 33);
31932         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31933         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
31934 }
31935
31936 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31937         LDKTxCreationKeys this_ptr_conv;
31938         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31939         this_ptr_conv.is_owned = false;
31940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31941         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31942         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
31943         return ret_arr;
31944 }
31945
31946 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) {
31947         LDKTxCreationKeys this_ptr_conv;
31948         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31949         this_ptr_conv.is_owned = false;
31950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31951         LDKPublicKey val_ref;
31952         CHECK((*env)->GetArrayLength(env, val) == 33);
31953         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31954         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
31955 }
31956
31957 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) {
31958         LDKPublicKey per_commitment_point_arg_ref;
31959         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
31960         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
31961         LDKPublicKey revocation_key_arg_ref;
31962         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
31963         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
31964         LDKPublicKey broadcaster_htlc_key_arg_ref;
31965         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
31966         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
31967         LDKPublicKey countersignatory_htlc_key_arg_ref;
31968         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
31969         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
31970         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
31971         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
31972         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
31973         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);
31974         uint64_t ret_ref = 0;
31975         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31976         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31977         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31978         ret_ref = (uint64_t)ret_var.inner;
31979         if (ret_var.is_owned) {
31980                 ret_ref |= 1;
31981         }
31982         return ret_ref;
31983 }
31984
31985 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
31986         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
31987 uint64_t ret_ref = 0;
31988 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31989 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31990 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31991 ret_ref = (uint64_t)ret_var.inner;
31992 if (ret_var.is_owned) {
31993         ret_ref |= 1;
31994 }
31995         return ret_ref;
31996 }
31997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31998         LDKTxCreationKeys arg_conv;
31999         arg_conv.inner = (void*)(arg & (~1));
32000         arg_conv.is_owned = false;
32001         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32002         int64_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
32003         return ret_val;
32004 }
32005
32006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32007         LDKTxCreationKeys orig_conv;
32008         orig_conv.inner = (void*)(orig & (~1));
32009         orig_conv.is_owned = false;
32010         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32011         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
32012         uint64_t ret_ref = 0;
32013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32016         ret_ref = (uint64_t)ret_var.inner;
32017         if (ret_var.is_owned) {
32018                 ret_ref |= 1;
32019         }
32020         return ret_ref;
32021 }
32022
32023 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
32024         LDKTxCreationKeys obj_conv;
32025         obj_conv.inner = (void*)(obj & (~1));
32026         obj_conv.is_owned = false;
32027         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32028         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
32029         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32030         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32031         CVec_u8Z_free(ret_var);
32032         return ret_arr;
32033 }
32034
32035 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32036         LDKu8slice ser_ref;
32037         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32038         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32039         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
32040         *ret_conv = TxCreationKeys_read(ser_ref);
32041         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32042         return (uint64_t)ret_conv;
32043 }
32044
32045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32046         LDKChannelPublicKeys this_obj_conv;
32047         this_obj_conv.inner = (void*)(this_obj & (~1));
32048         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32050         ChannelPublicKeys_free(this_obj_conv);
32051 }
32052
32053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32054         LDKChannelPublicKeys this_ptr_conv;
32055         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32056         this_ptr_conv.is_owned = false;
32057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32058         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32059         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
32060         return ret_arr;
32061 }
32062
32063 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32064         LDKChannelPublicKeys this_ptr_conv;
32065         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32066         this_ptr_conv.is_owned = false;
32067         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32068         LDKPublicKey val_ref;
32069         CHECK((*env)->GetArrayLength(env, val) == 33);
32070         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32071         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
32072 }
32073
32074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32075         LDKChannelPublicKeys this_ptr_conv;
32076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32077         this_ptr_conv.is_owned = false;
32078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32079         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32080         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32081         return ret_arr;
32082 }
32083
32084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32085         LDKChannelPublicKeys this_ptr_conv;
32086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32087         this_ptr_conv.is_owned = false;
32088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32089         LDKPublicKey val_ref;
32090         CHECK((*env)->GetArrayLength(env, val) == 33);
32091         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32092         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
32093 }
32094
32095 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32096         LDKChannelPublicKeys this_ptr_conv;
32097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32098         this_ptr_conv.is_owned = false;
32099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32100         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32101         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
32102         return ret_arr;
32103 }
32104
32105 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32106         LDKChannelPublicKeys this_ptr_conv;
32107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32108         this_ptr_conv.is_owned = false;
32109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32110         LDKPublicKey val_ref;
32111         CHECK((*env)->GetArrayLength(env, val) == 33);
32112         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32113         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
32114 }
32115
32116 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32117         LDKChannelPublicKeys this_ptr_conv;
32118         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32119         this_ptr_conv.is_owned = false;
32120         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32121         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32122         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32123         return ret_arr;
32124 }
32125
32126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32127         LDKChannelPublicKeys this_ptr_conv;
32128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32129         this_ptr_conv.is_owned = false;
32130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32131         LDKPublicKey val_ref;
32132         CHECK((*env)->GetArrayLength(env, val) == 33);
32133         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32134         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32135 }
32136
32137 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32138         LDKChannelPublicKeys this_ptr_conv;
32139         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32140         this_ptr_conv.is_owned = false;
32141         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32142         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32143         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32144         return ret_arr;
32145 }
32146
32147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32148         LDKChannelPublicKeys this_ptr_conv;
32149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32150         this_ptr_conv.is_owned = false;
32151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32152         LDKPublicKey val_ref;
32153         CHECK((*env)->GetArrayLength(env, val) == 33);
32154         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32155         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
32156 }
32157
32158 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) {
32159         LDKPublicKey funding_pubkey_arg_ref;
32160         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
32161         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
32162         LDKPublicKey revocation_basepoint_arg_ref;
32163         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
32164         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
32165         LDKPublicKey payment_point_arg_ref;
32166         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
32167         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
32168         LDKPublicKey delayed_payment_basepoint_arg_ref;
32169         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
32170         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
32171         LDKPublicKey htlc_basepoint_arg_ref;
32172         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
32173         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
32174         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);
32175         uint64_t ret_ref = 0;
32176         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32177         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32178         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32179         ret_ref = (uint64_t)ret_var.inner;
32180         if (ret_var.is_owned) {
32181                 ret_ref |= 1;
32182         }
32183         return ret_ref;
32184 }
32185
32186 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
32187         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
32188 uint64_t ret_ref = 0;
32189 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32190 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32191 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32192 ret_ref = (uint64_t)ret_var.inner;
32193 if (ret_var.is_owned) {
32194         ret_ref |= 1;
32195 }
32196         return ret_ref;
32197 }
32198 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32199         LDKChannelPublicKeys arg_conv;
32200         arg_conv.inner = (void*)(arg & (~1));
32201         arg_conv.is_owned = false;
32202         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32203         int64_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
32204         return ret_val;
32205 }
32206
32207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32208         LDKChannelPublicKeys orig_conv;
32209         orig_conv.inner = (void*)(orig & (~1));
32210         orig_conv.is_owned = false;
32211         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32212         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
32213         uint64_t ret_ref = 0;
32214         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32215         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32216         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32217         ret_ref = (uint64_t)ret_var.inner;
32218         if (ret_var.is_owned) {
32219                 ret_ref |= 1;
32220         }
32221         return ret_ref;
32222 }
32223
32224 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
32225         LDKChannelPublicKeys obj_conv;
32226         obj_conv.inner = (void*)(obj & (~1));
32227         obj_conv.is_owned = false;
32228         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32229         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
32230         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32231         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32232         CVec_u8Z_free(ret_var);
32233         return ret_arr;
32234 }
32235
32236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32237         LDKu8slice ser_ref;
32238         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32239         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32240         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
32241         *ret_conv = ChannelPublicKeys_read(ser_ref);
32242         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32243         return (uint64_t)ret_conv;
32244 }
32245
32246 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) {
32247         LDKPublicKey per_commitment_point_ref;
32248         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
32249         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
32250         LDKPublicKey broadcaster_delayed_payment_base_ref;
32251         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
32252         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
32253         LDKPublicKey broadcaster_htlc_base_ref;
32254         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
32255         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
32256         LDKPublicKey countersignatory_revocation_base_ref;
32257         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
32258         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
32259         LDKPublicKey countersignatory_htlc_base_ref;
32260         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
32261         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
32262         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32263         *ret_conv = TxCreationKeys_derive_new(per_commitment_point_ref, broadcaster_delayed_payment_base_ref, broadcaster_htlc_base_ref, countersignatory_revocation_base_ref, countersignatory_htlc_base_ref);
32264         return (uint64_t)ret_conv;
32265 }
32266
32267 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) {
32268         LDKPublicKey per_commitment_point_ref;
32269         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
32270         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
32271         LDKChannelPublicKeys broadcaster_keys_conv;
32272         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
32273         broadcaster_keys_conv.is_owned = false;
32274         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
32275         LDKChannelPublicKeys countersignatory_keys_conv;
32276         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
32277         countersignatory_keys_conv.is_owned = false;
32278         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
32279         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32280         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
32281         return (uint64_t)ret_conv;
32282 }
32283
32284 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) {
32285         LDKPublicKey revocation_key_ref;
32286         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
32287         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
32288         LDKPublicKey broadcaster_delayed_payment_key_ref;
32289         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
32290         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
32291         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
32292         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32293         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32294         CVec_u8Z_free(ret_var);
32295         return ret_arr;
32296 }
32297
32298 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32299         LDKHTLCOutputInCommitment this_obj_conv;
32300         this_obj_conv.inner = (void*)(this_obj & (~1));
32301         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32303         HTLCOutputInCommitment_free(this_obj_conv);
32304 }
32305
32306 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
32307         LDKHTLCOutputInCommitment this_ptr_conv;
32308         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32309         this_ptr_conv.is_owned = false;
32310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32311         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
32312         return ret_val;
32313 }
32314
32315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32316         LDKHTLCOutputInCommitment this_ptr_conv;
32317         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32318         this_ptr_conv.is_owned = false;
32319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32320         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
32321 }
32322
32323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32324         LDKHTLCOutputInCommitment this_ptr_conv;
32325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32326         this_ptr_conv.is_owned = false;
32327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32328         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
32329         return ret_val;
32330 }
32331
32332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32333         LDKHTLCOutputInCommitment this_ptr_conv;
32334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32335         this_ptr_conv.is_owned = false;
32336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32337         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
32338 }
32339
32340 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
32341         LDKHTLCOutputInCommitment this_ptr_conv;
32342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32343         this_ptr_conv.is_owned = false;
32344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32345         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
32346         return ret_val;
32347 }
32348
32349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32350         LDKHTLCOutputInCommitment this_ptr_conv;
32351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32352         this_ptr_conv.is_owned = false;
32353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32354         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
32355 }
32356
32357 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32358         LDKHTLCOutputInCommitment this_ptr_conv;
32359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32360         this_ptr_conv.is_owned = false;
32361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32362         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32363         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
32364         return ret_arr;
32365 }
32366
32367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32368         LDKHTLCOutputInCommitment this_ptr_conv;
32369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32370         this_ptr_conv.is_owned = false;
32371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32372         LDKThirtyTwoBytes val_ref;
32373         CHECK((*env)->GetArrayLength(env, val) == 32);
32374         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32375         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
32376 }
32377
32378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
32379         LDKHTLCOutputInCommitment this_ptr_conv;
32380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32381         this_ptr_conv.is_owned = false;
32382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32383         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32384         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
32385         uint64_t ret_ref = (uint64_t)ret_copy;
32386         return ret_ref;
32387 }
32388
32389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32390         LDKHTLCOutputInCommitment this_ptr_conv;
32391         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32392         this_ptr_conv.is_owned = false;
32393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32394         void* val_ptr = (void*)(((uint64_t)val) & ~1);
32395         CHECK_ACCESS(val_ptr);
32396         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32397         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
32398         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
32399 }
32400
32401 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) {
32402         LDKThirtyTwoBytes payment_hash_arg_ref;
32403         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
32404         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
32405         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
32406         CHECK_ACCESS(transaction_output_index_arg_ptr);
32407         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
32408         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
32409         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
32410         uint64_t ret_ref = 0;
32411         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32412         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32413         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32414         ret_ref = (uint64_t)ret_var.inner;
32415         if (ret_var.is_owned) {
32416                 ret_ref |= 1;
32417         }
32418         return ret_ref;
32419 }
32420
32421 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
32422         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
32423 uint64_t ret_ref = 0;
32424 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32425 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32426 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32427 ret_ref = (uint64_t)ret_var.inner;
32428 if (ret_var.is_owned) {
32429         ret_ref |= 1;
32430 }
32431         return ret_ref;
32432 }
32433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32434         LDKHTLCOutputInCommitment arg_conv;
32435         arg_conv.inner = (void*)(arg & (~1));
32436         arg_conv.is_owned = false;
32437         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32438         int64_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
32439         return ret_val;
32440 }
32441
32442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32443         LDKHTLCOutputInCommitment orig_conv;
32444         orig_conv.inner = (void*)(orig & (~1));
32445         orig_conv.is_owned = false;
32446         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32447         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
32448         uint64_t ret_ref = 0;
32449         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32450         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32451         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32452         ret_ref = (uint64_t)ret_var.inner;
32453         if (ret_var.is_owned) {
32454                 ret_ref |= 1;
32455         }
32456         return ret_ref;
32457 }
32458
32459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
32460         LDKHTLCOutputInCommitment obj_conv;
32461         obj_conv.inner = (void*)(obj & (~1));
32462         obj_conv.is_owned = false;
32463         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32464         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
32465         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32466         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32467         CVec_u8Z_free(ret_var);
32468         return ret_arr;
32469 }
32470
32471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32472         LDKu8slice ser_ref;
32473         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32474         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32475         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
32476         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
32477         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32478         return (uint64_t)ret_conv;
32479 }
32480
32481 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
32482         LDKHTLCOutputInCommitment htlc_conv;
32483         htlc_conv.inner = (void*)(htlc & (~1));
32484         htlc_conv.is_owned = false;
32485         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
32486         LDKTxCreationKeys keys_conv;
32487         keys_conv.inner = (void*)(keys & (~1));
32488         keys_conv.is_owned = false;
32489         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
32490         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
32491         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32492         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32493         CVec_u8Z_free(ret_var);
32494         return ret_arr;
32495 }
32496
32497 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
32498         LDKPublicKey broadcaster_ref;
32499         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
32500         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
32501         LDKPublicKey countersignatory_ref;
32502         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
32503         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
32504         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
32505         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32506         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32507         CVec_u8Z_free(ret_var);
32508         return ret_arr;
32509 }
32510
32511 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, int8_tArray broadcaster_delayed_payment_key, int8_tArray revocation_key) {
32512         unsigned char commitment_txid_arr[32];
32513         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
32514         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
32515         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
32516         LDKHTLCOutputInCommitment htlc_conv;
32517         htlc_conv.inner = (void*)(htlc & (~1));
32518         htlc_conv.is_owned = false;
32519         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
32520         LDKPublicKey broadcaster_delayed_payment_key_ref;
32521         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
32522         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
32523         LDKPublicKey revocation_key_ref;
32524         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
32525         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
32526         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
32527         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32528         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32529         Transaction_free(ret_var);
32530         return ret_arr;
32531 }
32532
32533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32534         LDKChannelTransactionParameters this_obj_conv;
32535         this_obj_conv.inner = (void*)(this_obj & (~1));
32536         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32537         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32538         ChannelTransactionParameters_free(this_obj_conv);
32539 }
32540
32541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
32542         LDKChannelTransactionParameters this_ptr_conv;
32543         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32544         this_ptr_conv.is_owned = false;
32545         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32546         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
32547         uint64_t ret_ref = 0;
32548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32551         ret_ref = (uint64_t)ret_var.inner;
32552         if (ret_var.is_owned) {
32553                 ret_ref |= 1;
32554         }
32555         return ret_ref;
32556 }
32557
32558 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32559         LDKChannelTransactionParameters this_ptr_conv;
32560         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32561         this_ptr_conv.is_owned = false;
32562         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32563         LDKChannelPublicKeys val_conv;
32564         val_conv.inner = (void*)(val & (~1));
32565         val_conv.is_owned = (val & 1) || (val == 0);
32566         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32567         val_conv = ChannelPublicKeys_clone(&val_conv);
32568         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
32569 }
32570
32571 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32572         LDKChannelTransactionParameters this_ptr_conv;
32573         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32574         this_ptr_conv.is_owned = false;
32575         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32576         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
32577         return ret_val;
32578 }
32579
32580 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) {
32581         LDKChannelTransactionParameters this_ptr_conv;
32582         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32583         this_ptr_conv.is_owned = false;
32584         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32585         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
32586 }
32587
32588 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
32589         LDKChannelTransactionParameters this_ptr_conv;
32590         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32591         this_ptr_conv.is_owned = false;
32592         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32593         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
32594         return ret_val;
32595 }
32596
32597 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32598         LDKChannelTransactionParameters this_ptr_conv;
32599         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32600         this_ptr_conv.is_owned = false;
32601         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32602         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
32603 }
32604
32605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
32606         LDKChannelTransactionParameters this_ptr_conv;
32607         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32608         this_ptr_conv.is_owned = false;
32609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32610         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
32611         uint64_t ret_ref = 0;
32612         if ((uint64_t)ret_var.inner > 4096) {
32613                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32614                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32615         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32616                 ret_ref = (uint64_t)ret_var.inner;
32617                 if (ret_var.is_owned) {
32618                         ret_ref |= 1;
32619                 }
32620         }
32621         return ret_ref;
32622 }
32623
32624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32625         LDKChannelTransactionParameters this_ptr_conv;
32626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32627         this_ptr_conv.is_owned = false;
32628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32629         LDKCounterpartyChannelTransactionParameters val_conv;
32630         val_conv.inner = (void*)(val & (~1));
32631         val_conv.is_owned = (val & 1) || (val == 0);
32632         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32633         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
32634         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
32635 }
32636
32637 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32638         LDKChannelTransactionParameters this_ptr_conv;
32639         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32640         this_ptr_conv.is_owned = false;
32641         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32642         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
32643         uint64_t ret_ref = 0;
32644         if ((uint64_t)ret_var.inner > 4096) {
32645                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32646                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32648                 ret_ref = (uint64_t)ret_var.inner;
32649                 if (ret_var.is_owned) {
32650                         ret_ref |= 1;
32651                 }
32652         }
32653         return ret_ref;
32654 }
32655
32656 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32657         LDKChannelTransactionParameters this_ptr_conv;
32658         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32659         this_ptr_conv.is_owned = false;
32660         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32661         LDKOutPoint val_conv;
32662         val_conv.inner = (void*)(val & (~1));
32663         val_conv.is_owned = (val & 1) || (val == 0);
32664         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32665         val_conv = OutPoint_clone(&val_conv);
32666         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
32667 }
32668
32669 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) {
32670         LDKChannelPublicKeys holder_pubkeys_arg_conv;
32671         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
32672         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
32673         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
32674         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
32675         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
32676         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
32677         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
32678         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
32679         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
32680         LDKOutPoint funding_outpoint_arg_conv;
32681         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
32682         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
32683         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
32684         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
32685         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);
32686         uint64_t ret_ref = 0;
32687         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32688         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32689         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32690         ret_ref = (uint64_t)ret_var.inner;
32691         if (ret_var.is_owned) {
32692                 ret_ref |= 1;
32693         }
32694         return ret_ref;
32695 }
32696
32697 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
32698         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
32699 uint64_t ret_ref = 0;
32700 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32701 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32702 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32703 ret_ref = (uint64_t)ret_var.inner;
32704 if (ret_var.is_owned) {
32705         ret_ref |= 1;
32706 }
32707         return ret_ref;
32708 }
32709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32710         LDKChannelTransactionParameters arg_conv;
32711         arg_conv.inner = (void*)(arg & (~1));
32712         arg_conv.is_owned = false;
32713         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32714         int64_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
32715         return ret_val;
32716 }
32717
32718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32719         LDKChannelTransactionParameters orig_conv;
32720         orig_conv.inner = (void*)(orig & (~1));
32721         orig_conv.is_owned = false;
32722         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32723         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
32724         uint64_t ret_ref = 0;
32725         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32726         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32727         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32728         ret_ref = (uint64_t)ret_var.inner;
32729         if (ret_var.is_owned) {
32730                 ret_ref |= 1;
32731         }
32732         return ret_ref;
32733 }
32734
32735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32736         LDKCounterpartyChannelTransactionParameters this_obj_conv;
32737         this_obj_conv.inner = (void*)(this_obj & (~1));
32738         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32740         CounterpartyChannelTransactionParameters_free(this_obj_conv);
32741 }
32742
32743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
32744         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
32745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32746         this_ptr_conv.is_owned = false;
32747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32748         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
32749         uint64_t ret_ref = 0;
32750         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32751         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32752         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32753         ret_ref = (uint64_t)ret_var.inner;
32754         if (ret_var.is_owned) {
32755                 ret_ref |= 1;
32756         }
32757         return ret_ref;
32758 }
32759
32760 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32761         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
32762         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32763         this_ptr_conv.is_owned = false;
32764         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32765         LDKChannelPublicKeys val_conv;
32766         val_conv.inner = (void*)(val & (~1));
32767         val_conv.is_owned = (val & 1) || (val == 0);
32768         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32769         val_conv = ChannelPublicKeys_clone(&val_conv);
32770         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
32771 }
32772
32773 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32774         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
32775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32776         this_ptr_conv.is_owned = false;
32777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32778         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
32779         return ret_val;
32780 }
32781
32782 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32783         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
32784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32785         this_ptr_conv.is_owned = false;
32786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32787         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
32788 }
32789
32790 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) {
32791         LDKChannelPublicKeys pubkeys_arg_conv;
32792         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
32793         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
32794         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
32795         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
32796         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
32797         uint64_t ret_ref = 0;
32798         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32799         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32800         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32801         ret_ref = (uint64_t)ret_var.inner;
32802         if (ret_var.is_owned) {
32803                 ret_ref |= 1;
32804         }
32805         return ret_ref;
32806 }
32807
32808 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
32809         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
32810 uint64_t ret_ref = 0;
32811 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32812 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32813 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32814 ret_ref = (uint64_t)ret_var.inner;
32815 if (ret_var.is_owned) {
32816         ret_ref |= 1;
32817 }
32818         return ret_ref;
32819 }
32820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32821         LDKCounterpartyChannelTransactionParameters arg_conv;
32822         arg_conv.inner = (void*)(arg & (~1));
32823         arg_conv.is_owned = false;
32824         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32825         int64_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
32826         return ret_val;
32827 }
32828
32829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32830         LDKCounterpartyChannelTransactionParameters orig_conv;
32831         orig_conv.inner = (void*)(orig & (~1));
32832         orig_conv.is_owned = false;
32833         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32834         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
32835         uint64_t ret_ref = 0;
32836         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32837         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32839         ret_ref = (uint64_t)ret_var.inner;
32840         if (ret_var.is_owned) {
32841                 ret_ref |= 1;
32842         }
32843         return ret_ref;
32844 }
32845
32846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
32847         LDKChannelTransactionParameters this_arg_conv;
32848         this_arg_conv.inner = (void*)(this_arg & (~1));
32849         this_arg_conv.is_owned = false;
32850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32851         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
32852         return ret_val;
32853 }
32854
32855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
32856         LDKChannelTransactionParameters this_arg_conv;
32857         this_arg_conv.inner = (void*)(this_arg & (~1));
32858         this_arg_conv.is_owned = false;
32859         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32860         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
32861         uint64_t ret_ref = 0;
32862         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32863         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32864         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32865         ret_ref = (uint64_t)ret_var.inner;
32866         if (ret_var.is_owned) {
32867                 ret_ref |= 1;
32868         }
32869         return ret_ref;
32870 }
32871
32872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
32873         LDKChannelTransactionParameters this_arg_conv;
32874         this_arg_conv.inner = (void*)(this_arg & (~1));
32875         this_arg_conv.is_owned = false;
32876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32877         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
32878         uint64_t ret_ref = 0;
32879         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32880         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32881         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32882         ret_ref = (uint64_t)ret_var.inner;
32883         if (ret_var.is_owned) {
32884                 ret_ref |= 1;
32885         }
32886         return ret_ref;
32887 }
32888
32889 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
32890         LDKCounterpartyChannelTransactionParameters obj_conv;
32891         obj_conv.inner = (void*)(obj & (~1));
32892         obj_conv.is_owned = false;
32893         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32894         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
32895         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32896         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32897         CVec_u8Z_free(ret_var);
32898         return ret_arr;
32899 }
32900
32901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32902         LDKu8slice ser_ref;
32903         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32904         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32905         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
32906         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
32907         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32908         return (uint64_t)ret_conv;
32909 }
32910
32911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
32912         LDKChannelTransactionParameters obj_conv;
32913         obj_conv.inner = (void*)(obj & (~1));
32914         obj_conv.is_owned = false;
32915         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32916         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
32917         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32918         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32919         CVec_u8Z_free(ret_var);
32920         return ret_arr;
32921 }
32922
32923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32924         LDKu8slice ser_ref;
32925         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32926         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32927         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
32928         *ret_conv = ChannelTransactionParameters_read(ser_ref);
32929         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32930         return (uint64_t)ret_conv;
32931 }
32932
32933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32934         LDKDirectedChannelTransactionParameters this_obj_conv;
32935         this_obj_conv.inner = (void*)(this_obj & (~1));
32936         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32938         DirectedChannelTransactionParameters_free(this_obj_conv);
32939 }
32940
32941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
32942         LDKDirectedChannelTransactionParameters this_arg_conv;
32943         this_arg_conv.inner = (void*)(this_arg & (~1));
32944         this_arg_conv.is_owned = false;
32945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32946         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
32947         uint64_t ret_ref = 0;
32948         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32949         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32950         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32951         ret_ref = (uint64_t)ret_var.inner;
32952         if (ret_var.is_owned) {
32953                 ret_ref |= 1;
32954         }
32955         return ret_ref;
32956 }
32957
32958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
32959         LDKDirectedChannelTransactionParameters this_arg_conv;
32960         this_arg_conv.inner = (void*)(this_arg & (~1));
32961         this_arg_conv.is_owned = false;
32962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32963         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
32964         uint64_t ret_ref = 0;
32965         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32966         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32968         ret_ref = (uint64_t)ret_var.inner;
32969         if (ret_var.is_owned) {
32970                 ret_ref |= 1;
32971         }
32972         return ret_ref;
32973 }
32974
32975 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
32976         LDKDirectedChannelTransactionParameters this_arg_conv;
32977         this_arg_conv.inner = (void*)(this_arg & (~1));
32978         this_arg_conv.is_owned = false;
32979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32980         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
32981         return ret_val;
32982 }
32983
32984 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
32985         LDKDirectedChannelTransactionParameters this_arg_conv;
32986         this_arg_conv.inner = (void*)(this_arg & (~1));
32987         this_arg_conv.is_owned = false;
32988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32989         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
32990         return ret_val;
32991 }
32992
32993 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
32994         LDKDirectedChannelTransactionParameters this_arg_conv;
32995         this_arg_conv.inner = (void*)(this_arg & (~1));
32996         this_arg_conv.is_owned = false;
32997         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32998         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
32999         uint64_t ret_ref = 0;
33000         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33001         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33002         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33003         ret_ref = (uint64_t)ret_var.inner;
33004         if (ret_var.is_owned) {
33005                 ret_ref |= 1;
33006         }
33007         return ret_ref;
33008 }
33009
33010 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33011         LDKHolderCommitmentTransaction this_obj_conv;
33012         this_obj_conv.inner = (void*)(this_obj & (~1));
33013         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33015         HolderCommitmentTransaction_free(this_obj_conv);
33016 }
33017
33018 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
33019         LDKHolderCommitmentTransaction this_ptr_conv;
33020         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33021         this_ptr_conv.is_owned = false;
33022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33023         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33024         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
33025         return ret_arr;
33026 }
33027
33028 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33029         LDKHolderCommitmentTransaction this_ptr_conv;
33030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33031         this_ptr_conv.is_owned = false;
33032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33033         LDKSignature val_ref;
33034         CHECK((*env)->GetArrayLength(env, val) == 64);
33035         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33036         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
33037 }
33038
33039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
33040         LDKHolderCommitmentTransaction this_ptr_conv;
33041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33042         this_ptr_conv.is_owned = false;
33043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33044         LDKCVec_SignatureZ val_constr;
33045         val_constr.datalen = (*env)->GetArrayLength(env, val);
33046         if (val_constr.datalen > 0)
33047                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33048         else
33049                 val_constr.data = NULL;
33050         for (size_t i = 0; i < val_constr.datalen; i++) {
33051                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
33052                 LDKSignature val_conv_8_ref;
33053                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
33054                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
33055                 val_constr.data[i] = val_conv_8_ref;
33056         }
33057         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
33058 }
33059
33060 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
33061         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
33062 uint64_t ret_ref = 0;
33063 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33064 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33065 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33066 ret_ref = (uint64_t)ret_var.inner;
33067 if (ret_var.is_owned) {
33068         ret_ref |= 1;
33069 }
33070         return ret_ref;
33071 }
33072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33073         LDKHolderCommitmentTransaction arg_conv;
33074         arg_conv.inner = (void*)(arg & (~1));
33075         arg_conv.is_owned = false;
33076         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33077         int64_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
33078         return ret_val;
33079 }
33080
33081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33082         LDKHolderCommitmentTransaction orig_conv;
33083         orig_conv.inner = (void*)(orig & (~1));
33084         orig_conv.is_owned = false;
33085         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33086         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
33087         uint64_t ret_ref = 0;
33088         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33089         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33090         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33091         ret_ref = (uint64_t)ret_var.inner;
33092         if (ret_var.is_owned) {
33093                 ret_ref |= 1;
33094         }
33095         return ret_ref;
33096 }
33097
33098 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
33099         LDKHolderCommitmentTransaction obj_conv;
33100         obj_conv.inner = (void*)(obj & (~1));
33101         obj_conv.is_owned = false;
33102         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33103         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
33104         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33105         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33106         CVec_u8Z_free(ret_var);
33107         return ret_arr;
33108 }
33109
33110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33111         LDKu8slice ser_ref;
33112         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33113         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33114         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
33115         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
33116         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33117         return (uint64_t)ret_conv;
33118 }
33119
33120 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) {
33121         LDKCommitmentTransaction commitment_tx_conv;
33122         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
33123         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
33124         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
33125         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
33126         LDKSignature counterparty_sig_ref;
33127         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
33128         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
33129         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
33130         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
33131         if (counterparty_htlc_sigs_constr.datalen > 0)
33132                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33133         else
33134                 counterparty_htlc_sigs_constr.data = NULL;
33135         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
33136                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
33137                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
33138                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
33139                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
33140                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
33141         }
33142         LDKPublicKey holder_funding_key_ref;
33143         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
33144         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
33145         LDKPublicKey counterparty_funding_key_ref;
33146         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
33147         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
33148         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
33149         uint64_t ret_ref = 0;
33150         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33151         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33152         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33153         ret_ref = (uint64_t)ret_var.inner;
33154         if (ret_var.is_owned) {
33155                 ret_ref |= 1;
33156         }
33157         return ret_ref;
33158 }
33159
33160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33161         LDKBuiltCommitmentTransaction this_obj_conv;
33162         this_obj_conv.inner = (void*)(this_obj & (~1));
33163         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33165         BuiltCommitmentTransaction_free(this_obj_conv);
33166 }
33167
33168 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
33169         LDKBuiltCommitmentTransaction this_ptr_conv;
33170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33171         this_ptr_conv.is_owned = false;
33172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33173         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
33174         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33175         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33176         Transaction_free(ret_var);
33177         return ret_arr;
33178 }
33179
33180 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33181         LDKBuiltCommitmentTransaction this_ptr_conv;
33182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33183         this_ptr_conv.is_owned = false;
33184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33185         LDKTransaction val_ref;
33186         val_ref.datalen = (*env)->GetArrayLength(env, val);
33187         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
33188         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
33189         val_ref.data_is_owned = true;
33190         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
33191 }
33192
33193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33194         LDKBuiltCommitmentTransaction this_ptr_conv;
33195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33196         this_ptr_conv.is_owned = false;
33197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33198         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
33200         return ret_arr;
33201 }
33202
33203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33204         LDKBuiltCommitmentTransaction this_ptr_conv;
33205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33206         this_ptr_conv.is_owned = false;
33207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33208         LDKThirtyTwoBytes val_ref;
33209         CHECK((*env)->GetArrayLength(env, val) == 32);
33210         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33211         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
33212 }
33213
33214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
33215         LDKTransaction transaction_arg_ref;
33216         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
33217         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
33218         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
33219         transaction_arg_ref.data_is_owned = true;
33220         LDKThirtyTwoBytes txid_arg_ref;
33221         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
33222         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
33223         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
33224         uint64_t ret_ref = 0;
33225         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33226         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33227         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33228         ret_ref = (uint64_t)ret_var.inner;
33229         if (ret_var.is_owned) {
33230                 ret_ref |= 1;
33231         }
33232         return ret_ref;
33233 }
33234
33235 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
33236         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
33237 uint64_t ret_ref = 0;
33238 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33239 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33240 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33241 ret_ref = (uint64_t)ret_var.inner;
33242 if (ret_var.is_owned) {
33243         ret_ref |= 1;
33244 }
33245         return ret_ref;
33246 }
33247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33248         LDKBuiltCommitmentTransaction arg_conv;
33249         arg_conv.inner = (void*)(arg & (~1));
33250         arg_conv.is_owned = false;
33251         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33252         int64_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
33253         return ret_val;
33254 }
33255
33256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33257         LDKBuiltCommitmentTransaction orig_conv;
33258         orig_conv.inner = (void*)(orig & (~1));
33259         orig_conv.is_owned = false;
33260         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33261         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
33262         uint64_t ret_ref = 0;
33263         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33264         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33266         ret_ref = (uint64_t)ret_var.inner;
33267         if (ret_var.is_owned) {
33268                 ret_ref |= 1;
33269         }
33270         return ret_ref;
33271 }
33272
33273 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
33274         LDKBuiltCommitmentTransaction obj_conv;
33275         obj_conv.inner = (void*)(obj & (~1));
33276         obj_conv.is_owned = false;
33277         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33278         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
33279         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33280         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33281         CVec_u8Z_free(ret_var);
33282         return ret_arr;
33283 }
33284
33285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33286         LDKu8slice ser_ref;
33287         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33288         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33289         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
33290         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
33291         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33292         return (uint64_t)ret_conv;
33293 }
33294
33295 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) {
33296         LDKBuiltCommitmentTransaction this_arg_conv;
33297         this_arg_conv.inner = (void*)(this_arg & (~1));
33298         this_arg_conv.is_owned = false;
33299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33300         LDKu8slice funding_redeemscript_ref;
33301         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
33302         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
33303         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33304         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
33305         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
33306         return ret_arr;
33307 }
33308
33309 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1sign(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray funding_key, int8_tArray funding_redeemscript, int64_t channel_value_satoshis) {
33310         LDKBuiltCommitmentTransaction this_arg_conv;
33311         this_arg_conv.inner = (void*)(this_arg & (~1));
33312         this_arg_conv.is_owned = false;
33313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33314         unsigned char funding_key_arr[32];
33315         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
33316         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
33317         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
33318         LDKu8slice funding_redeemscript_ref;
33319         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
33320         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
33321         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33322         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
33323         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
33324         return ret_arr;
33325 }
33326
33327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33328         LDKClosingTransaction this_obj_conv;
33329         this_obj_conv.inner = (void*)(this_obj & (~1));
33330         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33332         ClosingTransaction_free(this_obj_conv);
33333 }
33334
33335 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
33336         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
33337 uint64_t ret_ref = 0;
33338 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33339 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33340 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33341 ret_ref = (uint64_t)ret_var.inner;
33342 if (ret_var.is_owned) {
33343         ret_ref |= 1;
33344 }
33345         return ret_ref;
33346 }
33347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33348         LDKClosingTransaction arg_conv;
33349         arg_conv.inner = (void*)(arg & (~1));
33350         arg_conv.is_owned = false;
33351         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33352         int64_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
33353         return ret_val;
33354 }
33355
33356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33357         LDKClosingTransaction orig_conv;
33358         orig_conv.inner = (void*)(orig & (~1));
33359         orig_conv.is_owned = false;
33360         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33361         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
33362         uint64_t ret_ref = 0;
33363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33366         ret_ref = (uint64_t)ret_var.inner;
33367         if (ret_var.is_owned) {
33368                 ret_ref |= 1;
33369         }
33370         return ret_ref;
33371 }
33372
33373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
33374         LDKClosingTransaction o_conv;
33375         o_conv.inner = (void*)(o & (~1));
33376         o_conv.is_owned = false;
33377         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33378         int64_t ret_val = ClosingTransaction_hash(&o_conv);
33379         return ret_val;
33380 }
33381
33382 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) {
33383         LDKCVec_u8Z to_holder_script_ref;
33384         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
33385         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
33386         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
33387         LDKCVec_u8Z to_counterparty_script_ref;
33388         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
33389         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
33390         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
33391         LDKOutPoint funding_outpoint_conv;
33392         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
33393         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
33394         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
33395         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
33396         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
33397         uint64_t ret_ref = 0;
33398         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33399         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33400         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33401         ret_ref = (uint64_t)ret_var.inner;
33402         if (ret_var.is_owned) {
33403                 ret_ref |= 1;
33404         }
33405         return ret_ref;
33406 }
33407
33408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
33409         LDKClosingTransaction this_arg_conv;
33410         this_arg_conv.inner = (void*)(this_arg & (~1));
33411         this_arg_conv.is_owned = false;
33412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33413         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
33414         uint64_t ret_ref = 0;
33415         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33416         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33417         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33418         ret_ref = (uint64_t)ret_var.inner;
33419         if (ret_var.is_owned) {
33420                 ret_ref |= 1;
33421         }
33422         return ret_ref;
33423 }
33424
33425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
33426         LDKClosingTransaction this_arg_conv;
33427         this_arg_conv.inner = (void*)(this_arg & (~1));
33428         this_arg_conv.is_owned = false;
33429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33430         LDKOutPoint funding_outpoint_conv;
33431         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
33432         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
33433         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
33434         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
33435         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
33436         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
33437         return (uint64_t)ret_conv;
33438 }
33439
33440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
33441         LDKClosingTransaction this_arg_conv;
33442         this_arg_conv.inner = (void*)(this_arg & (~1));
33443         this_arg_conv.is_owned = false;
33444         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33445         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
33446         return ret_val;
33447 }
33448
33449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
33450         LDKClosingTransaction this_arg_conv;
33451         this_arg_conv.inner = (void*)(this_arg & (~1));
33452         this_arg_conv.is_owned = false;
33453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33454         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
33455         return ret_val;
33456 }
33457
33458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
33459         LDKClosingTransaction this_arg_conv;
33460         this_arg_conv.inner = (void*)(this_arg & (~1));
33461         this_arg_conv.is_owned = false;
33462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33463         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
33464         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33465         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33466         return ret_arr;
33467 }
33468
33469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
33470         LDKClosingTransaction this_arg_conv;
33471         this_arg_conv.inner = (void*)(this_arg & (~1));
33472         this_arg_conv.is_owned = false;
33473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33474         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
33475         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33476         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33477         return ret_arr;
33478 }
33479
33480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33481         LDKTrustedClosingTransaction this_obj_conv;
33482         this_obj_conv.inner = (void*)(this_obj & (~1));
33483         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33485         TrustedClosingTransaction_free(this_obj_conv);
33486 }
33487
33488 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
33489         LDKTrustedClosingTransaction this_arg_conv;
33490         this_arg_conv.inner = (void*)(this_arg & (~1));
33491         this_arg_conv.is_owned = false;
33492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33493         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
33494         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33495         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33496         Transaction_free(ret_var);
33497         return ret_arr;
33498 }
33499
33500 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) {
33501         LDKTrustedClosingTransaction this_arg_conv;
33502         this_arg_conv.inner = (void*)(this_arg & (~1));
33503         this_arg_conv.is_owned = false;
33504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33505         LDKu8slice funding_redeemscript_ref;
33506         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
33507         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
33508         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33509         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
33510         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
33511         return ret_arr;
33512 }
33513
33514 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) {
33515         LDKTrustedClosingTransaction this_arg_conv;
33516         this_arg_conv.inner = (void*)(this_arg & (~1));
33517         this_arg_conv.is_owned = false;
33518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33519         unsigned char funding_key_arr[32];
33520         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
33521         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
33522         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
33523         LDKu8slice funding_redeemscript_ref;
33524         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
33525         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
33526         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33527         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
33528         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
33529         return ret_arr;
33530 }
33531
33532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33533         LDKCommitmentTransaction this_obj_conv;
33534         this_obj_conv.inner = (void*)(this_obj & (~1));
33535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33537         CommitmentTransaction_free(this_obj_conv);
33538 }
33539
33540 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
33541         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
33542 uint64_t ret_ref = 0;
33543 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33544 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33545 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33546 ret_ref = (uint64_t)ret_var.inner;
33547 if (ret_var.is_owned) {
33548         ret_ref |= 1;
33549 }
33550         return ret_ref;
33551 }
33552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33553         LDKCommitmentTransaction arg_conv;
33554         arg_conv.inner = (void*)(arg & (~1));
33555         arg_conv.is_owned = false;
33556         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33557         int64_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
33558         return ret_val;
33559 }
33560
33561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33562         LDKCommitmentTransaction orig_conv;
33563         orig_conv.inner = (void*)(orig & (~1));
33564         orig_conv.is_owned = false;
33565         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33566         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
33567         uint64_t ret_ref = 0;
33568         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33569         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33570         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33571         ret_ref = (uint64_t)ret_var.inner;
33572         if (ret_var.is_owned) {
33573                 ret_ref |= 1;
33574         }
33575         return ret_ref;
33576 }
33577
33578 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
33579         LDKCommitmentTransaction obj_conv;
33580         obj_conv.inner = (void*)(obj & (~1));
33581         obj_conv.is_owned = false;
33582         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33583         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
33584         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33585         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33586         CVec_u8Z_free(ret_var);
33587         return ret_arr;
33588 }
33589
33590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33591         LDKu8slice ser_ref;
33592         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33593         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33594         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
33595         *ret_conv = CommitmentTransaction_read(ser_ref);
33596         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33597         return (uint64_t)ret_conv;
33598 }
33599
33600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
33601         LDKCommitmentTransaction this_arg_conv;
33602         this_arg_conv.inner = (void*)(this_arg & (~1));
33603         this_arg_conv.is_owned = false;
33604         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33605         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
33606         return ret_val;
33607 }
33608
33609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
33610         LDKCommitmentTransaction this_arg_conv;
33611         this_arg_conv.inner = (void*)(this_arg & (~1));
33612         this_arg_conv.is_owned = false;
33613         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33614         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
33615         return ret_val;
33616 }
33617
33618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
33619         LDKCommitmentTransaction this_arg_conv;
33620         this_arg_conv.inner = (void*)(this_arg & (~1));
33621         this_arg_conv.is_owned = false;
33622         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33623         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
33624         return ret_val;
33625 }
33626
33627 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
33628         LDKCommitmentTransaction this_arg_conv;
33629         this_arg_conv.inner = (void*)(this_arg & (~1));
33630         this_arg_conv.is_owned = false;
33631         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33632         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
33633         return ret_val;
33634 }
33635
33636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
33637         LDKCommitmentTransaction this_arg_conv;
33638         this_arg_conv.inner = (void*)(this_arg & (~1));
33639         this_arg_conv.is_owned = false;
33640         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33641         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
33642         uint64_t ret_ref = 0;
33643         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33644         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33645         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33646         ret_ref = (uint64_t)ret_var.inner;
33647         if (ret_var.is_owned) {
33648                 ret_ref |= 1;
33649         }
33650         return ret_ref;
33651 }
33652
33653 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) {
33654         LDKCommitmentTransaction this_arg_conv;
33655         this_arg_conv.inner = (void*)(this_arg & (~1));
33656         this_arg_conv.is_owned = false;
33657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33658         LDKDirectedChannelTransactionParameters channel_parameters_conv;
33659         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
33660         channel_parameters_conv.is_owned = false;
33661         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
33662         LDKChannelPublicKeys broadcaster_keys_conv;
33663         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
33664         broadcaster_keys_conv.is_owned = false;
33665         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
33666         LDKChannelPublicKeys countersignatory_keys_conv;
33667         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
33668         countersignatory_keys_conv.is_owned = false;
33669         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
33670         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
33671         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
33672         return (uint64_t)ret_conv;
33673 }
33674
33675 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33676         LDKTrustedCommitmentTransaction this_obj_conv;
33677         this_obj_conv.inner = (void*)(this_obj & (~1));
33678         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33680         TrustedCommitmentTransaction_free(this_obj_conv);
33681 }
33682
33683 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
33684         LDKTrustedCommitmentTransaction this_arg_conv;
33685         this_arg_conv.inner = (void*)(this_arg & (~1));
33686         this_arg_conv.is_owned = false;
33687         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33688         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33689         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
33690         return ret_arr;
33691 }
33692
33693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
33694         LDKTrustedCommitmentTransaction this_arg_conv;
33695         this_arg_conv.inner = (void*)(this_arg & (~1));
33696         this_arg_conv.is_owned = false;
33697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33698         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
33699         uint64_t ret_ref = 0;
33700         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33701         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33702         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33703         ret_ref = (uint64_t)ret_var.inner;
33704         if (ret_var.is_owned) {
33705                 ret_ref |= 1;
33706         }
33707         return ret_ref;
33708 }
33709
33710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
33711         LDKTrustedCommitmentTransaction this_arg_conv;
33712         this_arg_conv.inner = (void*)(this_arg & (~1));
33713         this_arg_conv.is_owned = false;
33714         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33715         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
33716         uint64_t ret_ref = 0;
33717         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33718         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33719         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33720         ret_ref = (uint64_t)ret_var.inner;
33721         if (ret_var.is_owned) {
33722                 ret_ref |= 1;
33723         }
33724         return ret_ref;
33725 }
33726
33727 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) {
33728         LDKTrustedCommitmentTransaction this_arg_conv;
33729         this_arg_conv.inner = (void*)(this_arg & (~1));
33730         this_arg_conv.is_owned = false;
33731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33732         unsigned char htlc_base_key_arr[32];
33733         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
33734         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
33735         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
33736         LDKDirectedChannelTransactionParameters channel_parameters_conv;
33737         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
33738         channel_parameters_conv.is_owned = false;
33739         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
33740         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
33741         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
33742         return (uint64_t)ret_conv;
33743 }
33744
33745 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) {
33746         LDKPublicKey broadcaster_payment_basepoint_ref;
33747         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
33748         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
33749         LDKPublicKey countersignatory_payment_basepoint_ref;
33750         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
33751         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
33752         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
33753         return ret_val;
33754 }
33755
33756 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33757         LDKInitFeatures a_conv;
33758         a_conv.inner = (void*)(a & (~1));
33759         a_conv.is_owned = false;
33760         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33761         LDKInitFeatures b_conv;
33762         b_conv.inner = (void*)(b & (~1));
33763         b_conv.is_owned = false;
33764         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33765         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
33766         return ret_val;
33767 }
33768
33769 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33770         LDKNodeFeatures a_conv;
33771         a_conv.inner = (void*)(a & (~1));
33772         a_conv.is_owned = false;
33773         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33774         LDKNodeFeatures b_conv;
33775         b_conv.inner = (void*)(b & (~1));
33776         b_conv.is_owned = false;
33777         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33778         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
33779         return ret_val;
33780 }
33781
33782 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33783         LDKChannelFeatures a_conv;
33784         a_conv.inner = (void*)(a & (~1));
33785         a_conv.is_owned = false;
33786         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33787         LDKChannelFeatures b_conv;
33788         b_conv.inner = (void*)(b & (~1));
33789         b_conv.is_owned = false;
33790         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33791         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
33792         return ret_val;
33793 }
33794
33795 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33796         LDKInvoiceFeatures a_conv;
33797         a_conv.inner = (void*)(a & (~1));
33798         a_conv.is_owned = false;
33799         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33800         LDKInvoiceFeatures b_conv;
33801         b_conv.inner = (void*)(b & (~1));
33802         b_conv.is_owned = false;
33803         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33804         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
33805         return ret_val;
33806 }
33807
33808 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
33809         LDKInitFeatures ret_var = InitFeatures_clone(arg);
33810 uint64_t ret_ref = 0;
33811 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33812 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33813 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33814 ret_ref = (uint64_t)ret_var.inner;
33815 if (ret_var.is_owned) {
33816         ret_ref |= 1;
33817 }
33818         return ret_ref;
33819 }
33820 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33821         LDKInitFeatures arg_conv;
33822         arg_conv.inner = (void*)(arg & (~1));
33823         arg_conv.is_owned = false;
33824         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33825         int64_t ret_val = InitFeatures_clone_ptr(&arg_conv);
33826         return ret_val;
33827 }
33828
33829 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33830         LDKInitFeatures orig_conv;
33831         orig_conv.inner = (void*)(orig & (~1));
33832         orig_conv.is_owned = false;
33833         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33834         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
33835         uint64_t ret_ref = 0;
33836         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33837         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33838         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33839         ret_ref = (uint64_t)ret_var.inner;
33840         if (ret_var.is_owned) {
33841                 ret_ref |= 1;
33842         }
33843         return ret_ref;
33844 }
33845
33846 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
33847         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
33848 uint64_t ret_ref = 0;
33849 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33850 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33851 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33852 ret_ref = (uint64_t)ret_var.inner;
33853 if (ret_var.is_owned) {
33854         ret_ref |= 1;
33855 }
33856         return ret_ref;
33857 }
33858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33859         LDKNodeFeatures arg_conv;
33860         arg_conv.inner = (void*)(arg & (~1));
33861         arg_conv.is_owned = false;
33862         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33863         int64_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
33864         return ret_val;
33865 }
33866
33867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33868         LDKNodeFeatures orig_conv;
33869         orig_conv.inner = (void*)(orig & (~1));
33870         orig_conv.is_owned = false;
33871         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33872         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
33873         uint64_t ret_ref = 0;
33874         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33875         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33876         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33877         ret_ref = (uint64_t)ret_var.inner;
33878         if (ret_var.is_owned) {
33879                 ret_ref |= 1;
33880         }
33881         return ret_ref;
33882 }
33883
33884 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
33885         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
33886 uint64_t ret_ref = 0;
33887 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33888 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33889 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33890 ret_ref = (uint64_t)ret_var.inner;
33891 if (ret_var.is_owned) {
33892         ret_ref |= 1;
33893 }
33894         return ret_ref;
33895 }
33896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33897         LDKChannelFeatures arg_conv;
33898         arg_conv.inner = (void*)(arg & (~1));
33899         arg_conv.is_owned = false;
33900         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33901         int64_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
33902         return ret_val;
33903 }
33904
33905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33906         LDKChannelFeatures orig_conv;
33907         orig_conv.inner = (void*)(orig & (~1));
33908         orig_conv.is_owned = false;
33909         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33910         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
33911         uint64_t ret_ref = 0;
33912         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33913         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33914         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33915         ret_ref = (uint64_t)ret_var.inner;
33916         if (ret_var.is_owned) {
33917                 ret_ref |= 1;
33918         }
33919         return ret_ref;
33920 }
33921
33922 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
33923         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
33924 uint64_t ret_ref = 0;
33925 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33926 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33927 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33928 ret_ref = (uint64_t)ret_var.inner;
33929 if (ret_var.is_owned) {
33930         ret_ref |= 1;
33931 }
33932         return ret_ref;
33933 }
33934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33935         LDKInvoiceFeatures arg_conv;
33936         arg_conv.inner = (void*)(arg & (~1));
33937         arg_conv.is_owned = false;
33938         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33939         int64_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
33940         return ret_val;
33941 }
33942
33943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33944         LDKInvoiceFeatures orig_conv;
33945         orig_conv.inner = (void*)(orig & (~1));
33946         orig_conv.is_owned = false;
33947         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33948         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
33949         uint64_t ret_ref = 0;
33950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33953         ret_ref = (uint64_t)ret_var.inner;
33954         if (ret_var.is_owned) {
33955                 ret_ref |= 1;
33956         }
33957         return ret_ref;
33958 }
33959
33960 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33961         LDKInitFeatures this_obj_conv;
33962         this_obj_conv.inner = (void*)(this_obj & (~1));
33963         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33965         InitFeatures_free(this_obj_conv);
33966 }
33967
33968 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33969         LDKNodeFeatures this_obj_conv;
33970         this_obj_conv.inner = (void*)(this_obj & (~1));
33971         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33972         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33973         NodeFeatures_free(this_obj_conv);
33974 }
33975
33976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33977         LDKChannelFeatures this_obj_conv;
33978         this_obj_conv.inner = (void*)(this_obj & (~1));
33979         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33980         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33981         ChannelFeatures_free(this_obj_conv);
33982 }
33983
33984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33985         LDKInvoiceFeatures this_obj_conv;
33986         this_obj_conv.inner = (void*)(this_obj & (~1));
33987         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33989         InvoiceFeatures_free(this_obj_conv);
33990 }
33991
33992 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
33993         LDKInitFeatures ret_var = InitFeatures_empty();
33994         uint64_t ret_ref = 0;
33995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33998         ret_ref = (uint64_t)ret_var.inner;
33999         if (ret_var.is_owned) {
34000                 ret_ref |= 1;
34001         }
34002         return ret_ref;
34003 }
34004
34005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
34006         LDKInitFeatures ret_var = InitFeatures_known();
34007         uint64_t ret_ref = 0;
34008         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34009         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34010         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34011         ret_ref = (uint64_t)ret_var.inner;
34012         if (ret_var.is_owned) {
34013                 ret_ref |= 1;
34014         }
34015         return ret_ref;
34016 }
34017
34018 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34019         LDKInitFeatures this_arg_conv;
34020         this_arg_conv.inner = (void*)(this_arg & (~1));
34021         this_arg_conv.is_owned = false;
34022         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34023         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
34024         return ret_val;
34025 }
34026
34027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
34028         LDKNodeFeatures ret_var = NodeFeatures_empty();
34029         uint64_t ret_ref = 0;
34030         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34031         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34032         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34033         ret_ref = (uint64_t)ret_var.inner;
34034         if (ret_var.is_owned) {
34035                 ret_ref |= 1;
34036         }
34037         return ret_ref;
34038 }
34039
34040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
34041         LDKNodeFeatures ret_var = NodeFeatures_known();
34042         uint64_t ret_ref = 0;
34043         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34044         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34045         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34046         ret_ref = (uint64_t)ret_var.inner;
34047         if (ret_var.is_owned) {
34048                 ret_ref |= 1;
34049         }
34050         return ret_ref;
34051 }
34052
34053 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34054         LDKNodeFeatures this_arg_conv;
34055         this_arg_conv.inner = (void*)(this_arg & (~1));
34056         this_arg_conv.is_owned = false;
34057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34058         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
34059         return ret_val;
34060 }
34061
34062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
34063         LDKChannelFeatures ret_var = ChannelFeatures_empty();
34064         uint64_t ret_ref = 0;
34065         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34066         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34068         ret_ref = (uint64_t)ret_var.inner;
34069         if (ret_var.is_owned) {
34070                 ret_ref |= 1;
34071         }
34072         return ret_ref;
34073 }
34074
34075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
34076         LDKChannelFeatures ret_var = ChannelFeatures_known();
34077         uint64_t ret_ref = 0;
34078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34081         ret_ref = (uint64_t)ret_var.inner;
34082         if (ret_var.is_owned) {
34083                 ret_ref |= 1;
34084         }
34085         return ret_ref;
34086 }
34087
34088 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34089         LDKChannelFeatures this_arg_conv;
34090         this_arg_conv.inner = (void*)(this_arg & (~1));
34091         this_arg_conv.is_owned = false;
34092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34093         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
34094         return ret_val;
34095 }
34096
34097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
34098         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
34099         uint64_t ret_ref = 0;
34100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34103         ret_ref = (uint64_t)ret_var.inner;
34104         if (ret_var.is_owned) {
34105                 ret_ref |= 1;
34106         }
34107         return ret_ref;
34108 }
34109
34110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
34111         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
34112         uint64_t ret_ref = 0;
34113         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34114         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34116         ret_ref = (uint64_t)ret_var.inner;
34117         if (ret_var.is_owned) {
34118                 ret_ref |= 1;
34119         }
34120         return ret_ref;
34121 }
34122
34123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34124         LDKInvoiceFeatures this_arg_conv;
34125         this_arg_conv.inner = (void*)(this_arg & (~1));
34126         this_arg_conv.is_owned = false;
34127         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34128         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
34129         return ret_val;
34130 }
34131
34132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
34133         LDKInitFeatures this_arg_conv;
34134         this_arg_conv.inner = (void*)(this_arg & (~1));
34135         this_arg_conv.is_owned = false;
34136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34137         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
34138         return ret_val;
34139 }
34140
34141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
34142         LDKNodeFeatures this_arg_conv;
34143         this_arg_conv.inner = (void*)(this_arg & (~1));
34144         this_arg_conv.is_owned = false;
34145         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34146         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
34147         return ret_val;
34148 }
34149
34150 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
34151         LDKInvoiceFeatures this_arg_conv;
34152         this_arg_conv.inner = (void*)(this_arg & (~1));
34153         this_arg_conv.is_owned = false;
34154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34155         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
34156         return ret_val;
34157 }
34158
34159 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34160         LDKInitFeatures obj_conv;
34161         obj_conv.inner = (void*)(obj & (~1));
34162         obj_conv.is_owned = false;
34163         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34164         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
34165         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34166         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34167         CVec_u8Z_free(ret_var);
34168         return ret_arr;
34169 }
34170
34171 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34172         LDKNodeFeatures obj_conv;
34173         obj_conv.inner = (void*)(obj & (~1));
34174         obj_conv.is_owned = false;
34175         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34176         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
34177         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34178         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34179         CVec_u8Z_free(ret_var);
34180         return ret_arr;
34181 }
34182
34183 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34184         LDKChannelFeatures obj_conv;
34185         obj_conv.inner = (void*)(obj & (~1));
34186         obj_conv.is_owned = false;
34187         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34188         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
34189         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34190         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34191         CVec_u8Z_free(ret_var);
34192         return ret_arr;
34193 }
34194
34195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34196         LDKInvoiceFeatures obj_conv;
34197         obj_conv.inner = (void*)(obj & (~1));
34198         obj_conv.is_owned = false;
34199         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34200         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
34201         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34202         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34203         CVec_u8Z_free(ret_var);
34204         return ret_arr;
34205 }
34206
34207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34208         LDKu8slice ser_ref;
34209         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34210         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34211         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
34212         *ret_conv = InitFeatures_read(ser_ref);
34213         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34214         return (uint64_t)ret_conv;
34215 }
34216
34217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34218         LDKu8slice ser_ref;
34219         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34220         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34221         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
34222         *ret_conv = NodeFeatures_read(ser_ref);
34223         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34224         return (uint64_t)ret_conv;
34225 }
34226
34227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34228         LDKu8slice ser_ref;
34229         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34230         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34231         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
34232         *ret_conv = ChannelFeatures_read(ser_ref);
34233         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34234         return (uint64_t)ret_conv;
34235 }
34236
34237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34238         LDKu8slice ser_ref;
34239         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34240         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34241         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
34242         *ret_conv = InvoiceFeatures_read(ser_ref);
34243         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34244         return (uint64_t)ret_conv;
34245 }
34246
34247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34248         LDKShutdownScript this_obj_conv;
34249         this_obj_conv.inner = (void*)(this_obj & (~1));
34250         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34252         ShutdownScript_free(this_obj_conv);
34253 }
34254
34255 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
34256         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
34257 uint64_t ret_ref = 0;
34258 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34259 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34260 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34261 ret_ref = (uint64_t)ret_var.inner;
34262 if (ret_var.is_owned) {
34263         ret_ref |= 1;
34264 }
34265         return ret_ref;
34266 }
34267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34268         LDKShutdownScript arg_conv;
34269         arg_conv.inner = (void*)(arg & (~1));
34270         arg_conv.is_owned = false;
34271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34272         int64_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
34273         return ret_val;
34274 }
34275
34276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34277         LDKShutdownScript orig_conv;
34278         orig_conv.inner = (void*)(orig & (~1));
34279         orig_conv.is_owned = false;
34280         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34281         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
34282         uint64_t ret_ref = 0;
34283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34286         ret_ref = (uint64_t)ret_var.inner;
34287         if (ret_var.is_owned) {
34288                 ret_ref |= 1;
34289         }
34290         return ret_ref;
34291 }
34292
34293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34294         LDKInvalidShutdownScript this_obj_conv;
34295         this_obj_conv.inner = (void*)(this_obj & (~1));
34296         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34298         InvalidShutdownScript_free(this_obj_conv);
34299 }
34300
34301 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
34302         LDKInvalidShutdownScript this_ptr_conv;
34303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34304         this_ptr_conv.is_owned = false;
34305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34306         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
34307         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34308         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34309         return ret_arr;
34310 }
34311
34312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34313         LDKInvalidShutdownScript this_ptr_conv;
34314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34315         this_ptr_conv.is_owned = false;
34316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34317         LDKCVec_u8Z val_ref;
34318         val_ref.datalen = (*env)->GetArrayLength(env, val);
34319         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
34320         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
34321         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
34322 }
34323
34324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
34325         LDKCVec_u8Z script_arg_ref;
34326         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
34327         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
34328         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
34329         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
34330         uint64_t ret_ref = 0;
34331         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34332         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34333         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34334         ret_ref = (uint64_t)ret_var.inner;
34335         if (ret_var.is_owned) {
34336                 ret_ref |= 1;
34337         }
34338         return ret_ref;
34339 }
34340
34341 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
34342         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
34343 uint64_t ret_ref = 0;
34344 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34345 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34346 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34347 ret_ref = (uint64_t)ret_var.inner;
34348 if (ret_var.is_owned) {
34349         ret_ref |= 1;
34350 }
34351         return ret_ref;
34352 }
34353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34354         LDKInvalidShutdownScript arg_conv;
34355         arg_conv.inner = (void*)(arg & (~1));
34356         arg_conv.is_owned = false;
34357         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34358         int64_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
34359         return ret_val;
34360 }
34361
34362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34363         LDKInvalidShutdownScript orig_conv;
34364         orig_conv.inner = (void*)(orig & (~1));
34365         orig_conv.is_owned = false;
34366         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34367         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
34368         uint64_t ret_ref = 0;
34369         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34370         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34372         ret_ref = (uint64_t)ret_var.inner;
34373         if (ret_var.is_owned) {
34374                 ret_ref |= 1;
34375         }
34376         return ret_ref;
34377 }
34378
34379 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
34380         LDKShutdownScript obj_conv;
34381         obj_conv.inner = (void*)(obj & (~1));
34382         obj_conv.is_owned = false;
34383         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34384         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
34385         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34386         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34387         CVec_u8Z_free(ret_var);
34388         return ret_arr;
34389 }
34390
34391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34392         LDKu8slice ser_ref;
34393         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34394         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34395         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
34396         *ret_conv = ShutdownScript_read(ser_ref);
34397         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34398         return (uint64_t)ret_conv;
34399 }
34400
34401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
34402         unsigned char pubkey_hash_arr[20];
34403         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
34404         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
34405         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
34406         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
34407         uint64_t ret_ref = 0;
34408         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34409         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34410         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34411         ret_ref = (uint64_t)ret_var.inner;
34412         if (ret_var.is_owned) {
34413                 ret_ref |= 1;
34414         }
34415         return ret_ref;
34416 }
34417
34418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
34419         unsigned char script_hash_arr[32];
34420         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
34421         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
34422         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
34423         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
34424         uint64_t ret_ref = 0;
34425         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34426         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34427         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34428         ret_ref = (uint64_t)ret_var.inner;
34429         if (ret_var.is_owned) {
34430                 ret_ref |= 1;
34431         }
34432         return ret_ref;
34433 }
34434
34435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
34436         LDKu8slice program_ref;
34437         program_ref.datalen = (*env)->GetArrayLength(env, program);
34438         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
34439         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
34440         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
34441         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
34442         return (uint64_t)ret_conv;
34443 }
34444
34445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
34446         LDKShutdownScript this_arg_conv;
34447         this_arg_conv.inner = (void*)(this_arg & (~1));
34448         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
34449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34450         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
34451         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
34452         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34453         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34454         CVec_u8Z_free(ret_var);
34455         return ret_arr;
34456 }
34457
34458 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
34459         LDKShutdownScript this_arg_conv;
34460         this_arg_conv.inner = (void*)(this_arg & (~1));
34461         this_arg_conv.is_owned = false;
34462         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34463         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34464         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
34465         return ret_arr;
34466 }
34467
34468 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
34469         LDKShutdownScript this_arg_conv;
34470         this_arg_conv.inner = (void*)(this_arg & (~1));
34471         this_arg_conv.is_owned = false;
34472         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34473         LDKInitFeatures features_conv;
34474         features_conv.inner = (void*)(features & (~1));
34475         features_conv.is_owned = false;
34476         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
34477         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
34478         return ret_val;
34479 }
34480
34481 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34482         if ((this_ptr & 1) != 0) return;
34483         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34484         CHECK_ACCESS(this_ptr_ptr);
34485         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
34486         FREE((void*)this_ptr);
34487         CustomMessageReader_free(this_ptr_conv);
34488 }
34489
34490 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
34491         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
34492         *ret_ret = Type_clone(arg);
34493         return (uint64_t)ret_ret;
34494 }
34495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34496         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
34497         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
34498         LDKType* arg_conv = (LDKType*)arg_ptr;
34499         int64_t ret_val = Type_clone_ptr(arg_conv);
34500         return ret_val;
34501 }
34502
34503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34504         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
34505         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
34506         LDKType* orig_conv = (LDKType*)orig_ptr;
34507         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
34508         *ret_ret = Type_clone(orig_conv);
34509         return (uint64_t)ret_ret;
34510 }
34511
34512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34513         if ((this_ptr & 1) != 0) return;
34514         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34515         CHECK_ACCESS(this_ptr_ptr);
34516         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
34517         FREE((void*)this_ptr);
34518         Type_free(this_ptr_conv);
34519 }
34520
34521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34522         if ((this_ptr & 1) != 0) return;
34523         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34524         CHECK_ACCESS(this_ptr_ptr);
34525         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
34526         FREE((void*)this_ptr);
34527         Score_free(this_ptr_conv);
34528 }
34529
34530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34531         LDKLockableScore this_obj_conv;
34532         this_obj_conv.inner = (void*)(this_obj & (~1));
34533         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34535         LockableScore_free(this_obj_conv);
34536 }
34537
34538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
34539         void* score_ptr = (void*)(((uint64_t)score) & ~1);
34540         CHECK_ACCESS(score_ptr);
34541         LDKScore score_conv = *(LDKScore*)(score_ptr);
34542         if (score_conv.free == LDKScore_JCalls_free) {
34543                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34544                 LDKScore_JCalls_cloned(&score_conv);
34545         }
34546         LDKLockableScore ret_var = LockableScore_new(score_conv);
34547         uint64_t ret_ref = 0;
34548         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34549         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34550         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34551         ret_ref = (uint64_t)ret_var.inner;
34552         if (ret_var.is_owned) {
34553                 ret_ref |= 1;
34554         }
34555         return ret_ref;
34556 }
34557
34558 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
34559         LDKLockableScore obj_conv;
34560         obj_conv.inner = (void*)(obj & (~1));
34561         obj_conv.is_owned = false;
34562         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34563         LDKCVec_u8Z ret_var = LockableScore_write(&obj_conv);
34564         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34565         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34566         CVec_u8Z_free(ret_var);
34567         return ret_arr;
34568 }
34569
34570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34571         LDKNodeId this_obj_conv;
34572         this_obj_conv.inner = (void*)(this_obj & (~1));
34573         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34575         NodeId_free(this_obj_conv);
34576 }
34577
34578 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
34579         LDKNodeId ret_var = NodeId_clone(arg);
34580 uint64_t ret_ref = 0;
34581 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34582 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34583 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34584 ret_ref = (uint64_t)ret_var.inner;
34585 if (ret_var.is_owned) {
34586         ret_ref |= 1;
34587 }
34588         return ret_ref;
34589 }
34590 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34591         LDKNodeId arg_conv;
34592         arg_conv.inner = (void*)(arg & (~1));
34593         arg_conv.is_owned = false;
34594         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34595         int64_t ret_val = NodeId_clone_ptr(&arg_conv);
34596         return ret_val;
34597 }
34598
34599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34600         LDKNodeId orig_conv;
34601         orig_conv.inner = (void*)(orig & (~1));
34602         orig_conv.is_owned = false;
34603         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34604         LDKNodeId ret_var = NodeId_clone(&orig_conv);
34605         uint64_t ret_ref = 0;
34606         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34607         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34608         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34609         ret_ref = (uint64_t)ret_var.inner;
34610         if (ret_var.is_owned) {
34611                 ret_ref |= 1;
34612         }
34613         return ret_ref;
34614 }
34615
34616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
34617         LDKPublicKey pubkey_ref;
34618         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
34619         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
34620         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
34621         uint64_t ret_ref = 0;
34622         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34623         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34625         ret_ref = (uint64_t)ret_var.inner;
34626         if (ret_var.is_owned) {
34627                 ret_ref |= 1;
34628         }
34629         return ret_ref;
34630 }
34631
34632 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
34633         LDKNodeId this_arg_conv;
34634         this_arg_conv.inner = (void*)(this_arg & (~1));
34635         this_arg_conv.is_owned = false;
34636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34637         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
34638         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34639         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34640         return ret_arr;
34641 }
34642
34643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
34644         LDKNodeId o_conv;
34645         o_conv.inner = (void*)(o & (~1));
34646         o_conv.is_owned = false;
34647         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34648         int64_t ret_val = NodeId_hash(&o_conv);
34649         return ret_val;
34650 }
34651
34652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
34653         LDKNodeId obj_conv;
34654         obj_conv.inner = (void*)(obj & (~1));
34655         obj_conv.is_owned = false;
34656         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34657         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
34658         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34659         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34660         CVec_u8Z_free(ret_var);
34661         return ret_arr;
34662 }
34663
34664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34665         LDKu8slice ser_ref;
34666         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34667         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34668         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
34669         *ret_conv = NodeId_read(ser_ref);
34670         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34671         return (uint64_t)ret_conv;
34672 }
34673
34674 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34675         LDKNetworkGraph this_obj_conv;
34676         this_obj_conv.inner = (void*)(this_obj & (~1));
34677         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34679         NetworkGraph_free(this_obj_conv);
34680 }
34681
34682 static inline uint64_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
34683         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
34684 uint64_t ret_ref = 0;
34685 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34686 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34687 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34688 ret_ref = (uint64_t)ret_var.inner;
34689 if (ret_var.is_owned) {
34690         ret_ref |= 1;
34691 }
34692         return ret_ref;
34693 }
34694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34695         LDKNetworkGraph arg_conv;
34696         arg_conv.inner = (void*)(arg & (~1));
34697         arg_conv.is_owned = false;
34698         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34699         int64_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
34700         return ret_val;
34701 }
34702
34703 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34704         LDKNetworkGraph orig_conv;
34705         orig_conv.inner = (void*)(orig & (~1));
34706         orig_conv.is_owned = false;
34707         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34708         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
34709         uint64_t ret_ref = 0;
34710         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34711         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34712         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34713         ret_ref = (uint64_t)ret_var.inner;
34714         if (ret_var.is_owned) {
34715                 ret_ref |= 1;
34716         }
34717         return ret_ref;
34718 }
34719
34720 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34721         LDKReadOnlyNetworkGraph this_obj_conv;
34722         this_obj_conv.inner = (void*)(this_obj & (~1));
34723         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34725         ReadOnlyNetworkGraph_free(this_obj_conv);
34726 }
34727
34728 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34729         if ((this_ptr & 1) != 0) return;
34730         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34731         CHECK_ACCESS(this_ptr_ptr);
34732         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
34733         FREE((void*)this_ptr);
34734         NetworkUpdate_free(this_ptr_conv);
34735 }
34736
34737 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
34738         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34739         *ret_copy = NetworkUpdate_clone(arg);
34740 uint64_t ret_ref = (uint64_t)ret_copy;
34741         return ret_ref;
34742 }
34743 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34744         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
34745         int64_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
34746         return ret_val;
34747 }
34748
34749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34750         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
34751         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34752         *ret_copy = NetworkUpdate_clone(orig_conv);
34753         uint64_t ret_ref = (uint64_t)ret_copy;
34754         return ret_ref;
34755 }
34756
34757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
34758         LDKChannelUpdate msg_conv;
34759         msg_conv.inner = (void*)(msg & (~1));
34760         msg_conv.is_owned = (msg & 1) || (msg == 0);
34761         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34762         msg_conv = ChannelUpdate_clone(&msg_conv);
34763         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34764         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
34765         uint64_t ret_ref = (uint64_t)ret_copy;
34766         return ret_ref;
34767 }
34768
34769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
34770         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34771         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
34772         uint64_t ret_ref = (uint64_t)ret_copy;
34773         return ret_ref;
34774 }
34775
34776 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
34777         LDKPublicKey node_id_ref;
34778         CHECK((*env)->GetArrayLength(env, node_id) == 33);
34779         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
34780         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34781         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
34782         uint64_t ret_ref = (uint64_t)ret_copy;
34783         return ret_ref;
34784 }
34785
34786 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
34787         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
34788         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
34789         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34790         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34791         CVec_u8Z_free(ret_var);
34792         return ret_arr;
34793 }
34794
34795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34796         LDKu8slice ser_ref;
34797         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34798         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34799         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
34800         *ret_conv = NetworkUpdate_read(ser_ref);
34801         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34802         return (uint64_t)ret_conv;
34803 }
34804
34805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
34806         LDKNetGraphMsgHandler this_arg_conv;
34807         this_arg_conv.inner = (void*)(this_arg & (~1));
34808         this_arg_conv.is_owned = false;
34809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34810         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
34811         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
34812         return (uint64_t)ret_ret;
34813 }
34814
34815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34816         LDKNetGraphMsgHandler this_obj_conv;
34817         this_obj_conv.inner = (void*)(this_obj & (~1));
34818         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34820         NetGraphMsgHandler_free(this_obj_conv);
34821 }
34822
34823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t chain_access, int64_t logger) {
34824         LDKNetworkGraph network_graph_conv;
34825         network_graph_conv.inner = (void*)(network_graph & (~1));
34826         network_graph_conv.is_owned = false;
34827         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
34828         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
34829         CHECK_ACCESS(chain_access_ptr);
34830         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
34831         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
34832         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
34833                 // Manually implement clone for Java trait instances
34834                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
34835                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34836                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
34837                 }
34838         }
34839         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
34840         CHECK_ACCESS(logger_ptr);
34841         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34842         if (logger_conv.free == LDKLogger_JCalls_free) {
34843                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34844                 LDKLogger_JCalls_cloned(&logger_conv);
34845         }
34846         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
34847         uint64_t ret_ref = 0;
34848         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34849         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34850         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34851         ret_ref = (uint64_t)ret_var.inner;
34852         if (ret_var.is_owned) {
34853                 ret_ref |= 1;
34854         }
34855         return ret_ref;
34856 }
34857
34858 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
34859         LDKNetGraphMsgHandler this_arg_conv;
34860         this_arg_conv.inner = (void*)(this_arg & (~1));
34861         this_arg_conv.is_owned = false;
34862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34863         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
34864         CHECK_ACCESS(chain_access_ptr);
34865         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
34866         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
34867         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
34868                 // Manually implement clone for Java trait instances
34869                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
34870                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34871                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
34872                 }
34873         }
34874         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
34875 }
34876
34877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
34878         LDKNetGraphMsgHandler this_arg_conv;
34879         this_arg_conv.inner = (void*)(this_arg & (~1));
34880         this_arg_conv.is_owned = false;
34881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34882         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
34883         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
34884         return (uint64_t)ret_ret;
34885 }
34886
34887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
34888         LDKNetGraphMsgHandler this_arg_conv;
34889         this_arg_conv.inner = (void*)(this_arg & (~1));
34890         this_arg_conv.is_owned = false;
34891         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34892         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34893         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
34894         return (uint64_t)ret_ret;
34895 }
34896
34897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34898         LDKDirectionalChannelInfo this_obj_conv;
34899         this_obj_conv.inner = (void*)(this_obj & (~1));
34900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34902         DirectionalChannelInfo_free(this_obj_conv);
34903 }
34904
34905 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
34906         LDKDirectionalChannelInfo this_ptr_conv;
34907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34908         this_ptr_conv.is_owned = false;
34909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34910         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
34911         return ret_val;
34912 }
34913
34914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34915         LDKDirectionalChannelInfo this_ptr_conv;
34916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34917         this_ptr_conv.is_owned = false;
34918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34919         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
34920 }
34921
34922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
34923         LDKDirectionalChannelInfo this_ptr_conv;
34924         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34925         this_ptr_conv.is_owned = false;
34926         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34927         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
34928         return ret_val;
34929 }
34930
34931 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34932         LDKDirectionalChannelInfo this_ptr_conv;
34933         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34934         this_ptr_conv.is_owned = false;
34935         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34936         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
34937 }
34938
34939 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
34940         LDKDirectionalChannelInfo this_ptr_conv;
34941         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34942         this_ptr_conv.is_owned = false;
34943         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34944         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
34945         return ret_val;
34946 }
34947
34948 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34949         LDKDirectionalChannelInfo this_ptr_conv;
34950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34951         this_ptr_conv.is_owned = false;
34952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34953         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
34954 }
34955
34956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34957         LDKDirectionalChannelInfo this_ptr_conv;
34958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34959         this_ptr_conv.is_owned = false;
34960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34961         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
34962         return ret_val;
34963 }
34964
34965 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34966         LDKDirectionalChannelInfo this_ptr_conv;
34967         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34968         this_ptr_conv.is_owned = false;
34969         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34970         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
34971 }
34972
34973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34974         LDKDirectionalChannelInfo this_ptr_conv;
34975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34976         this_ptr_conv.is_owned = false;
34977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34978         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34979         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
34980         uint64_t ret_ref = (uint64_t)ret_copy;
34981         return ret_ref;
34982 }
34983
34984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34985         LDKDirectionalChannelInfo this_ptr_conv;
34986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34987         this_ptr_conv.is_owned = false;
34988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34989         void* val_ptr = (void*)(((uint64_t)val) & ~1);
34990         CHECK_ACCESS(val_ptr);
34991         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34992         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
34993         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
34994 }
34995
34996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
34997         LDKDirectionalChannelInfo this_ptr_conv;
34998         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34999         this_ptr_conv.is_owned = false;
35000         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35001         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
35002         uint64_t ret_ref = 0;
35003         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35004         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35005         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35006         ret_ref = (uint64_t)ret_var.inner;
35007         if (ret_var.is_owned) {
35008                 ret_ref |= 1;
35009         }
35010         return ret_ref;
35011 }
35012
35013 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35014         LDKDirectionalChannelInfo this_ptr_conv;
35015         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35016         this_ptr_conv.is_owned = false;
35017         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35018         LDKRoutingFees val_conv;
35019         val_conv.inner = (void*)(val & (~1));
35020         val_conv.is_owned = (val & 1) || (val == 0);
35021         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35022         val_conv = RoutingFees_clone(&val_conv);
35023         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
35024 }
35025
35026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
35027         LDKDirectionalChannelInfo this_ptr_conv;
35028         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35029         this_ptr_conv.is_owned = false;
35030         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35031         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
35032         uint64_t ret_ref = 0;
35033         if ((uint64_t)ret_var.inner > 4096) {
35034                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35035                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35036         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35037                 ret_ref = (uint64_t)ret_var.inner;
35038                 if (ret_var.is_owned) {
35039                         ret_ref |= 1;
35040                 }
35041         }
35042         return ret_ref;
35043 }
35044
35045 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35046         LDKDirectionalChannelInfo this_ptr_conv;
35047         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35048         this_ptr_conv.is_owned = false;
35049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35050         LDKChannelUpdate val_conv;
35051         val_conv.inner = (void*)(val & (~1));
35052         val_conv.is_owned = (val & 1) || (val == 0);
35053         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35054         val_conv = ChannelUpdate_clone(&val_conv);
35055         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
35056 }
35057
35058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_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) {
35059         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
35060         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
35061         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
35062         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
35063         LDKRoutingFees fees_arg_conv;
35064         fees_arg_conv.inner = (void*)(fees_arg & (~1));
35065         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
35066         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
35067         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
35068         LDKChannelUpdate last_update_message_arg_conv;
35069         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
35070         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
35071         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
35072         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
35073         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_new(last_update_arg, enabled_arg, cltv_expiry_delta_arg, htlc_minimum_msat_arg, htlc_maximum_msat_arg_conv, fees_arg_conv, last_update_message_arg_conv);
35074         uint64_t ret_ref = 0;
35075         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35076         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35077         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35078         ret_ref = (uint64_t)ret_var.inner;
35079         if (ret_var.is_owned) {
35080                 ret_ref |= 1;
35081         }
35082         return ret_ref;
35083 }
35084
35085 static inline uint64_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
35086         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
35087 uint64_t ret_ref = 0;
35088 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35089 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35090 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35091 ret_ref = (uint64_t)ret_var.inner;
35092 if (ret_var.is_owned) {
35093         ret_ref |= 1;
35094 }
35095         return ret_ref;
35096 }
35097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35098         LDKDirectionalChannelInfo arg_conv;
35099         arg_conv.inner = (void*)(arg & (~1));
35100         arg_conv.is_owned = false;
35101         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35102         int64_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
35103         return ret_val;
35104 }
35105
35106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35107         LDKDirectionalChannelInfo orig_conv;
35108         orig_conv.inner = (void*)(orig & (~1));
35109         orig_conv.is_owned = false;
35110         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35111         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
35112         uint64_t ret_ref = 0;
35113         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35114         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35115         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35116         ret_ref = (uint64_t)ret_var.inner;
35117         if (ret_var.is_owned) {
35118                 ret_ref |= 1;
35119         }
35120         return ret_ref;
35121 }
35122
35123 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
35124         LDKDirectionalChannelInfo obj_conv;
35125         obj_conv.inner = (void*)(obj & (~1));
35126         obj_conv.is_owned = false;
35127         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35128         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
35129         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35130         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35131         CVec_u8Z_free(ret_var);
35132         return ret_arr;
35133 }
35134
35135 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35136         LDKu8slice ser_ref;
35137         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35138         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35139         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
35140         *ret_conv = DirectionalChannelInfo_read(ser_ref);
35141         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35142         return (uint64_t)ret_conv;
35143 }
35144
35145 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35146         LDKChannelInfo this_obj_conv;
35147         this_obj_conv.inner = (void*)(this_obj & (~1));
35148         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35149         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35150         ChannelInfo_free(this_obj_conv);
35151 }
35152
35153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35154         LDKChannelInfo this_ptr_conv;
35155         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35156         this_ptr_conv.is_owned = false;
35157         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35158         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
35159         uint64_t ret_ref = 0;
35160         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35161         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35162         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35163         ret_ref = (uint64_t)ret_var.inner;
35164         if (ret_var.is_owned) {
35165                 ret_ref |= 1;
35166         }
35167         return ret_ref;
35168 }
35169
35170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35171         LDKChannelInfo this_ptr_conv;
35172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35173         this_ptr_conv.is_owned = false;
35174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35175         LDKChannelFeatures val_conv;
35176         val_conv.inner = (void*)(val & (~1));
35177         val_conv.is_owned = (val & 1) || (val == 0);
35178         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35179         val_conv = ChannelFeatures_clone(&val_conv);
35180         ChannelInfo_set_features(&this_ptr_conv, val_conv);
35181 }
35182
35183 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
35184         LDKChannelInfo this_ptr_conv;
35185         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35186         this_ptr_conv.is_owned = false;
35187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35188         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
35189         uint64_t ret_ref = 0;
35190         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35191         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35193         ret_ref = (uint64_t)ret_var.inner;
35194         if (ret_var.is_owned) {
35195                 ret_ref |= 1;
35196         }
35197         return ret_ref;
35198 }
35199
35200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35201         LDKChannelInfo this_ptr_conv;
35202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35203         this_ptr_conv.is_owned = false;
35204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35205         LDKNodeId val_conv;
35206         val_conv.inner = (void*)(val & (~1));
35207         val_conv.is_owned = (val & 1) || (val == 0);
35208         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35209         val_conv = NodeId_clone(&val_conv);
35210         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
35211 }
35212
35213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
35214         LDKChannelInfo this_ptr_conv;
35215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35216         this_ptr_conv.is_owned = false;
35217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35218         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
35219         uint64_t ret_ref = 0;
35220         if ((uint64_t)ret_var.inner > 4096) {
35221                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35222                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35224                 ret_ref = (uint64_t)ret_var.inner;
35225                 if (ret_var.is_owned) {
35226                         ret_ref |= 1;
35227                 }
35228         }
35229         return ret_ref;
35230 }
35231
35232 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35233         LDKChannelInfo this_ptr_conv;
35234         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35235         this_ptr_conv.is_owned = false;
35236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35237         LDKDirectionalChannelInfo val_conv;
35238         val_conv.inner = (void*)(val & (~1));
35239         val_conv.is_owned = (val & 1) || (val == 0);
35240         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35241         val_conv = DirectionalChannelInfo_clone(&val_conv);
35242         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
35243 }
35244
35245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
35246         LDKChannelInfo this_ptr_conv;
35247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35248         this_ptr_conv.is_owned = false;
35249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35250         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
35251         uint64_t ret_ref = 0;
35252         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35253         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35254         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35255         ret_ref = (uint64_t)ret_var.inner;
35256         if (ret_var.is_owned) {
35257                 ret_ref |= 1;
35258         }
35259         return ret_ref;
35260 }
35261
35262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35263         LDKChannelInfo this_ptr_conv;
35264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35265         this_ptr_conv.is_owned = false;
35266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35267         LDKNodeId val_conv;
35268         val_conv.inner = (void*)(val & (~1));
35269         val_conv.is_owned = (val & 1) || (val == 0);
35270         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35271         val_conv = NodeId_clone(&val_conv);
35272         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
35273 }
35274
35275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
35276         LDKChannelInfo this_ptr_conv;
35277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35278         this_ptr_conv.is_owned = false;
35279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35280         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
35281         uint64_t ret_ref = 0;
35282         if ((uint64_t)ret_var.inner > 4096) {
35283                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35284                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35286                 ret_ref = (uint64_t)ret_var.inner;
35287                 if (ret_var.is_owned) {
35288                         ret_ref |= 1;
35289                 }
35290         }
35291         return ret_ref;
35292 }
35293
35294 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35295         LDKChannelInfo this_ptr_conv;
35296         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35297         this_ptr_conv.is_owned = false;
35298         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35299         LDKDirectionalChannelInfo val_conv;
35300         val_conv.inner = (void*)(val & (~1));
35301         val_conv.is_owned = (val & 1) || (val == 0);
35302         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35303         val_conv = DirectionalChannelInfo_clone(&val_conv);
35304         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
35305 }
35306
35307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
35308         LDKChannelInfo this_ptr_conv;
35309         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35310         this_ptr_conv.is_owned = false;
35311         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35312         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35313         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
35314         uint64_t ret_ref = (uint64_t)ret_copy;
35315         return ret_ref;
35316 }
35317
35318 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35319         LDKChannelInfo this_ptr_conv;
35320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35321         this_ptr_conv.is_owned = false;
35322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35323         void* val_ptr = (void*)(((uint64_t)val) & ~1);
35324         CHECK_ACCESS(val_ptr);
35325         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35326         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
35327         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
35328 }
35329
35330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
35331         LDKChannelInfo this_ptr_conv;
35332         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35333         this_ptr_conv.is_owned = false;
35334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35335         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
35336         uint64_t ret_ref = 0;
35337         if ((uint64_t)ret_var.inner > 4096) {
35338                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35339                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35340         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35341                 ret_ref = (uint64_t)ret_var.inner;
35342                 if (ret_var.is_owned) {
35343                         ret_ref |= 1;
35344                 }
35345         }
35346         return ret_ref;
35347 }
35348
35349 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35350         LDKChannelInfo this_ptr_conv;
35351         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35352         this_ptr_conv.is_owned = false;
35353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35354         LDKChannelAnnouncement val_conv;
35355         val_conv.inner = (void*)(val & (~1));
35356         val_conv.is_owned = (val & 1) || (val == 0);
35357         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35358         val_conv = ChannelAnnouncement_clone(&val_conv);
35359         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
35360 }
35361
35362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1new(JNIEnv *env, jclass clz, int64_t features_arg, int64_t node_one_arg, int64_t one_to_two_arg, int64_t node_two_arg, int64_t two_to_one_arg, int64_t capacity_sats_arg, int64_t announcement_message_arg) {
35363         LDKChannelFeatures features_arg_conv;
35364         features_arg_conv.inner = (void*)(features_arg & (~1));
35365         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
35366         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
35367         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
35368         LDKNodeId node_one_arg_conv;
35369         node_one_arg_conv.inner = (void*)(node_one_arg & (~1));
35370         node_one_arg_conv.is_owned = (node_one_arg & 1) || (node_one_arg == 0);
35371         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_one_arg_conv);
35372         node_one_arg_conv = NodeId_clone(&node_one_arg_conv);
35373         LDKDirectionalChannelInfo one_to_two_arg_conv;
35374         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
35375         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
35376         CHECK_INNER_FIELD_ACCESS_OR_NULL(one_to_two_arg_conv);
35377         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
35378         LDKNodeId node_two_arg_conv;
35379         node_two_arg_conv.inner = (void*)(node_two_arg & (~1));
35380         node_two_arg_conv.is_owned = (node_two_arg & 1) || (node_two_arg == 0);
35381         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_two_arg_conv);
35382         node_two_arg_conv = NodeId_clone(&node_two_arg_conv);
35383         LDKDirectionalChannelInfo two_to_one_arg_conv;
35384         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
35385         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
35386         CHECK_INNER_FIELD_ACCESS_OR_NULL(two_to_one_arg_conv);
35387         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
35388         void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
35389         CHECK_ACCESS(capacity_sats_arg_ptr);
35390         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
35391         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
35392         LDKChannelAnnouncement announcement_message_arg_conv;
35393         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
35394         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
35395         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
35396         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
35397         LDKChannelInfo ret_var = ChannelInfo_new(features_arg_conv, node_one_arg_conv, one_to_two_arg_conv, node_two_arg_conv, two_to_one_arg_conv, capacity_sats_arg_conv, announcement_message_arg_conv);
35398         uint64_t ret_ref = 0;
35399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35402         ret_ref = (uint64_t)ret_var.inner;
35403         if (ret_var.is_owned) {
35404                 ret_ref |= 1;
35405         }
35406         return ret_ref;
35407 }
35408
35409 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
35410         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
35411 uint64_t ret_ref = 0;
35412 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35413 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35414 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35415 ret_ref = (uint64_t)ret_var.inner;
35416 if (ret_var.is_owned) {
35417         ret_ref |= 1;
35418 }
35419         return ret_ref;
35420 }
35421 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35422         LDKChannelInfo arg_conv;
35423         arg_conv.inner = (void*)(arg & (~1));
35424         arg_conv.is_owned = false;
35425         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35426         int64_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
35427         return ret_val;
35428 }
35429
35430 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35431         LDKChannelInfo orig_conv;
35432         orig_conv.inner = (void*)(orig & (~1));
35433         orig_conv.is_owned = false;
35434         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35435         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
35436         uint64_t ret_ref = 0;
35437         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35438         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35439         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35440         ret_ref = (uint64_t)ret_var.inner;
35441         if (ret_var.is_owned) {
35442                 ret_ref |= 1;
35443         }
35444         return ret_ref;
35445 }
35446
35447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
35448         LDKChannelInfo obj_conv;
35449         obj_conv.inner = (void*)(obj & (~1));
35450         obj_conv.is_owned = false;
35451         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35452         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
35453         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35454         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35455         CVec_u8Z_free(ret_var);
35456         return ret_arr;
35457 }
35458
35459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35460         LDKu8slice ser_ref;
35461         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35462         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35463         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
35464         *ret_conv = ChannelInfo_read(ser_ref);
35465         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35466         return (uint64_t)ret_conv;
35467 }
35468
35469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35470         LDKRoutingFees this_obj_conv;
35471         this_obj_conv.inner = (void*)(this_obj & (~1));
35472         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35474         RoutingFees_free(this_obj_conv);
35475 }
35476
35477 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35478         LDKRoutingFees this_ptr_conv;
35479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35480         this_ptr_conv.is_owned = false;
35481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35482         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
35483         return ret_val;
35484 }
35485
35486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35487         LDKRoutingFees this_ptr_conv;
35488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35489         this_ptr_conv.is_owned = false;
35490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35491         RoutingFees_set_base_msat(&this_ptr_conv, val);
35492 }
35493
35494 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
35495         LDKRoutingFees this_ptr_conv;
35496         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35497         this_ptr_conv.is_owned = false;
35498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35499         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
35500         return ret_val;
35501 }
35502
35503 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35504         LDKRoutingFees this_ptr_conv;
35505         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35506         this_ptr_conv.is_owned = false;
35507         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35508         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
35509 }
35510
35511 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) {
35512         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
35513         uint64_t ret_ref = 0;
35514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35517         ret_ref = (uint64_t)ret_var.inner;
35518         if (ret_var.is_owned) {
35519                 ret_ref |= 1;
35520         }
35521         return ret_ref;
35522 }
35523
35524 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35525         LDKRoutingFees a_conv;
35526         a_conv.inner = (void*)(a & (~1));
35527         a_conv.is_owned = false;
35528         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35529         LDKRoutingFees b_conv;
35530         b_conv.inner = (void*)(b & (~1));
35531         b_conv.is_owned = false;
35532         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35533         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
35534         return ret_val;
35535 }
35536
35537 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
35538         LDKRoutingFees ret_var = RoutingFees_clone(arg);
35539 uint64_t ret_ref = 0;
35540 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35541 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35542 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35543 ret_ref = (uint64_t)ret_var.inner;
35544 if (ret_var.is_owned) {
35545         ret_ref |= 1;
35546 }
35547         return ret_ref;
35548 }
35549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35550         LDKRoutingFees arg_conv;
35551         arg_conv.inner = (void*)(arg & (~1));
35552         arg_conv.is_owned = false;
35553         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35554         int64_t ret_val = RoutingFees_clone_ptr(&arg_conv);
35555         return ret_val;
35556 }
35557
35558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35559         LDKRoutingFees orig_conv;
35560         orig_conv.inner = (void*)(orig & (~1));
35561         orig_conv.is_owned = false;
35562         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35563         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
35564         uint64_t ret_ref = 0;
35565         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35566         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35567         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35568         ret_ref = (uint64_t)ret_var.inner;
35569         if (ret_var.is_owned) {
35570                 ret_ref |= 1;
35571         }
35572         return ret_ref;
35573 }
35574
35575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
35576         LDKRoutingFees o_conv;
35577         o_conv.inner = (void*)(o & (~1));
35578         o_conv.is_owned = false;
35579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35580         int64_t ret_val = RoutingFees_hash(&o_conv);
35581         return ret_val;
35582 }
35583
35584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
35585         LDKRoutingFees obj_conv;
35586         obj_conv.inner = (void*)(obj & (~1));
35587         obj_conv.is_owned = false;
35588         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35589         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
35590         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35591         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35592         CVec_u8Z_free(ret_var);
35593         return ret_arr;
35594 }
35595
35596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35597         LDKu8slice ser_ref;
35598         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35599         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35600         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
35601         *ret_conv = RoutingFees_read(ser_ref);
35602         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35603         return (uint64_t)ret_conv;
35604 }
35605
35606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35607         LDKNodeAnnouncementInfo this_obj_conv;
35608         this_obj_conv.inner = (void*)(this_obj & (~1));
35609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35611         NodeAnnouncementInfo_free(this_obj_conv);
35612 }
35613
35614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35615         LDKNodeAnnouncementInfo this_ptr_conv;
35616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35617         this_ptr_conv.is_owned = false;
35618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35619         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
35620         uint64_t ret_ref = 0;
35621         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35622         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35623         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35624         ret_ref = (uint64_t)ret_var.inner;
35625         if (ret_var.is_owned) {
35626                 ret_ref |= 1;
35627         }
35628         return ret_ref;
35629 }
35630
35631 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35632         LDKNodeAnnouncementInfo this_ptr_conv;
35633         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35634         this_ptr_conv.is_owned = false;
35635         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35636         LDKNodeFeatures val_conv;
35637         val_conv.inner = (void*)(val & (~1));
35638         val_conv.is_owned = (val & 1) || (val == 0);
35639         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35640         val_conv = NodeFeatures_clone(&val_conv);
35641         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
35642 }
35643
35644 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
35645         LDKNodeAnnouncementInfo this_ptr_conv;
35646         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35647         this_ptr_conv.is_owned = false;
35648         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35649         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
35650         return ret_val;
35651 }
35652
35653 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35654         LDKNodeAnnouncementInfo this_ptr_conv;
35655         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35656         this_ptr_conv.is_owned = false;
35657         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35658         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
35659 }
35660
35661 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
35662         LDKNodeAnnouncementInfo this_ptr_conv;
35663         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35664         this_ptr_conv.is_owned = false;
35665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35666         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
35667         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
35668         return ret_arr;
35669 }
35670
35671 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35672         LDKNodeAnnouncementInfo this_ptr_conv;
35673         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35674         this_ptr_conv.is_owned = false;
35675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35676         LDKThreeBytes val_ref;
35677         CHECK((*env)->GetArrayLength(env, val) == 3);
35678         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
35679         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
35680 }
35681
35682 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35683         LDKNodeAnnouncementInfo this_ptr_conv;
35684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35685         this_ptr_conv.is_owned = false;
35686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35687         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35688         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
35689         return ret_arr;
35690 }
35691
35692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35693         LDKNodeAnnouncementInfo this_ptr_conv;
35694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35695         this_ptr_conv.is_owned = false;
35696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35697         LDKThirtyTwoBytes val_ref;
35698         CHECK((*env)->GetArrayLength(env, val) == 32);
35699         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35700         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
35701 }
35702
35703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35704         LDKNodeAnnouncementInfo this_ptr_conv;
35705         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35706         this_ptr_conv.is_owned = false;
35707         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35708         LDKCVec_NetAddressZ val_constr;
35709         val_constr.datalen = (*env)->GetArrayLength(env, val);
35710         if (val_constr.datalen > 0)
35711                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35712         else
35713                 val_constr.data = NULL;
35714         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35715         for (size_t m = 0; m < val_constr.datalen; m++) {
35716                 int64_t val_conv_12 = val_vals[m];
35717                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
35718                 CHECK_ACCESS(val_conv_12_ptr);
35719                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
35720                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
35721                 val_constr.data[m] = val_conv_12_conv;
35722         }
35723         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35724         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
35725 }
35726
35727 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
35728         LDKNodeAnnouncementInfo this_ptr_conv;
35729         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35730         this_ptr_conv.is_owned = false;
35731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35732         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
35733         uint64_t ret_ref = 0;
35734         if ((uint64_t)ret_var.inner > 4096) {
35735                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35736                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35737         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35738                 ret_ref = (uint64_t)ret_var.inner;
35739                 if (ret_var.is_owned) {
35740                         ret_ref |= 1;
35741                 }
35742         }
35743         return ret_ref;
35744 }
35745
35746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35747         LDKNodeAnnouncementInfo this_ptr_conv;
35748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35749         this_ptr_conv.is_owned = false;
35750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35751         LDKNodeAnnouncement val_conv;
35752         val_conv.inner = (void*)(val & (~1));
35753         val_conv.is_owned = (val & 1) || (val == 0);
35754         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35755         val_conv = NodeAnnouncement_clone(&val_conv);
35756         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
35757 }
35758
35759 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, int8_tArray alias_arg, int64_tArray addresses_arg, int64_t announcement_message_arg) {
35760         LDKNodeFeatures features_arg_conv;
35761         features_arg_conv.inner = (void*)(features_arg & (~1));
35762         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
35763         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
35764         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
35765         LDKThreeBytes rgb_arg_ref;
35766         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
35767         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
35768         LDKThirtyTwoBytes alias_arg_ref;
35769         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
35770         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
35771         LDKCVec_NetAddressZ addresses_arg_constr;
35772         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
35773         if (addresses_arg_constr.datalen > 0)
35774                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35775         else
35776                 addresses_arg_constr.data = NULL;
35777         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
35778         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
35779                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
35780                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
35781                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
35782                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
35783                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
35784         }
35785         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
35786         LDKNodeAnnouncement announcement_message_arg_conv;
35787         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
35788         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
35789         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
35790         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
35791         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
35792         uint64_t ret_ref = 0;
35793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35796         ret_ref = (uint64_t)ret_var.inner;
35797         if (ret_var.is_owned) {
35798                 ret_ref |= 1;
35799         }
35800         return ret_ref;
35801 }
35802
35803 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
35804         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
35805 uint64_t ret_ref = 0;
35806 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35807 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35808 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35809 ret_ref = (uint64_t)ret_var.inner;
35810 if (ret_var.is_owned) {
35811         ret_ref |= 1;
35812 }
35813         return ret_ref;
35814 }
35815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35816         LDKNodeAnnouncementInfo arg_conv;
35817         arg_conv.inner = (void*)(arg & (~1));
35818         arg_conv.is_owned = false;
35819         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35820         int64_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
35821         return ret_val;
35822 }
35823
35824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35825         LDKNodeAnnouncementInfo orig_conv;
35826         orig_conv.inner = (void*)(orig & (~1));
35827         orig_conv.is_owned = false;
35828         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35829         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
35830         uint64_t ret_ref = 0;
35831         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35832         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35833         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35834         ret_ref = (uint64_t)ret_var.inner;
35835         if (ret_var.is_owned) {
35836                 ret_ref |= 1;
35837         }
35838         return ret_ref;
35839 }
35840
35841 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
35842         LDKNodeAnnouncementInfo obj_conv;
35843         obj_conv.inner = (void*)(obj & (~1));
35844         obj_conv.is_owned = false;
35845         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35846         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
35847         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35848         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35849         CVec_u8Z_free(ret_var);
35850         return ret_arr;
35851 }
35852
35853 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35854         LDKu8slice ser_ref;
35855         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35856         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35857         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
35858         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
35859         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35860         return (uint64_t)ret_conv;
35861 }
35862
35863 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35864         LDKNodeInfo this_obj_conv;
35865         this_obj_conv.inner = (void*)(this_obj & (~1));
35866         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35867         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35868         NodeInfo_free(this_obj_conv);
35869 }
35870
35871 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35872         LDKNodeInfo this_ptr_conv;
35873         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35874         this_ptr_conv.is_owned = false;
35875         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35876         LDKCVec_u64Z val_constr;
35877         val_constr.datalen = (*env)->GetArrayLength(env, val);
35878         if (val_constr.datalen > 0)
35879                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35880         else
35881                 val_constr.data = NULL;
35882         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35883         for (size_t g = 0; g < val_constr.datalen; g++) {
35884                 int64_t val_conv_6 = val_vals[g];
35885                 val_constr.data[g] = val_conv_6;
35886         }
35887         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35888         NodeInfo_set_channels(&this_ptr_conv, val_constr);
35889 }
35890
35891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
35892         LDKNodeInfo this_ptr_conv;
35893         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35894         this_ptr_conv.is_owned = false;
35895         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35896         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
35897         uint64_t ret_ref = 0;
35898         if ((uint64_t)ret_var.inner > 4096) {
35899                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35900                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35901         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35902                 ret_ref = (uint64_t)ret_var.inner;
35903                 if (ret_var.is_owned) {
35904                         ret_ref |= 1;
35905                 }
35906         }
35907         return ret_ref;
35908 }
35909
35910 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35911         LDKNodeInfo this_ptr_conv;
35912         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35913         this_ptr_conv.is_owned = false;
35914         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35915         LDKRoutingFees val_conv;
35916         val_conv.inner = (void*)(val & (~1));
35917         val_conv.is_owned = (val & 1) || (val == 0);
35918         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35919         val_conv = RoutingFees_clone(&val_conv);
35920         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
35921 }
35922
35923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
35924         LDKNodeInfo this_ptr_conv;
35925         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35926         this_ptr_conv.is_owned = false;
35927         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35928         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
35929         uint64_t ret_ref = 0;
35930         if ((uint64_t)ret_var.inner > 4096) {
35931                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35932                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35933         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35934                 ret_ref = (uint64_t)ret_var.inner;
35935                 if (ret_var.is_owned) {
35936                         ret_ref |= 1;
35937                 }
35938         }
35939         return ret_ref;
35940 }
35941
35942 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35943         LDKNodeInfo this_ptr_conv;
35944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35945         this_ptr_conv.is_owned = false;
35946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35947         LDKNodeAnnouncementInfo val_conv;
35948         val_conv.inner = (void*)(val & (~1));
35949         val_conv.is_owned = (val & 1) || (val == 0);
35950         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35951         val_conv = NodeAnnouncementInfo_clone(&val_conv);
35952         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
35953 }
35954
35955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1new(JNIEnv *env, jclass clz, int64_tArray channels_arg, int64_t lowest_inbound_channel_fees_arg, int64_t announcement_info_arg) {
35956         LDKCVec_u64Z channels_arg_constr;
35957         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
35958         if (channels_arg_constr.datalen > 0)
35959                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35960         else
35961                 channels_arg_constr.data = NULL;
35962         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
35963         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
35964                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
35965                 channels_arg_constr.data[g] = channels_arg_conv_6;
35966         }
35967         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
35968         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
35969         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
35970         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
35971         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
35972         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
35973         LDKNodeAnnouncementInfo announcement_info_arg_conv;
35974         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
35975         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
35976         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
35977         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
35978         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
35979         uint64_t ret_ref = 0;
35980         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35981         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35982         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35983         ret_ref = (uint64_t)ret_var.inner;
35984         if (ret_var.is_owned) {
35985                 ret_ref |= 1;
35986         }
35987         return ret_ref;
35988 }
35989
35990 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
35991         LDKNodeInfo ret_var = NodeInfo_clone(arg);
35992 uint64_t ret_ref = 0;
35993 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35994 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35995 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35996 ret_ref = (uint64_t)ret_var.inner;
35997 if (ret_var.is_owned) {
35998         ret_ref |= 1;
35999 }
36000         return ret_ref;
36001 }
36002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36003         LDKNodeInfo arg_conv;
36004         arg_conv.inner = (void*)(arg & (~1));
36005         arg_conv.is_owned = false;
36006         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36007         int64_t ret_val = NodeInfo_clone_ptr(&arg_conv);
36008         return ret_val;
36009 }
36010
36011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36012         LDKNodeInfo orig_conv;
36013         orig_conv.inner = (void*)(orig & (~1));
36014         orig_conv.is_owned = false;
36015         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36016         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
36017         uint64_t ret_ref = 0;
36018         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36019         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36021         ret_ref = (uint64_t)ret_var.inner;
36022         if (ret_var.is_owned) {
36023                 ret_ref |= 1;
36024         }
36025         return ret_ref;
36026 }
36027
36028 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
36029         LDKNodeInfo obj_conv;
36030         obj_conv.inner = (void*)(obj & (~1));
36031         obj_conv.is_owned = false;
36032         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36033         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
36034         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36035         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36036         CVec_u8Z_free(ret_var);
36037         return ret_arr;
36038 }
36039
36040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36041         LDKu8slice ser_ref;
36042         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36043         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36044         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
36045         *ret_conv = NodeInfo_read(ser_ref);
36046         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36047         return (uint64_t)ret_conv;
36048 }
36049
36050 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
36051         LDKNetworkGraph obj_conv;
36052         obj_conv.inner = (void*)(obj & (~1));
36053         obj_conv.is_owned = false;
36054         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36055         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
36056         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36057         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36058         CVec_u8Z_free(ret_var);
36059         return ret_arr;
36060 }
36061
36062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36063         LDKu8slice ser_ref;
36064         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36065         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36066         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
36067         *ret_conv = NetworkGraph_read(ser_ref);
36068         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36069         return (uint64_t)ret_conv;
36070 }
36071
36072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
36073         LDKThirtyTwoBytes genesis_hash_ref;
36074         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
36075         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
36076         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
36077         uint64_t ret_ref = 0;
36078         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36079         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36080         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36081         ret_ref = (uint64_t)ret_var.inner;
36082         if (ret_var.is_owned) {
36083                 ret_ref |= 1;
36084         }
36085         return ret_ref;
36086 }
36087
36088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
36089         LDKNetworkGraph this_arg_conv;
36090         this_arg_conv.inner = (void*)(this_arg & (~1));
36091         this_arg_conv.is_owned = false;
36092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36093         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
36094         uint64_t ret_ref = 0;
36095         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36096         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36097         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36098         ret_ref = (uint64_t)ret_var.inner;
36099         if (ret_var.is_owned) {
36100                 ret_ref |= 1;
36101         }
36102         return ret_ref;
36103 }
36104
36105 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) {
36106         LDKNetworkGraph this_arg_conv;
36107         this_arg_conv.inner = (void*)(this_arg & (~1));
36108         this_arg_conv.is_owned = false;
36109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36110         LDKNodeAnnouncement msg_conv;
36111         msg_conv.inner = (void*)(msg & (~1));
36112         msg_conv.is_owned = false;
36113         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36114         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36115         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
36116         return (uint64_t)ret_conv;
36117 }
36118
36119 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) {
36120         LDKNetworkGraph this_arg_conv;
36121         this_arg_conv.inner = (void*)(this_arg & (~1));
36122         this_arg_conv.is_owned = false;
36123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36124         LDKUnsignedNodeAnnouncement msg_conv;
36125         msg_conv.inner = (void*)(msg & (~1));
36126         msg_conv.is_owned = false;
36127         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36128         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36129         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
36130         return (uint64_t)ret_conv;
36131 }
36132
36133 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 chain_access) {
36134         LDKNetworkGraph this_arg_conv;
36135         this_arg_conv.inner = (void*)(this_arg & (~1));
36136         this_arg_conv.is_owned = false;
36137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36138         LDKChannelAnnouncement msg_conv;
36139         msg_conv.inner = (void*)(msg & (~1));
36140         msg_conv.is_owned = false;
36141         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36142         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
36143         CHECK_ACCESS(chain_access_ptr);
36144         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36145         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
36146         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36147                 // Manually implement clone for Java trait instances
36148                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36149                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36150                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36151                 }
36152         }
36153         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36154         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
36155         return (uint64_t)ret_conv;
36156 }
36157
36158 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 chain_access) {
36159         LDKNetworkGraph this_arg_conv;
36160         this_arg_conv.inner = (void*)(this_arg & (~1));
36161         this_arg_conv.is_owned = false;
36162         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36163         LDKUnsignedChannelAnnouncement msg_conv;
36164         msg_conv.inner = (void*)(msg & (~1));
36165         msg_conv.is_owned = false;
36166         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36167         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
36168         CHECK_ACCESS(chain_access_ptr);
36169         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36170         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
36171         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36172                 // Manually implement clone for Java trait instances
36173                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36174                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36175                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36176                 }
36177         }
36178         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36179         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
36180         return (uint64_t)ret_conv;
36181 }
36182
36183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1close_1channel_1from_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t short_channel_id, jboolean is_permanent) {
36184         LDKNetworkGraph this_arg_conv;
36185         this_arg_conv.inner = (void*)(this_arg & (~1));
36186         this_arg_conv.is_owned = false;
36187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36188         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
36189 }
36190
36191 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1fail_1node(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray _node_id, jboolean is_permanent) {
36192         LDKNetworkGraph this_arg_conv;
36193         this_arg_conv.inner = (void*)(this_arg & (~1));
36194         this_arg_conv.is_owned = false;
36195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36196         LDKPublicKey _node_id_ref;
36197         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
36198         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
36199         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
36200 }
36201
36202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
36203         LDKNetworkGraph this_arg_conv;
36204         this_arg_conv.inner = (void*)(this_arg & (~1));
36205         this_arg_conv.is_owned = false;
36206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36207         LDKChannelUpdate msg_conv;
36208         msg_conv.inner = (void*)(msg & (~1));
36209         msg_conv.is_owned = false;
36210         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36211         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36212         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
36213         return (uint64_t)ret_conv;
36214 }
36215
36216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
36217         LDKNetworkGraph this_arg_conv;
36218         this_arg_conv.inner = (void*)(this_arg & (~1));
36219         this_arg_conv.is_owned = false;
36220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36221         LDKUnsignedChannelUpdate msg_conv;
36222         msg_conv.inner = (void*)(msg & (~1));
36223         msg_conv.is_owned = false;
36224         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36225         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36226         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
36227         return (uint64_t)ret_conv;
36228 }
36229
36230 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
36231         LDKReadOnlyNetworkGraph this_arg_conv;
36232         this_arg_conv.inner = (void*)(this_arg & (~1));
36233         this_arg_conv.is_owned = false;
36234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36235         LDKPublicKey pubkey_ref;
36236         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
36237         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
36238         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
36239         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
36240         uint64_t ret_ref = (uint64_t)ret_copy;
36241         return ret_ref;
36242 }
36243
36244 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36245         LDKRouteHop this_obj_conv;
36246         this_obj_conv.inner = (void*)(this_obj & (~1));
36247         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36248         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36249         RouteHop_free(this_obj_conv);
36250 }
36251
36252 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36253         LDKRouteHop this_ptr_conv;
36254         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36255         this_ptr_conv.is_owned = false;
36256         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36257         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36258         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
36259         return ret_arr;
36260 }
36261
36262 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36263         LDKRouteHop this_ptr_conv;
36264         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36265         this_ptr_conv.is_owned = false;
36266         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36267         LDKPublicKey val_ref;
36268         CHECK((*env)->GetArrayLength(env, val) == 33);
36269         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36270         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
36271 }
36272
36273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36274         LDKRouteHop this_ptr_conv;
36275         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36276         this_ptr_conv.is_owned = false;
36277         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36278         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
36279         uint64_t ret_ref = 0;
36280         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36281         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36282         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36283         ret_ref = (uint64_t)ret_var.inner;
36284         if (ret_var.is_owned) {
36285                 ret_ref |= 1;
36286         }
36287         return ret_ref;
36288 }
36289
36290 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36291         LDKRouteHop this_ptr_conv;
36292         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36293         this_ptr_conv.is_owned = false;
36294         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36295         LDKNodeFeatures val_conv;
36296         val_conv.inner = (void*)(val & (~1));
36297         val_conv.is_owned = (val & 1) || (val == 0);
36298         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36299         val_conv = NodeFeatures_clone(&val_conv);
36300         RouteHop_set_node_features(&this_ptr_conv, val_conv);
36301 }
36302
36303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36304         LDKRouteHop this_ptr_conv;
36305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36306         this_ptr_conv.is_owned = false;
36307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36308         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
36309         return ret_val;
36310 }
36311
36312 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36313         LDKRouteHop this_ptr_conv;
36314         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36315         this_ptr_conv.is_owned = false;
36316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36317         RouteHop_set_short_channel_id(&this_ptr_conv, val);
36318 }
36319
36320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36321         LDKRouteHop this_ptr_conv;
36322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36323         this_ptr_conv.is_owned = false;
36324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36325         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
36326         uint64_t ret_ref = 0;
36327         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36328         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36329         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36330         ret_ref = (uint64_t)ret_var.inner;
36331         if (ret_var.is_owned) {
36332                 ret_ref |= 1;
36333         }
36334         return ret_ref;
36335 }
36336
36337 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36338         LDKRouteHop this_ptr_conv;
36339         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36340         this_ptr_conv.is_owned = false;
36341         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36342         LDKChannelFeatures val_conv;
36343         val_conv.inner = (void*)(val & (~1));
36344         val_conv.is_owned = (val & 1) || (val == 0);
36345         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36346         val_conv = ChannelFeatures_clone(&val_conv);
36347         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
36348 }
36349
36350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36351         LDKRouteHop this_ptr_conv;
36352         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36353         this_ptr_conv.is_owned = false;
36354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36355         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
36356         return ret_val;
36357 }
36358
36359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36360         LDKRouteHop this_ptr_conv;
36361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36362         this_ptr_conv.is_owned = false;
36363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36364         RouteHop_set_fee_msat(&this_ptr_conv, val);
36365 }
36366
36367 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
36368         LDKRouteHop this_ptr_conv;
36369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36370         this_ptr_conv.is_owned = false;
36371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36372         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
36373         return ret_val;
36374 }
36375
36376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36377         LDKRouteHop this_ptr_conv;
36378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36379         this_ptr_conv.is_owned = false;
36380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36381         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
36382 }
36383
36384 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) {
36385         LDKPublicKey pubkey_arg_ref;
36386         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
36387         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
36388         LDKNodeFeatures node_features_arg_conv;
36389         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
36390         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
36391         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
36392         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
36393         LDKChannelFeatures channel_features_arg_conv;
36394         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
36395         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
36396         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
36397         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
36398         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);
36399         uint64_t ret_ref = 0;
36400         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36401         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36403         ret_ref = (uint64_t)ret_var.inner;
36404         if (ret_var.is_owned) {
36405                 ret_ref |= 1;
36406         }
36407         return ret_ref;
36408 }
36409
36410 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
36411         LDKRouteHop ret_var = RouteHop_clone(arg);
36412 uint64_t ret_ref = 0;
36413 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36414 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36415 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36416 ret_ref = (uint64_t)ret_var.inner;
36417 if (ret_var.is_owned) {
36418         ret_ref |= 1;
36419 }
36420         return ret_ref;
36421 }
36422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36423         LDKRouteHop arg_conv;
36424         arg_conv.inner = (void*)(arg & (~1));
36425         arg_conv.is_owned = false;
36426         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36427         int64_t ret_val = RouteHop_clone_ptr(&arg_conv);
36428         return ret_val;
36429 }
36430
36431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36432         LDKRouteHop orig_conv;
36433         orig_conv.inner = (void*)(orig & (~1));
36434         orig_conv.is_owned = false;
36435         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36436         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
36437         uint64_t ret_ref = 0;
36438         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36439         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36441         ret_ref = (uint64_t)ret_var.inner;
36442         if (ret_var.is_owned) {
36443                 ret_ref |= 1;
36444         }
36445         return ret_ref;
36446 }
36447
36448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
36449         LDKRouteHop o_conv;
36450         o_conv.inner = (void*)(o & (~1));
36451         o_conv.is_owned = false;
36452         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36453         int64_t ret_val = RouteHop_hash(&o_conv);
36454         return ret_val;
36455 }
36456
36457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36458         LDKRouteHop a_conv;
36459         a_conv.inner = (void*)(a & (~1));
36460         a_conv.is_owned = false;
36461         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36462         LDKRouteHop b_conv;
36463         b_conv.inner = (void*)(b & (~1));
36464         b_conv.is_owned = false;
36465         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36466         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
36467         return ret_val;
36468 }
36469
36470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
36471         LDKRouteHop obj_conv;
36472         obj_conv.inner = (void*)(obj & (~1));
36473         obj_conv.is_owned = false;
36474         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36475         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
36476         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36477         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36478         CVec_u8Z_free(ret_var);
36479         return ret_arr;
36480 }
36481
36482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36483         LDKu8slice ser_ref;
36484         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36485         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36486         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
36487         *ret_conv = RouteHop_read(ser_ref);
36488         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36489         return (uint64_t)ret_conv;
36490 }
36491
36492 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36493         LDKRoute this_obj_conv;
36494         this_obj_conv.inner = (void*)(this_obj & (~1));
36495         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36496         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36497         Route_free(this_obj_conv);
36498 }
36499
36500 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
36501         LDKRoute this_ptr_conv;
36502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36503         this_ptr_conv.is_owned = false;
36504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36505         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
36506         jobjectArray ret_arr = NULL;
36507         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
36508         ;
36509         for (size_t m = 0; m < ret_var.datalen; m++) {
36510                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
36511                 int64_tArray ret_conv_12_arr = NULL;
36512                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
36513                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
36514                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
36515                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
36516                         uint64_t ret_conv_12_conv_10_ref = 0;
36517                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36518                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36519                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
36520                         ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
36521                         if (ret_conv_12_conv_10_var.is_owned) {
36522                                 ret_conv_12_conv_10_ref |= 1;
36523                         }
36524                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
36525                 }
36526                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
36527                 FREE(ret_conv_12_var.data);
36528                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
36529         }
36530         
36531         FREE(ret_var.data);
36532         return ret_arr;
36533 }
36534
36535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
36536         LDKRoute this_ptr_conv;
36537         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36538         this_ptr_conv.is_owned = false;
36539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36540         LDKCVec_CVec_RouteHopZZ val_constr;
36541         val_constr.datalen = (*env)->GetArrayLength(env, val);
36542         if (val_constr.datalen > 0)
36543                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
36544         else
36545                 val_constr.data = NULL;
36546         for (size_t m = 0; m < val_constr.datalen; m++) {
36547                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
36548                 LDKCVec_RouteHopZ val_conv_12_constr;
36549                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
36550                 if (val_conv_12_constr.datalen > 0)
36551                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
36552                 else
36553                         val_conv_12_constr.data = NULL;
36554                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
36555                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
36556                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
36557                         LDKRouteHop val_conv_12_conv_10_conv;
36558                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
36559                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
36560                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
36561                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
36562                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
36563                 }
36564                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
36565                 val_constr.data[m] = val_conv_12_constr;
36566         }
36567         Route_set_paths(&this_ptr_conv, val_constr);
36568 }
36569
36570 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
36571         LDKRoute this_ptr_conv;
36572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36573         this_ptr_conv.is_owned = false;
36574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36575         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
36576         uint64_t ret_ref = 0;
36577         if ((uint64_t)ret_var.inner > 4096) {
36578                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36579                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36580         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36581                 ret_ref = (uint64_t)ret_var.inner;
36582                 if (ret_var.is_owned) {
36583                         ret_ref |= 1;
36584                 }
36585         }
36586         return ret_ref;
36587 }
36588
36589 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36590         LDKRoute this_ptr_conv;
36591         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36592         this_ptr_conv.is_owned = false;
36593         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36594         LDKPayee val_conv;
36595         val_conv.inner = (void*)(val & (~1));
36596         val_conv.is_owned = (val & 1) || (val == 0);
36597         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36598         val_conv = Payee_clone(&val_conv);
36599         Route_set_payee(&this_ptr_conv, val_conv);
36600 }
36601
36602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payee_arg) {
36603         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
36604         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
36605         if (paths_arg_constr.datalen > 0)
36606                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
36607         else
36608                 paths_arg_constr.data = NULL;
36609         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
36610                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
36611                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
36612                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
36613                 if (paths_arg_conv_12_constr.datalen > 0)
36614                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
36615                 else
36616                         paths_arg_conv_12_constr.data = NULL;
36617                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
36618                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
36619                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
36620                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
36621                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
36622                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
36623                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
36624                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
36625                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
36626                 }
36627                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
36628                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
36629         }
36630         LDKPayee payee_arg_conv;
36631         payee_arg_conv.inner = (void*)(payee_arg & (~1));
36632         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
36633         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
36634         payee_arg_conv = Payee_clone(&payee_arg_conv);
36635         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
36636         uint64_t ret_ref = 0;
36637         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36638         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36639         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36640         ret_ref = (uint64_t)ret_var.inner;
36641         if (ret_var.is_owned) {
36642                 ret_ref |= 1;
36643         }
36644         return ret_ref;
36645 }
36646
36647 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
36648         LDKRoute ret_var = Route_clone(arg);
36649 uint64_t ret_ref = 0;
36650 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36651 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36652 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36653 ret_ref = (uint64_t)ret_var.inner;
36654 if (ret_var.is_owned) {
36655         ret_ref |= 1;
36656 }
36657         return ret_ref;
36658 }
36659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36660         LDKRoute arg_conv;
36661         arg_conv.inner = (void*)(arg & (~1));
36662         arg_conv.is_owned = false;
36663         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36664         int64_t ret_val = Route_clone_ptr(&arg_conv);
36665         return ret_val;
36666 }
36667
36668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36669         LDKRoute orig_conv;
36670         orig_conv.inner = (void*)(orig & (~1));
36671         orig_conv.is_owned = false;
36672         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36673         LDKRoute ret_var = Route_clone(&orig_conv);
36674         uint64_t ret_ref = 0;
36675         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36676         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36677         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36678         ret_ref = (uint64_t)ret_var.inner;
36679         if (ret_var.is_owned) {
36680                 ret_ref |= 1;
36681         }
36682         return ret_ref;
36683 }
36684
36685 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
36686         LDKRoute o_conv;
36687         o_conv.inner = (void*)(o & (~1));
36688         o_conv.is_owned = false;
36689         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36690         int64_t ret_val = Route_hash(&o_conv);
36691         return ret_val;
36692 }
36693
36694 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36695         LDKRoute a_conv;
36696         a_conv.inner = (void*)(a & (~1));
36697         a_conv.is_owned = false;
36698         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36699         LDKRoute b_conv;
36700         b_conv.inner = (void*)(b & (~1));
36701         b_conv.is_owned = false;
36702         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36703         jboolean ret_val = Route_eq(&a_conv, &b_conv);
36704         return ret_val;
36705 }
36706
36707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
36708         LDKRoute this_arg_conv;
36709         this_arg_conv.inner = (void*)(this_arg & (~1));
36710         this_arg_conv.is_owned = false;
36711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36712         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
36713         return ret_val;
36714 }
36715
36716 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
36717         LDKRoute this_arg_conv;
36718         this_arg_conv.inner = (void*)(this_arg & (~1));
36719         this_arg_conv.is_owned = false;
36720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36721         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
36722         return ret_val;
36723 }
36724
36725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
36726         LDKRoute obj_conv;
36727         obj_conv.inner = (void*)(obj & (~1));
36728         obj_conv.is_owned = false;
36729         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36730         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
36731         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36732         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36733         CVec_u8Z_free(ret_var);
36734         return ret_arr;
36735 }
36736
36737 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36738         LDKu8slice ser_ref;
36739         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36740         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36741         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
36742         *ret_conv = Route_read(ser_ref);
36743         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36744         return (uint64_t)ret_conv;
36745 }
36746
36747 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36748         LDKRouteParameters this_obj_conv;
36749         this_obj_conv.inner = (void*)(this_obj & (~1));
36750         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36751         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36752         RouteParameters_free(this_obj_conv);
36753 }
36754
36755 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
36756         LDKRouteParameters this_ptr_conv;
36757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36758         this_ptr_conv.is_owned = false;
36759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36760         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
36761         uint64_t ret_ref = 0;
36762         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36763         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36764         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36765         ret_ref = (uint64_t)ret_var.inner;
36766         if (ret_var.is_owned) {
36767                 ret_ref |= 1;
36768         }
36769         return ret_ref;
36770 }
36771
36772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36773         LDKRouteParameters this_ptr_conv;
36774         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36775         this_ptr_conv.is_owned = false;
36776         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36777         LDKPayee val_conv;
36778         val_conv.inner = (void*)(val & (~1));
36779         val_conv.is_owned = (val & 1) || (val == 0);
36780         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36781         val_conv = Payee_clone(&val_conv);
36782         RouteParameters_set_payee(&this_ptr_conv, val_conv);
36783 }
36784
36785 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36786         LDKRouteParameters this_ptr_conv;
36787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36788         this_ptr_conv.is_owned = false;
36789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36790         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
36791         return ret_val;
36792 }
36793
36794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36795         LDKRouteParameters this_ptr_conv;
36796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36797         this_ptr_conv.is_owned = false;
36798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36799         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
36800 }
36801
36802 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
36803         LDKRouteParameters this_ptr_conv;
36804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36805         this_ptr_conv.is_owned = false;
36806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36807         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
36808         return ret_val;
36809 }
36810
36811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36812         LDKRouteParameters this_ptr_conv;
36813         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36814         this_ptr_conv.is_owned = false;
36815         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36816         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
36817 }
36818
36819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1new(JNIEnv *env, jclass clz, int64_t payee_arg, int64_t final_value_msat_arg, int32_t final_cltv_expiry_delta_arg) {
36820         LDKPayee payee_arg_conv;
36821         payee_arg_conv.inner = (void*)(payee_arg & (~1));
36822         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
36823         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
36824         payee_arg_conv = Payee_clone(&payee_arg_conv);
36825         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
36826         uint64_t ret_ref = 0;
36827         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36828         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36829         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36830         ret_ref = (uint64_t)ret_var.inner;
36831         if (ret_var.is_owned) {
36832                 ret_ref |= 1;
36833         }
36834         return ret_ref;
36835 }
36836
36837 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
36838         LDKRouteParameters ret_var = RouteParameters_clone(arg);
36839 uint64_t ret_ref = 0;
36840 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36841 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36842 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36843 ret_ref = (uint64_t)ret_var.inner;
36844 if (ret_var.is_owned) {
36845         ret_ref |= 1;
36846 }
36847         return ret_ref;
36848 }
36849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36850         LDKRouteParameters arg_conv;
36851         arg_conv.inner = (void*)(arg & (~1));
36852         arg_conv.is_owned = false;
36853         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36854         int64_t ret_val = RouteParameters_clone_ptr(&arg_conv);
36855         return ret_val;
36856 }
36857
36858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36859         LDKRouteParameters orig_conv;
36860         orig_conv.inner = (void*)(orig & (~1));
36861         orig_conv.is_owned = false;
36862         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36863         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
36864         uint64_t ret_ref = 0;
36865         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36866         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36867         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36868         ret_ref = (uint64_t)ret_var.inner;
36869         if (ret_var.is_owned) {
36870                 ret_ref |= 1;
36871         }
36872         return ret_ref;
36873 }
36874
36875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
36876         LDKRouteParameters obj_conv;
36877         obj_conv.inner = (void*)(obj & (~1));
36878         obj_conv.is_owned = false;
36879         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36880         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
36881         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36882         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36883         CVec_u8Z_free(ret_var);
36884         return ret_arr;
36885 }
36886
36887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36888         LDKu8slice ser_ref;
36889         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36890         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36891         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
36892         *ret_conv = RouteParameters_read(ser_ref);
36893         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36894         return (uint64_t)ret_conv;
36895 }
36896
36897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36898         LDKPayee this_obj_conv;
36899         this_obj_conv.inner = (void*)(this_obj & (~1));
36900         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36901         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36902         Payee_free(this_obj_conv);
36903 }
36904
36905 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36906         LDKPayee this_ptr_conv;
36907         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36908         this_ptr_conv.is_owned = false;
36909         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36910         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36911         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Payee_get_pubkey(&this_ptr_conv).compressed_form);
36912         return ret_arr;
36913 }
36914
36915 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36916         LDKPayee this_ptr_conv;
36917         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36918         this_ptr_conv.is_owned = false;
36919         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36920         LDKPublicKey val_ref;
36921         CHECK((*env)->GetArrayLength(env, val) == 33);
36922         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36923         Payee_set_pubkey(&this_ptr_conv, val_ref);
36924 }
36925
36926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36927         LDKPayee this_ptr_conv;
36928         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36929         this_ptr_conv.is_owned = false;
36930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36931         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
36932         uint64_t ret_ref = 0;
36933         if ((uint64_t)ret_var.inner > 4096) {
36934                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36935                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36936         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36937                 ret_ref = (uint64_t)ret_var.inner;
36938                 if (ret_var.is_owned) {
36939                         ret_ref |= 1;
36940                 }
36941         }
36942         return ret_ref;
36943 }
36944
36945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36946         LDKPayee this_ptr_conv;
36947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36948         this_ptr_conv.is_owned = false;
36949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36950         LDKInvoiceFeatures val_conv;
36951         val_conv.inner = (void*)(val & (~1));
36952         val_conv.is_owned = (val & 1) || (val == 0);
36953         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36954         val_conv = InvoiceFeatures_clone(&val_conv);
36955         Payee_set_features(&this_ptr_conv, val_conv);
36956 }
36957
36958 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
36959         LDKPayee this_ptr_conv;
36960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36961         this_ptr_conv.is_owned = false;
36962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36963         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
36964         int64_tArray ret_arr = NULL;
36965         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36966         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36967         for (size_t l = 0; l < ret_var.datalen; l++) {
36968                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
36969                 uint64_t ret_conv_11_ref = 0;
36970                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36971                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36972                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
36973                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
36974                 if (ret_conv_11_var.is_owned) {
36975                         ret_conv_11_ref |= 1;
36976                 }
36977                 ret_arr_ptr[l] = ret_conv_11_ref;
36978         }
36979         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36980         FREE(ret_var.data);
36981         return ret_arr;
36982 }
36983
36984 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36985         LDKPayee this_ptr_conv;
36986         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36987         this_ptr_conv.is_owned = false;
36988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36989         LDKCVec_RouteHintZ val_constr;
36990         val_constr.datalen = (*env)->GetArrayLength(env, val);
36991         if (val_constr.datalen > 0)
36992                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
36993         else
36994                 val_constr.data = NULL;
36995         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36996         for (size_t l = 0; l < val_constr.datalen; l++) {
36997                 int64_t val_conv_11 = val_vals[l];
36998                 LDKRouteHint val_conv_11_conv;
36999                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
37000                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
37001                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
37002                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
37003                 val_constr.data[l] = val_conv_11_conv;
37004         }
37005         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37006         Payee_set_route_hints(&this_ptr_conv, val_constr);
37007 }
37008
37009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
37010         LDKPayee this_ptr_conv;
37011         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37012         this_ptr_conv.is_owned = false;
37013         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37014         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37015         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
37016         uint64_t ret_ref = (uint64_t)ret_copy;
37017         return ret_ref;
37018 }
37019
37020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37021         LDKPayee this_ptr_conv;
37022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37023         this_ptr_conv.is_owned = false;
37024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37025         void* val_ptr = (void*)(((uint64_t)val) & ~1);
37026         CHECK_ACCESS(val_ptr);
37027         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37028         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
37029         Payee_set_expiry_time(&this_ptr_conv, val_conv);
37030 }
37031
37032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1new(JNIEnv *env, jclass clz, int8_tArray pubkey_arg, int64_t features_arg, int64_tArray route_hints_arg, int64_t expiry_time_arg) {
37033         LDKPublicKey pubkey_arg_ref;
37034         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
37035         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
37036         LDKInvoiceFeatures features_arg_conv;
37037         features_arg_conv.inner = (void*)(features_arg & (~1));
37038         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37039         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37040         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
37041         LDKCVec_RouteHintZ route_hints_arg_constr;
37042         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
37043         if (route_hints_arg_constr.datalen > 0)
37044                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37045         else
37046                 route_hints_arg_constr.data = NULL;
37047         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
37048         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
37049                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
37050                 LDKRouteHint route_hints_arg_conv_11_conv;
37051                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
37052                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
37053                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
37054                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
37055                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
37056         }
37057         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
37058         void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
37059         CHECK_ACCESS(expiry_time_arg_ptr);
37060         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
37061         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
37062         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
37063         uint64_t ret_ref = 0;
37064         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37065         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37066         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37067         ret_ref = (uint64_t)ret_var.inner;
37068         if (ret_var.is_owned) {
37069                 ret_ref |= 1;
37070         }
37071         return ret_ref;
37072 }
37073
37074 static inline uint64_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
37075         LDKPayee ret_var = Payee_clone(arg);
37076 uint64_t ret_ref = 0;
37077 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37078 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37079 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37080 ret_ref = (uint64_t)ret_var.inner;
37081 if (ret_var.is_owned) {
37082         ret_ref |= 1;
37083 }
37084         return ret_ref;
37085 }
37086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37087         LDKPayee arg_conv;
37088         arg_conv.inner = (void*)(arg & (~1));
37089         arg_conv.is_owned = false;
37090         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37091         int64_t ret_val = Payee_clone_ptr(&arg_conv);
37092         return ret_val;
37093 }
37094
37095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37096         LDKPayee orig_conv;
37097         orig_conv.inner = (void*)(orig & (~1));
37098         orig_conv.is_owned = false;
37099         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37100         LDKPayee ret_var = Payee_clone(&orig_conv);
37101         uint64_t ret_ref = 0;
37102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37105         ret_ref = (uint64_t)ret_var.inner;
37106         if (ret_var.is_owned) {
37107                 ret_ref |= 1;
37108         }
37109         return ret_ref;
37110 }
37111
37112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1hash(JNIEnv *env, jclass clz, int64_t o) {
37113         LDKPayee o_conv;
37114         o_conv.inner = (void*)(o & (~1));
37115         o_conv.is_owned = false;
37116         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37117         int64_t ret_val = Payee_hash(&o_conv);
37118         return ret_val;
37119 }
37120
37121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Payee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37122         LDKPayee a_conv;
37123         a_conv.inner = (void*)(a & (~1));
37124         a_conv.is_owned = false;
37125         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37126         LDKPayee b_conv;
37127         b_conv.inner = (void*)(b & (~1));
37128         b_conv.is_owned = false;
37129         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37130         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
37131         return ret_val;
37132 }
37133
37134 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1write(JNIEnv *env, jclass clz, int64_t obj) {
37135         LDKPayee obj_conv;
37136         obj_conv.inner = (void*)(obj & (~1));
37137         obj_conv.is_owned = false;
37138         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37139         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
37140         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37141         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37142         CVec_u8Z_free(ret_var);
37143         return ret_arr;
37144 }
37145
37146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37147         LDKu8slice ser_ref;
37148         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37149         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37150         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
37151         *ret_conv = Payee_read(ser_ref);
37152         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37153         return (uint64_t)ret_conv;
37154 }
37155
37156 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray pubkey) {
37157         LDKPublicKey pubkey_ref;
37158         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
37159         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
37160         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
37161         uint64_t ret_ref = 0;
37162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37165         ret_ref = (uint64_t)ret_var.inner;
37166         if (ret_var.is_owned) {
37167                 ret_ref |= 1;
37168         }
37169         return ret_ref;
37170 }
37171
37172 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray pubkey) {
37173         LDKPublicKey pubkey_ref;
37174         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
37175         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
37176         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
37177         uint64_t ret_ref = 0;
37178         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37179         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37181         ret_ref = (uint64_t)ret_var.inner;
37182         if (ret_var.is_owned) {
37183                 ret_ref |= 1;
37184         }
37185         return ret_ref;
37186 }
37187
37188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37189         LDKRouteHint this_obj_conv;
37190         this_obj_conv.inner = (void*)(this_obj & (~1));
37191         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37193         RouteHint_free(this_obj_conv);
37194 }
37195
37196 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
37197         LDKRouteHint this_ptr_conv;
37198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37199         this_ptr_conv.is_owned = false;
37200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37201         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
37202         int64_tArray ret_arr = NULL;
37203         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37204         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37205         for (size_t o = 0; o < ret_var.datalen; o++) {
37206                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
37207                 uint64_t ret_conv_14_ref = 0;
37208                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37209                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37210                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
37211                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
37212                 if (ret_conv_14_var.is_owned) {
37213                         ret_conv_14_ref |= 1;
37214                 }
37215                 ret_arr_ptr[o] = ret_conv_14_ref;
37216         }
37217         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37218         FREE(ret_var.data);
37219         return ret_arr;
37220 }
37221
37222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37223         LDKRouteHint this_ptr_conv;
37224         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37225         this_ptr_conv.is_owned = false;
37226         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37227         LDKCVec_RouteHintHopZ val_constr;
37228         val_constr.datalen = (*env)->GetArrayLength(env, val);
37229         if (val_constr.datalen > 0)
37230                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
37231         else
37232                 val_constr.data = NULL;
37233         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37234         for (size_t o = 0; o < val_constr.datalen; o++) {
37235                 int64_t val_conv_14 = val_vals[o];
37236                 LDKRouteHintHop val_conv_14_conv;
37237                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
37238                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
37239                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
37240                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
37241                 val_constr.data[o] = val_conv_14_conv;
37242         }
37243         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37244         RouteHint_set_a(&this_ptr_conv, val_constr);
37245 }
37246
37247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
37248         LDKCVec_RouteHintHopZ a_arg_constr;
37249         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
37250         if (a_arg_constr.datalen > 0)
37251                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
37252         else
37253                 a_arg_constr.data = NULL;
37254         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
37255         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
37256                 int64_t a_arg_conv_14 = a_arg_vals[o];
37257                 LDKRouteHintHop a_arg_conv_14_conv;
37258                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
37259                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
37260                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
37261                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
37262                 a_arg_constr.data[o] = a_arg_conv_14_conv;
37263         }
37264         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
37265         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
37266         uint64_t ret_ref = 0;
37267         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37268         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37269         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37270         ret_ref = (uint64_t)ret_var.inner;
37271         if (ret_var.is_owned) {
37272                 ret_ref |= 1;
37273         }
37274         return ret_ref;
37275 }
37276
37277 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
37278         LDKRouteHint ret_var = RouteHint_clone(arg);
37279 uint64_t ret_ref = 0;
37280 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37281 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37282 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37283 ret_ref = (uint64_t)ret_var.inner;
37284 if (ret_var.is_owned) {
37285         ret_ref |= 1;
37286 }
37287         return ret_ref;
37288 }
37289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37290         LDKRouteHint arg_conv;
37291         arg_conv.inner = (void*)(arg & (~1));
37292         arg_conv.is_owned = false;
37293         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37294         int64_t ret_val = RouteHint_clone_ptr(&arg_conv);
37295         return ret_val;
37296 }
37297
37298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37299         LDKRouteHint orig_conv;
37300         orig_conv.inner = (void*)(orig & (~1));
37301         orig_conv.is_owned = false;
37302         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37303         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
37304         uint64_t ret_ref = 0;
37305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37308         ret_ref = (uint64_t)ret_var.inner;
37309         if (ret_var.is_owned) {
37310                 ret_ref |= 1;
37311         }
37312         return ret_ref;
37313 }
37314
37315 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
37316         LDKRouteHint o_conv;
37317         o_conv.inner = (void*)(o & (~1));
37318         o_conv.is_owned = false;
37319         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37320         int64_t ret_val = RouteHint_hash(&o_conv);
37321         return ret_val;
37322 }
37323
37324 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37325         LDKRouteHint a_conv;
37326         a_conv.inner = (void*)(a & (~1));
37327         a_conv.is_owned = false;
37328         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37329         LDKRouteHint b_conv;
37330         b_conv.inner = (void*)(b & (~1));
37331         b_conv.is_owned = false;
37332         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37333         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
37334         return ret_val;
37335 }
37336
37337 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
37338         LDKRouteHint obj_conv;
37339         obj_conv.inner = (void*)(obj & (~1));
37340         obj_conv.is_owned = false;
37341         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37342         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
37343         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37344         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37345         CVec_u8Z_free(ret_var);
37346         return ret_arr;
37347 }
37348
37349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37350         LDKu8slice ser_ref;
37351         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37352         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37353         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
37354         *ret_conv = RouteHint_read(ser_ref);
37355         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37356         return (uint64_t)ret_conv;
37357 }
37358
37359 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37360         LDKRouteHintHop this_obj_conv;
37361         this_obj_conv.inner = (void*)(this_obj & (~1));
37362         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37364         RouteHintHop_free(this_obj_conv);
37365 }
37366
37367 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37368         LDKRouteHintHop this_ptr_conv;
37369         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37370         this_ptr_conv.is_owned = false;
37371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37372         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37373         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
37374         return ret_arr;
37375 }
37376
37377 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37378         LDKRouteHintHop this_ptr_conv;
37379         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37380         this_ptr_conv.is_owned = false;
37381         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37382         LDKPublicKey val_ref;
37383         CHECK((*env)->GetArrayLength(env, val) == 33);
37384         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37385         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
37386 }
37387
37388 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37389         LDKRouteHintHop this_ptr_conv;
37390         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37391         this_ptr_conv.is_owned = false;
37392         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37393         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
37394         return ret_val;
37395 }
37396
37397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37398         LDKRouteHintHop this_ptr_conv;
37399         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37400         this_ptr_conv.is_owned = false;
37401         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37402         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
37403 }
37404
37405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
37406         LDKRouteHintHop this_ptr_conv;
37407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37408         this_ptr_conv.is_owned = false;
37409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37410         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
37411         uint64_t ret_ref = 0;
37412         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37413         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37414         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37415         ret_ref = (uint64_t)ret_var.inner;
37416         if (ret_var.is_owned) {
37417                 ret_ref |= 1;
37418         }
37419         return ret_ref;
37420 }
37421
37422 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37423         LDKRouteHintHop this_ptr_conv;
37424         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37425         this_ptr_conv.is_owned = false;
37426         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37427         LDKRoutingFees val_conv;
37428         val_conv.inner = (void*)(val & (~1));
37429         val_conv.is_owned = (val & 1) || (val == 0);
37430         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37431         val_conv = RoutingFees_clone(&val_conv);
37432         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
37433 }
37434
37435 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
37436         LDKRouteHintHop this_ptr_conv;
37437         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37438         this_ptr_conv.is_owned = false;
37439         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37440         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
37441         return ret_val;
37442 }
37443
37444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37445         LDKRouteHintHop this_ptr_conv;
37446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37447         this_ptr_conv.is_owned = false;
37448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37449         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37450 }
37451
37452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37453         LDKRouteHintHop this_ptr_conv;
37454         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37455         this_ptr_conv.is_owned = false;
37456         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37457         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37458         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
37459         uint64_t ret_ref = (uint64_t)ret_copy;
37460         return ret_ref;
37461 }
37462
37463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37464         LDKRouteHintHop this_ptr_conv;
37465         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37466         this_ptr_conv.is_owned = false;
37467         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37468         void* val_ptr = (void*)(((uint64_t)val) & ~1);
37469         CHECK_ACCESS(val_ptr);
37470         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37471         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
37472         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
37473 }
37474
37475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37476         LDKRouteHintHop this_ptr_conv;
37477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37478         this_ptr_conv.is_owned = false;
37479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37480         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37481         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
37482         uint64_t ret_ref = (uint64_t)ret_copy;
37483         return ret_ref;
37484 }
37485
37486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37487         LDKRouteHintHop this_ptr_conv;
37488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37489         this_ptr_conv.is_owned = false;
37490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37491         void* val_ptr = (void*)(((uint64_t)val) & ~1);
37492         CHECK_ACCESS(val_ptr);
37493         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37494         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
37495         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
37496 }
37497
37498 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) {
37499         LDKPublicKey src_node_id_arg_ref;
37500         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
37501         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
37502         LDKRoutingFees fees_arg_conv;
37503         fees_arg_conv.inner = (void*)(fees_arg & (~1));
37504         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
37505         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
37506         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
37507         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
37508         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
37509         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
37510         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
37511         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
37512         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
37513         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
37514         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
37515         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);
37516         uint64_t ret_ref = 0;
37517         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37518         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37519         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37520         ret_ref = (uint64_t)ret_var.inner;
37521         if (ret_var.is_owned) {
37522                 ret_ref |= 1;
37523         }
37524         return ret_ref;
37525 }
37526
37527 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
37528         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
37529 uint64_t ret_ref = 0;
37530 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37531 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37532 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37533 ret_ref = (uint64_t)ret_var.inner;
37534 if (ret_var.is_owned) {
37535         ret_ref |= 1;
37536 }
37537         return ret_ref;
37538 }
37539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37540         LDKRouteHintHop arg_conv;
37541         arg_conv.inner = (void*)(arg & (~1));
37542         arg_conv.is_owned = false;
37543         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37544         int64_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
37545         return ret_val;
37546 }
37547
37548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37549         LDKRouteHintHop orig_conv;
37550         orig_conv.inner = (void*)(orig & (~1));
37551         orig_conv.is_owned = false;
37552         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37553         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
37554         uint64_t ret_ref = 0;
37555         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37556         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37557         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37558         ret_ref = (uint64_t)ret_var.inner;
37559         if (ret_var.is_owned) {
37560                 ret_ref |= 1;
37561         }
37562         return ret_ref;
37563 }
37564
37565 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
37566         LDKRouteHintHop o_conv;
37567         o_conv.inner = (void*)(o & (~1));
37568         o_conv.is_owned = false;
37569         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37570         int64_t ret_val = RouteHintHop_hash(&o_conv);
37571         return ret_val;
37572 }
37573
37574 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37575         LDKRouteHintHop a_conv;
37576         a_conv.inner = (void*)(a & (~1));
37577         a_conv.is_owned = false;
37578         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37579         LDKRouteHintHop b_conv;
37580         b_conv.inner = (void*)(b & (~1));
37581         b_conv.is_owned = false;
37582         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37583         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
37584         return ret_val;
37585 }
37586
37587 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
37588         LDKRouteHintHop obj_conv;
37589         obj_conv.inner = (void*)(obj & (~1));
37590         obj_conv.is_owned = false;
37591         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37592         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
37593         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37594         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37595         CVec_u8Z_free(ret_var);
37596         return ret_arr;
37597 }
37598
37599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37600         LDKu8slice ser_ref;
37601         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37602         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37603         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
37604         *ret_conv = RouteHintHop_read(ser_ref);
37605         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37606         return (uint64_t)ret_conv;
37607 }
37608
37609 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_find_1route(JNIEnv *env, jclass clz, int8_tArray our_node_pubkey, int64_t params, int64_t network, int64_tArray first_hops, int64_t logger, int64_t scorer) {
37610         LDKPublicKey our_node_pubkey_ref;
37611         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
37612         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
37613         LDKRouteParameters params_conv;
37614         params_conv.inner = (void*)(params & (~1));
37615         params_conv.is_owned = false;
37616         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
37617         LDKNetworkGraph network_conv;
37618         network_conv.inner = (void*)(network & (~1));
37619         network_conv.is_owned = false;
37620         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
37621         LDKCVec_ChannelDetailsZ first_hops_constr;
37622         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
37623         if (first_hops != NULL) {
37624                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
37625                 if (first_hops_constr.datalen > 0)
37626                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
37627                 else
37628                         first_hops_constr.data = NULL;
37629                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
37630                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
37631                         int64_t first_hops_conv_16 = first_hops_vals[q];
37632                         LDKChannelDetails first_hops_conv_16_conv;
37633                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
37634                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
37635                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
37636                         first_hops_constr.data[q] = first_hops_conv_16_conv;
37637                 }
37638                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
37639                 first_hops_ptr = &first_hops_constr;
37640         }
37641         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
37642         CHECK_ACCESS(logger_ptr);
37643         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37644         if (logger_conv.free == LDKLogger_JCalls_free) {
37645                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37646                 LDKLogger_JCalls_cloned(&logger_conv);
37647         }
37648         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
37649         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
37650         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
37651         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
37652         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
37653         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
37654         return (uint64_t)ret_conv;
37655 }
37656
37657 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37658         LDKScorer this_obj_conv;
37659         this_obj_conv.inner = (void*)(this_obj & (~1));
37660         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37661         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37662         Scorer_free(this_obj_conv);
37663 }
37664
37665 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37666         LDKScoringParameters this_obj_conv;
37667         this_obj_conv.inner = (void*)(this_obj & (~1));
37668         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37669         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37670         ScoringParameters_free(this_obj_conv);
37671 }
37672
37673 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37674         LDKScoringParameters this_ptr_conv;
37675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37676         this_ptr_conv.is_owned = false;
37677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37678         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
37679         return ret_val;
37680 }
37681
37682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37683         LDKScoringParameters this_ptr_conv;
37684         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37685         this_ptr_conv.is_owned = false;
37686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37687         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
37688 }
37689
37690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37691         LDKScoringParameters this_ptr_conv;
37692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37693         this_ptr_conv.is_owned = false;
37694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37695         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
37696         return ret_val;
37697 }
37698
37699 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37700         LDKScoringParameters this_ptr_conv;
37701         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37702         this_ptr_conv.is_owned = false;
37703         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37704         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
37705 }
37706
37707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
37708         LDKScoringParameters this_ptr_conv;
37709         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37710         this_ptr_conv.is_owned = false;
37711         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37712         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
37713         return ret_val;
37714 }
37715
37716 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37717         LDKScoringParameters this_ptr_conv;
37718         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37719         this_ptr_conv.is_owned = false;
37720         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37721         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
37722 }
37723
37724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1new(JNIEnv *env, jclass clz, int64_t base_penalty_msat_arg, int64_t failure_penalty_msat_arg, int64_t failure_penalty_half_life_arg) {
37725         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
37726         uint64_t ret_ref = 0;
37727         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37728         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37730         ret_ref = (uint64_t)ret_var.inner;
37731         if (ret_var.is_owned) {
37732                 ret_ref |= 1;
37733         }
37734         return ret_ref;
37735 }
37736
37737 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37738         LDKScoringParameters obj_conv;
37739         obj_conv.inner = (void*)(obj & (~1));
37740         obj_conv.is_owned = false;
37741         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37742         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
37743         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37744         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37745         CVec_u8Z_free(ret_var);
37746         return ret_arr;
37747 }
37748
37749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37750         LDKu8slice ser_ref;
37751         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37752         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37753         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
37754         *ret_conv = ScoringParameters_read(ser_ref);
37755         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37756         return (uint64_t)ret_conv;
37757 }
37758
37759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
37760         LDKScoringParameters params_conv;
37761         params_conv.inner = (void*)(params & (~1));
37762         params_conv.is_owned = (params & 1) || (params == 0);
37763         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
37764         // Warning: we need a move here but no clone is available for LDKScoringParameters
37765         LDKScorer ret_var = Scorer_new(params_conv);
37766         uint64_t ret_ref = 0;
37767         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37768         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37769         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37770         ret_ref = (uint64_t)ret_var.inner;
37771         if (ret_var.is_owned) {
37772                 ret_ref |= 1;
37773         }
37774         return ret_ref;
37775 }
37776
37777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
37778         LDKScorer ret_var = Scorer_default();
37779         uint64_t ret_ref = 0;
37780         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37781         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37782         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37783         ret_ref = (uint64_t)ret_var.inner;
37784         if (ret_var.is_owned) {
37785                 ret_ref |= 1;
37786         }
37787         return ret_ref;
37788 }
37789
37790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
37791         LDKScoringParameters ret_var = ScoringParameters_default();
37792         uint64_t ret_ref = 0;
37793         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37794         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37795         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37796         ret_ref = (uint64_t)ret_var.inner;
37797         if (ret_var.is_owned) {
37798                 ret_ref |= 1;
37799         }
37800         return ret_ref;
37801 }
37802
37803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
37804         LDKScorer this_arg_conv;
37805         this_arg_conv.inner = (void*)(this_arg & (~1));
37806         this_arg_conv.is_owned = false;
37807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37808         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
37809         *ret_ret = Scorer_as_Score(&this_arg_conv);
37810         return (uint64_t)ret_ret;
37811 }
37812
37813 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
37814         LDKScorer obj_conv;
37815         obj_conv.inner = (void*)(obj & (~1));
37816         obj_conv.is_owned = false;
37817         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37818         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
37819         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37820         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37821         CVec_u8Z_free(ret_var);
37822         return ret_arr;
37823 }
37824
37825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37826         LDKu8slice ser_ref;
37827         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37828         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37829         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
37830         *ret_conv = Scorer_read(ser_ref);
37831         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37832         return (uint64_t)ret_conv;
37833 }
37834
37835 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37836         LDKFilesystemPersister this_obj_conv;
37837         this_obj_conv.inner = (void*)(this_obj & (~1));
37838         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37839         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37840         FilesystemPersister_free(this_obj_conv);
37841 }
37842
37843 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
37844         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
37845         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
37846         uint64_t ret_ref = 0;
37847         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37848         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37849         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37850         ret_ref = (uint64_t)ret_var.inner;
37851         if (ret_var.is_owned) {
37852                 ret_ref |= 1;
37853         }
37854         return ret_ref;
37855 }
37856
37857 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
37858         LDKFilesystemPersister this_arg_conv;
37859         this_arg_conv.inner = (void*)(this_arg & (~1));
37860         this_arg_conv.is_owned = false;
37861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37862         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
37863         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
37864         Str_free(ret_str);
37865         return ret_conv;
37866 }
37867
37868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
37869         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
37870         LDKChannelManager manager_conv;
37871         manager_conv.inner = (void*)(manager & (~1));
37872         manager_conv.is_owned = false;
37873         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
37874         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
37875         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
37876         return (uint64_t)ret_conv;
37877 }
37878
37879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
37880         LDKFilesystemPersister this_arg_conv;
37881         this_arg_conv.inner = (void*)(this_arg & (~1));
37882         this_arg_conv.is_owned = false;
37883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37884         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
37885         CHECK_ACCESS(keys_manager_ptr);
37886         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
37887         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
37888                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37889                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
37890         }
37891         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
37892         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
37893         return (uint64_t)ret_conv;
37894 }
37895
37896 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
37897         LDKFilesystemPersister this_arg_conv;
37898         this_arg_conv.inner = (void*)(this_arg & (~1));
37899         this_arg_conv.is_owned = false;
37900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37901         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
37902         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
37903         return (uint64_t)ret_ret;
37904 }
37905
37906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37907         LDKBackgroundProcessor this_obj_conv;
37908         this_obj_conv.inner = (void*)(this_obj & (~1));
37909         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37911         BackgroundProcessor_free(this_obj_conv);
37912 }
37913
37914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37915         if ((this_ptr & 1) != 0) return;
37916         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
37917         CHECK_ACCESS(this_ptr_ptr);
37918         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
37919         FREE((void*)this_ptr);
37920         ChannelManagerPersister_free(this_ptr_conv);
37921 }
37922
37923 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 net_graph_msg_handler, int64_t peer_manager, int64_t logger) {
37924         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
37925         CHECK_ACCESS(persister_ptr);
37926         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
37927         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
37928                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37929                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
37930         }
37931         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
37932         CHECK_ACCESS(event_handler_ptr);
37933         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
37934         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
37935                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37936                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
37937         }
37938         LDKChainMonitor chain_monitor_conv;
37939         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
37940         chain_monitor_conv.is_owned = false;
37941         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
37942         LDKChannelManager channel_manager_conv;
37943         channel_manager_conv.inner = (void*)(channel_manager & (~1));
37944         channel_manager_conv.is_owned = false;
37945         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
37946         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
37947         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
37948         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
37949         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
37950         LDKPeerManager peer_manager_conv;
37951         peer_manager_conv.inner = (void*)(peer_manager & (~1));
37952         peer_manager_conv.is_owned = false;
37953         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
37954         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
37955         CHECK_ACCESS(logger_ptr);
37956         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37957         if (logger_conv.free == LDKLogger_JCalls_free) {
37958                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37959                 LDKLogger_JCalls_cloned(&logger_conv);
37960         }
37961         LDKBackgroundProcessor ret_var = BackgroundProcessor_start(persister_conv, event_handler_conv, &chain_monitor_conv, &channel_manager_conv, net_graph_msg_handler_conv, &peer_manager_conv, logger_conv);
37962         uint64_t ret_ref = 0;
37963         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37964         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37966         ret_ref = (uint64_t)ret_var.inner;
37967         if (ret_var.is_owned) {
37968                 ret_ref |= 1;
37969         }
37970         return ret_ref;
37971 }
37972
37973 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
37974         LDKBackgroundProcessor this_arg_conv;
37975         this_arg_conv.inner = (void*)(this_arg & (~1));
37976         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
37977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37978         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
37979         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
37980         *ret_conv = BackgroundProcessor_join(this_arg_conv);
37981         return (uint64_t)ret_conv;
37982 }
37983
37984 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
37985         LDKBackgroundProcessor this_arg_conv;
37986         this_arg_conv.inner = (void*)(this_arg & (~1));
37987         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
37988         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37989         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
37990         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
37991         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
37992         return (uint64_t)ret_conv;
37993 }
37994
37995 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
37996         check_platform();
37997 }
37998
37999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38000         LDKInvoice this_obj_conv;
38001         this_obj_conv.inner = (void*)(this_obj & (~1));
38002         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38004         Invoice_free(this_obj_conv);
38005 }
38006
38007 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38008         LDKInvoice a_conv;
38009         a_conv.inner = (void*)(a & (~1));
38010         a_conv.is_owned = false;
38011         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38012         LDKInvoice b_conv;
38013         b_conv.inner = (void*)(b & (~1));
38014         b_conv.is_owned = false;
38015         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38016         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
38017         return ret_val;
38018 }
38019
38020 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
38021         LDKInvoice ret_var = Invoice_clone(arg);
38022 uint64_t ret_ref = 0;
38023 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38024 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38025 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38026 ret_ref = (uint64_t)ret_var.inner;
38027 if (ret_var.is_owned) {
38028         ret_ref |= 1;
38029 }
38030         return ret_ref;
38031 }
38032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38033         LDKInvoice arg_conv;
38034         arg_conv.inner = (void*)(arg & (~1));
38035         arg_conv.is_owned = false;
38036         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38037         int64_t ret_val = Invoice_clone_ptr(&arg_conv);
38038         return ret_val;
38039 }
38040
38041 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38042         LDKInvoice orig_conv;
38043         orig_conv.inner = (void*)(orig & (~1));
38044         orig_conv.is_owned = false;
38045         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38046         LDKInvoice ret_var = Invoice_clone(&orig_conv);
38047         uint64_t ret_ref = 0;
38048         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38049         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38050         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38051         ret_ref = (uint64_t)ret_var.inner;
38052         if (ret_var.is_owned) {
38053                 ret_ref |= 1;
38054         }
38055         return ret_ref;
38056 }
38057
38058 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38059         LDKSignedRawInvoice this_obj_conv;
38060         this_obj_conv.inner = (void*)(this_obj & (~1));
38061         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38063         SignedRawInvoice_free(this_obj_conv);
38064 }
38065
38066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38067         LDKSignedRawInvoice a_conv;
38068         a_conv.inner = (void*)(a & (~1));
38069         a_conv.is_owned = false;
38070         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38071         LDKSignedRawInvoice b_conv;
38072         b_conv.inner = (void*)(b & (~1));
38073         b_conv.is_owned = false;
38074         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38075         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
38076         return ret_val;
38077 }
38078
38079 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
38080         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
38081 uint64_t ret_ref = 0;
38082 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38083 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38084 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38085 ret_ref = (uint64_t)ret_var.inner;
38086 if (ret_var.is_owned) {
38087         ret_ref |= 1;
38088 }
38089         return ret_ref;
38090 }
38091 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38092         LDKSignedRawInvoice arg_conv;
38093         arg_conv.inner = (void*)(arg & (~1));
38094         arg_conv.is_owned = false;
38095         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38096         int64_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
38097         return ret_val;
38098 }
38099
38100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38101         LDKSignedRawInvoice orig_conv;
38102         orig_conv.inner = (void*)(orig & (~1));
38103         orig_conv.is_owned = false;
38104         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38105         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
38106         uint64_t ret_ref = 0;
38107         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38108         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38109         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38110         ret_ref = (uint64_t)ret_var.inner;
38111         if (ret_var.is_owned) {
38112                 ret_ref |= 1;
38113         }
38114         return ret_ref;
38115 }
38116
38117 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38118         LDKRawInvoice this_obj_conv;
38119         this_obj_conv.inner = (void*)(this_obj & (~1));
38120         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38122         RawInvoice_free(this_obj_conv);
38123 }
38124
38125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
38126         LDKRawInvoice this_ptr_conv;
38127         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38128         this_ptr_conv.is_owned = false;
38129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38130         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
38131         uint64_t ret_ref = 0;
38132         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38133         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38135         ret_ref = (uint64_t)ret_var.inner;
38136         if (ret_var.is_owned) {
38137                 ret_ref |= 1;
38138         }
38139         return ret_ref;
38140 }
38141
38142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38143         LDKRawInvoice this_ptr_conv;
38144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38145         this_ptr_conv.is_owned = false;
38146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38147         LDKRawDataPart val_conv;
38148         val_conv.inner = (void*)(val & (~1));
38149         val_conv.is_owned = (val & 1) || (val == 0);
38150         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38151         val_conv = RawDataPart_clone(&val_conv);
38152         RawInvoice_set_data(&this_ptr_conv, val_conv);
38153 }
38154
38155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38156         LDKRawInvoice a_conv;
38157         a_conv.inner = (void*)(a & (~1));
38158         a_conv.is_owned = false;
38159         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38160         LDKRawInvoice b_conv;
38161         b_conv.inner = (void*)(b & (~1));
38162         b_conv.is_owned = false;
38163         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38164         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
38165         return ret_val;
38166 }
38167
38168 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
38169         LDKRawInvoice ret_var = RawInvoice_clone(arg);
38170 uint64_t ret_ref = 0;
38171 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38172 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38173 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38174 ret_ref = (uint64_t)ret_var.inner;
38175 if (ret_var.is_owned) {
38176         ret_ref |= 1;
38177 }
38178         return ret_ref;
38179 }
38180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38181         LDKRawInvoice arg_conv;
38182         arg_conv.inner = (void*)(arg & (~1));
38183         arg_conv.is_owned = false;
38184         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38185         int64_t ret_val = RawInvoice_clone_ptr(&arg_conv);
38186         return ret_val;
38187 }
38188
38189 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38190         LDKRawInvoice orig_conv;
38191         orig_conv.inner = (void*)(orig & (~1));
38192         orig_conv.is_owned = false;
38193         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38194         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
38195         uint64_t ret_ref = 0;
38196         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38197         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38199         ret_ref = (uint64_t)ret_var.inner;
38200         if (ret_var.is_owned) {
38201                 ret_ref |= 1;
38202         }
38203         return ret_ref;
38204 }
38205
38206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38207         LDKRawDataPart this_obj_conv;
38208         this_obj_conv.inner = (void*)(this_obj & (~1));
38209         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38211         RawDataPart_free(this_obj_conv);
38212 }
38213
38214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38215         LDKRawDataPart this_ptr_conv;
38216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38217         this_ptr_conv.is_owned = false;
38218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38219         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
38220         uint64_t ret_ref = 0;
38221         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38222         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38223         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38224         ret_ref = (uint64_t)ret_var.inner;
38225         if (ret_var.is_owned) {
38226                 ret_ref |= 1;
38227         }
38228         return ret_ref;
38229 }
38230
38231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38232         LDKRawDataPart this_ptr_conv;
38233         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38234         this_ptr_conv.is_owned = false;
38235         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38236         LDKPositiveTimestamp val_conv;
38237         val_conv.inner = (void*)(val & (~1));
38238         val_conv.is_owned = (val & 1) || (val == 0);
38239         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38240         val_conv = PositiveTimestamp_clone(&val_conv);
38241         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
38242 }
38243
38244 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38245         LDKRawDataPart a_conv;
38246         a_conv.inner = (void*)(a & (~1));
38247         a_conv.is_owned = false;
38248         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38249         LDKRawDataPart b_conv;
38250         b_conv.inner = (void*)(b & (~1));
38251         b_conv.is_owned = false;
38252         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38253         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
38254         return ret_val;
38255 }
38256
38257 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
38258         LDKRawDataPart ret_var = RawDataPart_clone(arg);
38259 uint64_t ret_ref = 0;
38260 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38261 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38262 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38263 ret_ref = (uint64_t)ret_var.inner;
38264 if (ret_var.is_owned) {
38265         ret_ref |= 1;
38266 }
38267         return ret_ref;
38268 }
38269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38270         LDKRawDataPart arg_conv;
38271         arg_conv.inner = (void*)(arg & (~1));
38272         arg_conv.is_owned = false;
38273         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38274         int64_t ret_val = RawDataPart_clone_ptr(&arg_conv);
38275         return ret_val;
38276 }
38277
38278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38279         LDKRawDataPart orig_conv;
38280         orig_conv.inner = (void*)(orig & (~1));
38281         orig_conv.is_owned = false;
38282         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38283         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
38284         uint64_t ret_ref = 0;
38285         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38286         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38288         ret_ref = (uint64_t)ret_var.inner;
38289         if (ret_var.is_owned) {
38290                 ret_ref |= 1;
38291         }
38292         return ret_ref;
38293 }
38294
38295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38296         LDKPositiveTimestamp this_obj_conv;
38297         this_obj_conv.inner = (void*)(this_obj & (~1));
38298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38300         PositiveTimestamp_free(this_obj_conv);
38301 }
38302
38303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38304         LDKPositiveTimestamp a_conv;
38305         a_conv.inner = (void*)(a & (~1));
38306         a_conv.is_owned = false;
38307         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38308         LDKPositiveTimestamp b_conv;
38309         b_conv.inner = (void*)(b & (~1));
38310         b_conv.is_owned = false;
38311         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38312         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
38313         return ret_val;
38314 }
38315
38316 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
38317         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
38318 uint64_t ret_ref = 0;
38319 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38320 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38321 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38322 ret_ref = (uint64_t)ret_var.inner;
38323 if (ret_var.is_owned) {
38324         ret_ref |= 1;
38325 }
38326         return ret_ref;
38327 }
38328 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38329         LDKPositiveTimestamp arg_conv;
38330         arg_conv.inner = (void*)(arg & (~1));
38331         arg_conv.is_owned = false;
38332         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38333         int64_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
38334         return ret_val;
38335 }
38336
38337 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38338         LDKPositiveTimestamp orig_conv;
38339         orig_conv.inner = (void*)(orig & (~1));
38340         orig_conv.is_owned = false;
38341         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38342         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
38343         uint64_t ret_ref = 0;
38344         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38345         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38346         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38347         ret_ref = (uint64_t)ret_var.inner;
38348         if (ret_var.is_owned) {
38349                 ret_ref |= 1;
38350         }
38351         return ret_ref;
38352 }
38353
38354 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38355         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
38356         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
38357         return ret_conv;
38358 }
38359
38360 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
38361         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
38362         return ret_conv;
38363 }
38364
38365 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
38366         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
38367         return ret_conv;
38368 }
38369
38370 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
38371         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
38372         return ret_conv;
38373 }
38374
38375 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
38376         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
38377         return ret_conv;
38378 }
38379
38380 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38381         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
38382         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
38383         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
38384         return ret_val;
38385 }
38386
38387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
38388         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
38389         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
38390         return ret_val;
38391 }
38392
38393 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38394         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
38395         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
38396         return ret_conv;
38397 }
38398
38399 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
38400         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
38401         return ret_conv;
38402 }
38403
38404 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
38405         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
38406         return ret_conv;
38407 }
38408
38409 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
38410         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
38411         return ret_conv;
38412 }
38413
38414 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
38415         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
38416         return ret_conv;
38417 }
38418
38419 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
38420         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
38421         return ret_conv;
38422 }
38423
38424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
38425         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
38426         int64_t ret_val = Currency_hash(o_conv);
38427         return ret_val;
38428 }
38429
38430 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38431         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
38432         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
38433         jboolean ret_val = Currency_eq(a_conv, b_conv);
38434         return ret_val;
38435 }
38436
38437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38438         LDKSha256 this_obj_conv;
38439         this_obj_conv.inner = (void*)(this_obj & (~1));
38440         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38442         Sha256_free(this_obj_conv);
38443 }
38444
38445 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
38446         LDKSha256 ret_var = Sha256_clone(arg);
38447 uint64_t ret_ref = 0;
38448 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38449 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38450 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38451 ret_ref = (uint64_t)ret_var.inner;
38452 if (ret_var.is_owned) {
38453         ret_ref |= 1;
38454 }
38455         return ret_ref;
38456 }
38457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38458         LDKSha256 arg_conv;
38459         arg_conv.inner = (void*)(arg & (~1));
38460         arg_conv.is_owned = false;
38461         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38462         int64_t ret_val = Sha256_clone_ptr(&arg_conv);
38463         return ret_val;
38464 }
38465
38466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38467         LDKSha256 orig_conv;
38468         orig_conv.inner = (void*)(orig & (~1));
38469         orig_conv.is_owned = false;
38470         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38471         LDKSha256 ret_var = Sha256_clone(&orig_conv);
38472         uint64_t ret_ref = 0;
38473         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38474         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38475         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38476         ret_ref = (uint64_t)ret_var.inner;
38477         if (ret_var.is_owned) {
38478                 ret_ref |= 1;
38479         }
38480         return ret_ref;
38481 }
38482
38483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
38484         LDKSha256 o_conv;
38485         o_conv.inner = (void*)(o & (~1));
38486         o_conv.is_owned = false;
38487         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38488         int64_t ret_val = Sha256_hash(&o_conv);
38489         return ret_val;
38490 }
38491
38492 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38493         LDKSha256 a_conv;
38494         a_conv.inner = (void*)(a & (~1));
38495         a_conv.is_owned = false;
38496         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38497         LDKSha256 b_conv;
38498         b_conv.inner = (void*)(b & (~1));
38499         b_conv.is_owned = false;
38500         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38501         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
38502         return ret_val;
38503 }
38504
38505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38506         LDKDescription this_obj_conv;
38507         this_obj_conv.inner = (void*)(this_obj & (~1));
38508         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38510         Description_free(this_obj_conv);
38511 }
38512
38513 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
38514         LDKDescription ret_var = Description_clone(arg);
38515 uint64_t ret_ref = 0;
38516 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38517 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38518 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38519 ret_ref = (uint64_t)ret_var.inner;
38520 if (ret_var.is_owned) {
38521         ret_ref |= 1;
38522 }
38523         return ret_ref;
38524 }
38525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38526         LDKDescription arg_conv;
38527         arg_conv.inner = (void*)(arg & (~1));
38528         arg_conv.is_owned = false;
38529         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38530         int64_t ret_val = Description_clone_ptr(&arg_conv);
38531         return ret_val;
38532 }
38533
38534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38535         LDKDescription orig_conv;
38536         orig_conv.inner = (void*)(orig & (~1));
38537         orig_conv.is_owned = false;
38538         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38539         LDKDescription ret_var = Description_clone(&orig_conv);
38540         uint64_t ret_ref = 0;
38541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38544         ret_ref = (uint64_t)ret_var.inner;
38545         if (ret_var.is_owned) {
38546                 ret_ref |= 1;
38547         }
38548         return ret_ref;
38549 }
38550
38551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
38552         LDKDescription o_conv;
38553         o_conv.inner = (void*)(o & (~1));
38554         o_conv.is_owned = false;
38555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38556         int64_t ret_val = Description_hash(&o_conv);
38557         return ret_val;
38558 }
38559
38560 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38561         LDKDescription a_conv;
38562         a_conv.inner = (void*)(a & (~1));
38563         a_conv.is_owned = false;
38564         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38565         LDKDescription b_conv;
38566         b_conv.inner = (void*)(b & (~1));
38567         b_conv.is_owned = false;
38568         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38569         jboolean ret_val = Description_eq(&a_conv, &b_conv);
38570         return ret_val;
38571 }
38572
38573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38574         LDKPayeePubKey this_obj_conv;
38575         this_obj_conv.inner = (void*)(this_obj & (~1));
38576         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38578         PayeePubKey_free(this_obj_conv);
38579 }
38580
38581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
38582         LDKPayeePubKey this_ptr_conv;
38583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38584         this_ptr_conv.is_owned = false;
38585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38586         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
38588         return ret_arr;
38589 }
38590
38591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38592         LDKPayeePubKey this_ptr_conv;
38593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38594         this_ptr_conv.is_owned = false;
38595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38596         LDKPublicKey val_ref;
38597         CHECK((*env)->GetArrayLength(env, val) == 33);
38598         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38599         PayeePubKey_set_a(&this_ptr_conv, val_ref);
38600 }
38601
38602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
38603         LDKPublicKey a_arg_ref;
38604         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
38605         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
38606         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
38607         uint64_t ret_ref = 0;
38608         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38609         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38611         ret_ref = (uint64_t)ret_var.inner;
38612         if (ret_var.is_owned) {
38613                 ret_ref |= 1;
38614         }
38615         return ret_ref;
38616 }
38617
38618 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
38619         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
38620 uint64_t ret_ref = 0;
38621 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38622 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38623 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38624 ret_ref = (uint64_t)ret_var.inner;
38625 if (ret_var.is_owned) {
38626         ret_ref |= 1;
38627 }
38628         return ret_ref;
38629 }
38630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38631         LDKPayeePubKey arg_conv;
38632         arg_conv.inner = (void*)(arg & (~1));
38633         arg_conv.is_owned = false;
38634         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38635         int64_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
38636         return ret_val;
38637 }
38638
38639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38640         LDKPayeePubKey orig_conv;
38641         orig_conv.inner = (void*)(orig & (~1));
38642         orig_conv.is_owned = false;
38643         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38644         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
38645         uint64_t ret_ref = 0;
38646         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38647         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38648         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38649         ret_ref = (uint64_t)ret_var.inner;
38650         if (ret_var.is_owned) {
38651                 ret_ref |= 1;
38652         }
38653         return ret_ref;
38654 }
38655
38656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
38657         LDKPayeePubKey o_conv;
38658         o_conv.inner = (void*)(o & (~1));
38659         o_conv.is_owned = false;
38660         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38661         int64_t ret_val = PayeePubKey_hash(&o_conv);
38662         return ret_val;
38663 }
38664
38665 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38666         LDKPayeePubKey a_conv;
38667         a_conv.inner = (void*)(a & (~1));
38668         a_conv.is_owned = false;
38669         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38670         LDKPayeePubKey b_conv;
38671         b_conv.inner = (void*)(b & (~1));
38672         b_conv.is_owned = false;
38673         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38674         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
38675         return ret_val;
38676 }
38677
38678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38679         LDKExpiryTime this_obj_conv;
38680         this_obj_conv.inner = (void*)(this_obj & (~1));
38681         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38682         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38683         ExpiryTime_free(this_obj_conv);
38684 }
38685
38686 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
38687         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
38688 uint64_t ret_ref = 0;
38689 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38690 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38691 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38692 ret_ref = (uint64_t)ret_var.inner;
38693 if (ret_var.is_owned) {
38694         ret_ref |= 1;
38695 }
38696         return ret_ref;
38697 }
38698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38699         LDKExpiryTime arg_conv;
38700         arg_conv.inner = (void*)(arg & (~1));
38701         arg_conv.is_owned = false;
38702         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38703         int64_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
38704         return ret_val;
38705 }
38706
38707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38708         LDKExpiryTime orig_conv;
38709         orig_conv.inner = (void*)(orig & (~1));
38710         orig_conv.is_owned = false;
38711         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38712         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
38713         uint64_t ret_ref = 0;
38714         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38715         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38716         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38717         ret_ref = (uint64_t)ret_var.inner;
38718         if (ret_var.is_owned) {
38719                 ret_ref |= 1;
38720         }
38721         return ret_ref;
38722 }
38723
38724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
38725         LDKExpiryTime o_conv;
38726         o_conv.inner = (void*)(o & (~1));
38727         o_conv.is_owned = false;
38728         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38729         int64_t ret_val = ExpiryTime_hash(&o_conv);
38730         return ret_val;
38731 }
38732
38733 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38734         LDKExpiryTime a_conv;
38735         a_conv.inner = (void*)(a & (~1));
38736         a_conv.is_owned = false;
38737         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38738         LDKExpiryTime b_conv;
38739         b_conv.inner = (void*)(b & (~1));
38740         b_conv.is_owned = false;
38741         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38742         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
38743         return ret_val;
38744 }
38745
38746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38747         LDKMinFinalCltvExpiry this_obj_conv;
38748         this_obj_conv.inner = (void*)(this_obj & (~1));
38749         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38751         MinFinalCltvExpiry_free(this_obj_conv);
38752 }
38753
38754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
38755         LDKMinFinalCltvExpiry this_ptr_conv;
38756         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38757         this_ptr_conv.is_owned = false;
38758         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38759         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
38760         return ret_val;
38761 }
38762
38763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38764         LDKMinFinalCltvExpiry this_ptr_conv;
38765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38766         this_ptr_conv.is_owned = false;
38767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38768         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
38769 }
38770
38771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
38772         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
38773         uint64_t ret_ref = 0;
38774         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38775         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38776         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38777         ret_ref = (uint64_t)ret_var.inner;
38778         if (ret_var.is_owned) {
38779                 ret_ref |= 1;
38780         }
38781         return ret_ref;
38782 }
38783
38784 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
38785         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
38786 uint64_t ret_ref = 0;
38787 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38788 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38789 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38790 ret_ref = (uint64_t)ret_var.inner;
38791 if (ret_var.is_owned) {
38792         ret_ref |= 1;
38793 }
38794         return ret_ref;
38795 }
38796 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38797         LDKMinFinalCltvExpiry arg_conv;
38798         arg_conv.inner = (void*)(arg & (~1));
38799         arg_conv.is_owned = false;
38800         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38801         int64_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
38802         return ret_val;
38803 }
38804
38805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38806         LDKMinFinalCltvExpiry orig_conv;
38807         orig_conv.inner = (void*)(orig & (~1));
38808         orig_conv.is_owned = false;
38809         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38810         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
38811         uint64_t ret_ref = 0;
38812         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38813         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38814         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38815         ret_ref = (uint64_t)ret_var.inner;
38816         if (ret_var.is_owned) {
38817                 ret_ref |= 1;
38818         }
38819         return ret_ref;
38820 }
38821
38822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
38823         LDKMinFinalCltvExpiry o_conv;
38824         o_conv.inner = (void*)(o & (~1));
38825         o_conv.is_owned = false;
38826         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38827         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
38828         return ret_val;
38829 }
38830
38831 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38832         LDKMinFinalCltvExpiry a_conv;
38833         a_conv.inner = (void*)(a & (~1));
38834         a_conv.is_owned = false;
38835         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38836         LDKMinFinalCltvExpiry b_conv;
38837         b_conv.inner = (void*)(b & (~1));
38838         b_conv.is_owned = false;
38839         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38840         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
38841         return ret_val;
38842 }
38843
38844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38845         if ((this_ptr & 1) != 0) return;
38846         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
38847         CHECK_ACCESS(this_ptr_ptr);
38848         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
38849         FREE((void*)this_ptr);
38850         Fallback_free(this_ptr_conv);
38851 }
38852
38853 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
38854         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38855         *ret_copy = Fallback_clone(arg);
38856 uint64_t ret_ref = (uint64_t)ret_copy;
38857         return ret_ref;
38858 }
38859 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38860         LDKFallback* arg_conv = (LDKFallback*)arg;
38861         int64_t ret_val = Fallback_clone_ptr(arg_conv);
38862         return ret_val;
38863 }
38864
38865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38866         LDKFallback* orig_conv = (LDKFallback*)orig;
38867         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38868         *ret_copy = Fallback_clone(orig_conv);
38869         uint64_t ret_ref = (uint64_t)ret_copy;
38870         return ret_ref;
38871 }
38872
38873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
38874         
38875         LDKCVec_u8Z program_ref;
38876         program_ref.datalen = (*env)->GetArrayLength(env, program);
38877         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
38878         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
38879         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38880         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
38881         uint64_t ret_ref = (uint64_t)ret_copy;
38882         return ret_ref;
38883 }
38884
38885 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
38886         LDKTwentyBytes a_ref;
38887         CHECK((*env)->GetArrayLength(env, a) == 20);
38888         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
38889         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38890         *ret_copy = Fallback_pub_key_hash(a_ref);
38891         uint64_t ret_ref = (uint64_t)ret_copy;
38892         return ret_ref;
38893 }
38894
38895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
38896         LDKTwentyBytes a_ref;
38897         CHECK((*env)->GetArrayLength(env, a) == 20);
38898         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
38899         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38900         *ret_copy = Fallback_script_hash(a_ref);
38901         uint64_t ret_ref = (uint64_t)ret_copy;
38902         return ret_ref;
38903 }
38904
38905 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
38906         LDKFallback* o_conv = (LDKFallback*)o;
38907         int64_t ret_val = Fallback_hash(o_conv);
38908         return ret_val;
38909 }
38910
38911 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38912         LDKFallback* a_conv = (LDKFallback*)a;
38913         LDKFallback* b_conv = (LDKFallback*)b;
38914         jboolean ret_val = Fallback_eq(a_conv, b_conv);
38915         return ret_val;
38916 }
38917
38918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38919         LDKInvoiceSignature this_obj_conv;
38920         this_obj_conv.inner = (void*)(this_obj & (~1));
38921         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38922         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38923         InvoiceSignature_free(this_obj_conv);
38924 }
38925
38926 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
38927         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
38928 uint64_t ret_ref = 0;
38929 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38930 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38931 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38932 ret_ref = (uint64_t)ret_var.inner;
38933 if (ret_var.is_owned) {
38934         ret_ref |= 1;
38935 }
38936         return ret_ref;
38937 }
38938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38939         LDKInvoiceSignature arg_conv;
38940         arg_conv.inner = (void*)(arg & (~1));
38941         arg_conv.is_owned = false;
38942         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38943         int64_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
38944         return ret_val;
38945 }
38946
38947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38948         LDKInvoiceSignature orig_conv;
38949         orig_conv.inner = (void*)(orig & (~1));
38950         orig_conv.is_owned = false;
38951         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38952         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
38953         uint64_t ret_ref = 0;
38954         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38955         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38956         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38957         ret_ref = (uint64_t)ret_var.inner;
38958         if (ret_var.is_owned) {
38959                 ret_ref |= 1;
38960         }
38961         return ret_ref;
38962 }
38963
38964 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38965         LDKInvoiceSignature a_conv;
38966         a_conv.inner = (void*)(a & (~1));
38967         a_conv.is_owned = false;
38968         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38969         LDKInvoiceSignature b_conv;
38970         b_conv.inner = (void*)(b & (~1));
38971         b_conv.is_owned = false;
38972         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38973         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
38974         return ret_val;
38975 }
38976
38977 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38978         LDKPrivateRoute this_obj_conv;
38979         this_obj_conv.inner = (void*)(this_obj & (~1));
38980         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38982         PrivateRoute_free(this_obj_conv);
38983 }
38984
38985 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
38986         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
38987 uint64_t ret_ref = 0;
38988 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38989 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38990 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38991 ret_ref = (uint64_t)ret_var.inner;
38992 if (ret_var.is_owned) {
38993         ret_ref |= 1;
38994 }
38995         return ret_ref;
38996 }
38997 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38998         LDKPrivateRoute arg_conv;
38999         arg_conv.inner = (void*)(arg & (~1));
39000         arg_conv.is_owned = false;
39001         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39002         int64_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
39003         return ret_val;
39004 }
39005
39006 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39007         LDKPrivateRoute orig_conv;
39008         orig_conv.inner = (void*)(orig & (~1));
39009         orig_conv.is_owned = false;
39010         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39011         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
39012         uint64_t ret_ref = 0;
39013         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39014         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39015         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39016         ret_ref = (uint64_t)ret_var.inner;
39017         if (ret_var.is_owned) {
39018                 ret_ref |= 1;
39019         }
39020         return ret_ref;
39021 }
39022
39023 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
39024         LDKPrivateRoute o_conv;
39025         o_conv.inner = (void*)(o & (~1));
39026         o_conv.is_owned = false;
39027         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39028         int64_t ret_val = PrivateRoute_hash(&o_conv);
39029         return ret_val;
39030 }
39031
39032 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39033         LDKPrivateRoute a_conv;
39034         a_conv.inner = (void*)(a & (~1));
39035         a_conv.is_owned = false;
39036         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39037         LDKPrivateRoute b_conv;
39038         b_conv.inner = (void*)(b & (~1));
39039         b_conv.is_owned = false;
39040         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39041         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
39042         return ret_val;
39043 }
39044
39045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
39046         LDKSignedRawInvoice this_arg_conv;
39047         this_arg_conv.inner = (void*)(this_arg & (~1));
39048         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39049         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39050         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
39051         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
39052         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
39053         return ((uint64_t)ret_conv);
39054 }
39055
39056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
39057         LDKSignedRawInvoice this_arg_conv;
39058         this_arg_conv.inner = (void*)(this_arg & (~1));
39059         this_arg_conv.is_owned = false;
39060         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39061         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
39062         uint64_t ret_ref = 0;
39063         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39064         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39065         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39066         ret_ref = (uint64_t)ret_var.inner;
39067         if (ret_var.is_owned) {
39068                 ret_ref |= 1;
39069         }
39070         return ret_ref;
39071 }
39072
39073 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39074         LDKSignedRawInvoice this_arg_conv;
39075         this_arg_conv.inner = (void*)(this_arg & (~1));
39076         this_arg_conv.is_owned = false;
39077         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39078         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39079         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
39080         return ret_arr;
39081 }
39082
39083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
39084         LDKSignedRawInvoice this_arg_conv;
39085         this_arg_conv.inner = (void*)(this_arg & (~1));
39086         this_arg_conv.is_owned = false;
39087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39088         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
39089         uint64_t ret_ref = 0;
39090         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39091         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39093         ret_ref = (uint64_t)ret_var.inner;
39094         if (ret_var.is_owned) {
39095                 ret_ref |= 1;
39096         }
39097         return ret_ref;
39098 }
39099
39100 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
39101         LDKSignedRawInvoice this_arg_conv;
39102         this_arg_conv.inner = (void*)(this_arg & (~1));
39103         this_arg_conv.is_owned = false;
39104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39105         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
39106         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
39107         return (uint64_t)ret_conv;
39108 }
39109
39110 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
39111         LDKSignedRawInvoice this_arg_conv;
39112         this_arg_conv.inner = (void*)(this_arg & (~1));
39113         this_arg_conv.is_owned = false;
39114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39115         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
39116         return ret_val;
39117 }
39118
39119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39120         LDKRawInvoice this_arg_conv;
39121         this_arg_conv.inner = (void*)(this_arg & (~1));
39122         this_arg_conv.is_owned = false;
39123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39124         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39125         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
39126         return ret_arr;
39127 }
39128
39129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39130         LDKRawInvoice this_arg_conv;
39131         this_arg_conv.inner = (void*)(this_arg & (~1));
39132         this_arg_conv.is_owned = false;
39133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39134         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
39135         uint64_t ret_ref = 0;
39136         if ((uint64_t)ret_var.inner > 4096) {
39137                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39138                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39139         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39140                 ret_ref = (uint64_t)ret_var.inner;
39141                 if (ret_var.is_owned) {
39142                         ret_ref |= 1;
39143                 }
39144         }
39145         return ret_ref;
39146 }
39147
39148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
39149         LDKRawInvoice this_arg_conv;
39150         this_arg_conv.inner = (void*)(this_arg & (~1));
39151         this_arg_conv.is_owned = false;
39152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39153         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
39154         uint64_t ret_ref = 0;
39155         if ((uint64_t)ret_var.inner > 4096) {
39156                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39157                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39158         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39159                 ret_ref = (uint64_t)ret_var.inner;
39160                 if (ret_var.is_owned) {
39161                         ret_ref |= 1;
39162                 }
39163         }
39164         return ret_ref;
39165 }
39166
39167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
39168         LDKRawInvoice this_arg_conv;
39169         this_arg_conv.inner = (void*)(this_arg & (~1));
39170         this_arg_conv.is_owned = false;
39171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39172         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
39173         uint64_t ret_ref = 0;
39174         if ((uint64_t)ret_var.inner > 4096) {
39175                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39176                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39177         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39178                 ret_ref = (uint64_t)ret_var.inner;
39179                 if (ret_var.is_owned) {
39180                         ret_ref |= 1;
39181                 }
39182         }
39183         return ret_ref;
39184 }
39185
39186 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39187         LDKRawInvoice this_arg_conv;
39188         this_arg_conv.inner = (void*)(this_arg & (~1));
39189         this_arg_conv.is_owned = false;
39190         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39191         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
39192         uint64_t ret_ref = 0;
39193         if ((uint64_t)ret_var.inner > 4096) {
39194                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39195                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39196         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39197                 ret_ref = (uint64_t)ret_var.inner;
39198                 if (ret_var.is_owned) {
39199                         ret_ref |= 1;
39200                 }
39201         }
39202         return ret_ref;
39203 }
39204
39205 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
39206         LDKRawInvoice this_arg_conv;
39207         this_arg_conv.inner = (void*)(this_arg & (~1));
39208         this_arg_conv.is_owned = false;
39209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39210         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
39211         uint64_t ret_ref = 0;
39212         if ((uint64_t)ret_var.inner > 4096) {
39213                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39214                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39215         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39216                 ret_ref = (uint64_t)ret_var.inner;
39217                 if (ret_var.is_owned) {
39218                         ret_ref |= 1;
39219                 }
39220         }
39221         return ret_ref;
39222 }
39223
39224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
39225         LDKRawInvoice this_arg_conv;
39226         this_arg_conv.inner = (void*)(this_arg & (~1));
39227         this_arg_conv.is_owned = false;
39228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39229         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
39230         uint64_t ret_ref = 0;
39231         if ((uint64_t)ret_var.inner > 4096) {
39232                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39233                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39235                 ret_ref = (uint64_t)ret_var.inner;
39236                 if (ret_var.is_owned) {
39237                         ret_ref |= 1;
39238                 }
39239         }
39240         return ret_ref;
39241 }
39242
39243 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
39244         LDKRawInvoice this_arg_conv;
39245         this_arg_conv.inner = (void*)(this_arg & (~1));
39246         this_arg_conv.is_owned = false;
39247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39248         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39249         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
39250         return ret_arr;
39251 }
39252
39253 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
39254         LDKRawInvoice this_arg_conv;
39255         this_arg_conv.inner = (void*)(this_arg & (~1));
39256         this_arg_conv.is_owned = false;
39257         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39258         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
39259         uint64_t ret_ref = 0;
39260         if ((uint64_t)ret_var.inner > 4096) {
39261                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39262                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39263         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39264                 ret_ref = (uint64_t)ret_var.inner;
39265                 if (ret_var.is_owned) {
39266                         ret_ref |= 1;
39267                 }
39268         }
39269         return ret_ref;
39270 }
39271
39272 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
39273         LDKRawInvoice this_arg_conv;
39274         this_arg_conv.inner = (void*)(this_arg & (~1));
39275         this_arg_conv.is_owned = false;
39276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39277         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
39278         int64_tArray ret_arr = NULL;
39279         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39280         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39281         for (size_t o = 0; o < ret_var.datalen; o++) {
39282                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
39283                 uint64_t ret_conv_14_ref = 0;
39284                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39285                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39286                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
39287                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
39288                 if (ret_conv_14_var.is_owned) {
39289                         ret_conv_14_ref |= 1;
39290                 }
39291                 ret_arr_ptr[o] = ret_conv_14_ref;
39292         }
39293         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39294         FREE(ret_var.data);
39295         return ret_arr;
39296 }
39297
39298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
39299         LDKRawInvoice this_arg_conv;
39300         this_arg_conv.inner = (void*)(this_arg & (~1));
39301         this_arg_conv.is_owned = false;
39302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39303         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39304         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
39305         uint64_t ret_ref = (uint64_t)ret_copy;
39306         return ret_ref;
39307 }
39308
39309 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
39310         LDKRawInvoice this_arg_conv;
39311         this_arg_conv.inner = (void*)(this_arg & (~1));
39312         this_arg_conv.is_owned = false;
39313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39314         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
39315         return ret_conv;
39316 }
39317
39318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
39319         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
39320         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
39321         return (uint64_t)ret_conv;
39322 }
39323
39324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
39325         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
39326         *ret_conv = PositiveTimestamp_from_system_time(time);
39327         return (uint64_t)ret_conv;
39328 }
39329
39330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
39331         LDKPositiveTimestamp this_arg_conv;
39332         this_arg_conv.inner = (void*)(this_arg & (~1));
39333         this_arg_conv.is_owned = false;
39334         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39335         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
39336         return ret_val;
39337 }
39338
39339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
39340         LDKPositiveTimestamp this_arg_conv;
39341         this_arg_conv.inner = (void*)(this_arg & (~1));
39342         this_arg_conv.is_owned = false;
39343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39344         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
39345         return ret_val;
39346 }
39347
39348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
39349         LDKInvoice this_arg_conv;
39350         this_arg_conv.inner = (void*)(this_arg & (~1));
39351         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39353         this_arg_conv = Invoice_clone(&this_arg_conv);
39354         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
39355         uint64_t ret_ref = 0;
39356         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39357         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39358         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39359         ret_ref = (uint64_t)ret_var.inner;
39360         if (ret_var.is_owned) {
39361                 ret_ref |= 1;
39362         }
39363         return ret_ref;
39364 }
39365
39366 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
39367         LDKInvoice this_arg_conv;
39368         this_arg_conv.inner = (void*)(this_arg & (~1));
39369         this_arg_conv.is_owned = false;
39370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39371         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
39372         *ret_conv = Invoice_check_signature(&this_arg_conv);
39373         return (uint64_t)ret_conv;
39374 }
39375
39376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
39377         LDKSignedRawInvoice signed_invoice_conv;
39378         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
39379         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
39380         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
39381         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
39382         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
39383         *ret_conv = Invoice_from_signed(signed_invoice_conv);
39384         return (uint64_t)ret_conv;
39385 }
39386
39387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
39388         LDKInvoice this_arg_conv;
39389         this_arg_conv.inner = (void*)(this_arg & (~1));
39390         this_arg_conv.is_owned = false;
39391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39392         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
39393         return ret_val;
39394 }
39395
39396 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39397         LDKInvoice this_arg_conv;
39398         this_arg_conv.inner = (void*)(this_arg & (~1));
39399         this_arg_conv.is_owned = false;
39400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39401         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39402         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
39403         return ret_arr;
39404 }
39405
39406 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
39407         LDKInvoice this_arg_conv;
39408         this_arg_conv.inner = (void*)(this_arg & (~1));
39409         this_arg_conv.is_owned = false;
39410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39411         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39412         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
39413         return ret_arr;
39414 }
39415
39416 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
39417         LDKInvoice this_arg_conv;
39418         this_arg_conv.inner = (void*)(this_arg & (~1));
39419         this_arg_conv.is_owned = false;
39420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39421         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39422         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
39423         return ret_arr;
39424 }
39425
39426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
39427         LDKInvoice this_arg_conv;
39428         this_arg_conv.inner = (void*)(this_arg & (~1));
39429         this_arg_conv.is_owned = false;
39430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39431         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
39432         uint64_t ret_ref = 0;
39433         if ((uint64_t)ret_var.inner > 4096) {
39434                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39435                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39436         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39437                 ret_ref = (uint64_t)ret_var.inner;
39438                 if (ret_var.is_owned) {
39439                         ret_ref |= 1;
39440                 }
39441         }
39442         return ret_ref;
39443 }
39444
39445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
39446         LDKInvoice this_arg_conv;
39447         this_arg_conv.inner = (void*)(this_arg & (~1));
39448         this_arg_conv.is_owned = false;
39449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39450         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
39452         return ret_arr;
39453 }
39454
39455 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
39456         LDKInvoice this_arg_conv;
39457         this_arg_conv.inner = (void*)(this_arg & (~1));
39458         this_arg_conv.is_owned = false;
39459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39460         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
39461         return ret_val;
39462 }
39463
39464 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
39465         LDKInvoice this_arg_conv;
39466         this_arg_conv.inner = (void*)(this_arg & (~1));
39467         this_arg_conv.is_owned = false;
39468         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39469         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
39470         return ret_val;
39471 }
39472
39473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
39474         LDKInvoice this_arg_conv;
39475         this_arg_conv.inner = (void*)(this_arg & (~1));
39476         this_arg_conv.is_owned = false;
39477         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39478         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
39479         return ret_val;
39480 }
39481
39482 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
39483         LDKInvoice this_arg_conv;
39484         this_arg_conv.inner = (void*)(this_arg & (~1));
39485         this_arg_conv.is_owned = false;
39486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39487         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
39488         int64_tArray ret_arr = NULL;
39489         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39490         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39491         for (size_t o = 0; o < ret_var.datalen; o++) {
39492                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
39493                 uint64_t ret_conv_14_ref = 0;
39494                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39495                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39496                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
39497                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
39498                 if (ret_conv_14_var.is_owned) {
39499                         ret_conv_14_ref |= 1;
39500                 }
39501                 ret_arr_ptr[o] = ret_conv_14_ref;
39502         }
39503         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39504         FREE(ret_var.data);
39505         return ret_arr;
39506 }
39507
39508 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
39509         LDKInvoice this_arg_conv;
39510         this_arg_conv.inner = (void*)(this_arg & (~1));
39511         this_arg_conv.is_owned = false;
39512         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39513         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
39514         int64_tArray ret_arr = NULL;
39515         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39516         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39517         for (size_t l = 0; l < ret_var.datalen; l++) {
39518                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
39519                 uint64_t ret_conv_11_ref = 0;
39520                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39521                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39522                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
39523                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
39524                 if (ret_conv_11_var.is_owned) {
39525                         ret_conv_11_ref |= 1;
39526                 }
39527                 ret_arr_ptr[l] = ret_conv_11_ref;
39528         }
39529         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39530         FREE(ret_var.data);
39531         return ret_arr;
39532 }
39533
39534 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
39535         LDKInvoice this_arg_conv;
39536         this_arg_conv.inner = (void*)(this_arg & (~1));
39537         this_arg_conv.is_owned = false;
39538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39539         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
39540         return ret_conv;
39541 }
39542
39543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
39544         LDKInvoice this_arg_conv;
39545         this_arg_conv.inner = (void*)(this_arg & (~1));
39546         this_arg_conv.is_owned = false;
39547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39548         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39549         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
39550         uint64_t ret_ref = (uint64_t)ret_copy;
39551         return ret_ref;
39552 }
39553
39554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
39555         LDKStr description_conv = java_to_owned_str(env, description);
39556         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
39557         *ret_conv = Description_new(description_conv);
39558         return (uint64_t)ret_conv;
39559 }
39560
39561 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
39562         LDKDescription this_arg_conv;
39563         this_arg_conv.inner = (void*)(this_arg & (~1));
39564         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39565         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39566         this_arg_conv = Description_clone(&this_arg_conv);
39567         LDKStr ret_str = Description_into_inner(this_arg_conv);
39568         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39569         Str_free(ret_str);
39570         return ret_conv;
39571 }
39572
39573 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
39574         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
39575         *ret_conv = ExpiryTime_from_seconds(seconds);
39576         return (uint64_t)ret_conv;
39577 }
39578
39579 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
39580         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
39581         *ret_conv = ExpiryTime_from_duration(duration);
39582         return (uint64_t)ret_conv;
39583 }
39584
39585 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
39586         LDKExpiryTime this_arg_conv;
39587         this_arg_conv.inner = (void*)(this_arg & (~1));
39588         this_arg_conv.is_owned = false;
39589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39590         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
39591         return ret_val;
39592 }
39593
39594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
39595         LDKExpiryTime this_arg_conv;
39596         this_arg_conv.inner = (void*)(this_arg & (~1));
39597         this_arg_conv.is_owned = false;
39598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39599         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
39600         return ret_val;
39601 }
39602
39603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
39604         LDKRouteHint hops_conv;
39605         hops_conv.inner = (void*)(hops & (~1));
39606         hops_conv.is_owned = (hops & 1) || (hops == 0);
39607         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
39608         hops_conv = RouteHint_clone(&hops_conv);
39609         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
39610         *ret_conv = PrivateRoute_new(hops_conv);
39611         return (uint64_t)ret_conv;
39612 }
39613
39614 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
39615         LDKPrivateRoute this_arg_conv;
39616         this_arg_conv.inner = (void*)(this_arg & (~1));
39617         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39619         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
39620         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
39621         uint64_t ret_ref = 0;
39622         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39623         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39625         ret_ref = (uint64_t)ret_var.inner;
39626         if (ret_var.is_owned) {
39627                 ret_ref |= 1;
39628         }
39629         return ret_ref;
39630 }
39631
39632 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39633         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
39634         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
39635         return ret_conv;
39636 }
39637
39638 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
39639         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
39640         return ret_conv;
39641 }
39642
39643 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
39644         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
39645         return ret_conv;
39646 }
39647
39648 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
39649         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
39650         return ret_conv;
39651 }
39652
39653 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
39654         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
39655         return ret_conv;
39656 }
39657
39658 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39659         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
39660         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
39661         jboolean ret_val = CreationError_eq(a_conv, b_conv);
39662         return ret_val;
39663 }
39664
39665 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
39666         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
39667         LDKStr ret_str = CreationError_to_str(o_conv);
39668         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39669         Str_free(ret_str);
39670         return ret_conv;
39671 }
39672
39673 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39674         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
39675         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
39676         return ret_conv;
39677 }
39678
39679 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
39680         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
39681         return ret_conv;
39682 }
39683
39684 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
39685         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
39686         return ret_conv;
39687 }
39688
39689 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
39690         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
39691         return ret_conv;
39692 }
39693
39694 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
39695         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
39696         return ret_conv;
39697 }
39698
39699 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
39700         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
39701         return ret_conv;
39702 }
39703
39704 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
39705         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
39706         return ret_conv;
39707 }
39708
39709 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
39710         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
39711         return ret_conv;
39712 }
39713
39714 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
39715         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
39716         return ret_conv;
39717 }
39718
39719 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
39720         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
39721         return ret_conv;
39722 }
39723
39724 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
39725         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
39726         return ret_conv;
39727 }
39728
39729 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39730         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
39731         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
39732         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
39733         return ret_val;
39734 }
39735
39736 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
39737         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
39738         LDKStr ret_str = SemanticError_to_str(o_conv);
39739         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39740         Str_free(ret_str);
39741         return ret_conv;
39742 }
39743
39744 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39745         if ((this_ptr & 1) != 0) return;
39746         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39747         CHECK_ACCESS(this_ptr_ptr);
39748         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
39749         FREE((void*)this_ptr);
39750         SignOrCreationError_free(this_ptr_conv);
39751 }
39752
39753 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
39754         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
39755         *ret_copy = SignOrCreationError_clone(arg);
39756 uint64_t ret_ref = (uint64_t)ret_copy;
39757         return ret_ref;
39758 }
39759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39760         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
39761         int64_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
39762         return ret_val;
39763 }
39764
39765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39766         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
39767         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
39768         *ret_copy = SignOrCreationError_clone(orig_conv);
39769         uint64_t ret_ref = (uint64_t)ret_copy;
39770         return ret_ref;
39771 }
39772
39773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
39774         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
39775         *ret_copy = SignOrCreationError_sign_error();
39776         uint64_t ret_ref = (uint64_t)ret_copy;
39777         return ret_ref;
39778 }
39779
39780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
39781         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
39782         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
39783         *ret_copy = SignOrCreationError_creation_error(a_conv);
39784         uint64_t ret_ref = (uint64_t)ret_copy;
39785         return ret_ref;
39786 }
39787
39788 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39789         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
39790         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
39791         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
39792         return ret_val;
39793 }
39794
39795 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
39796         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
39797         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
39798         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39799         Str_free(ret_str);
39800         return ret_conv;
39801 }
39802
39803 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39804         LDKInvoicePayer this_obj_conv;
39805         this_obj_conv.inner = (void*)(this_obj & (~1));
39806         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39807         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39808         InvoicePayer_free(this_obj_conv);
39809 }
39810
39811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39812         if ((this_ptr & 1) != 0) return;
39813         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39814         CHECK_ACCESS(this_ptr_ptr);
39815         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
39816         FREE((void*)this_ptr);
39817         Payer_free(this_ptr_conv);
39818 }
39819
39820 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39821         if ((this_ptr & 1) != 0) return;
39822         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39823         CHECK_ACCESS(this_ptr_ptr);
39824         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
39825         FREE((void*)this_ptr);
39826         Router_free(this_ptr_conv);
39827 }
39828
39829 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39830         LDKRetryAttempts this_obj_conv;
39831         this_obj_conv.inner = (void*)(this_obj & (~1));
39832         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39833         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39834         RetryAttempts_free(this_obj_conv);
39835 }
39836
39837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
39838         LDKRetryAttempts this_ptr_conv;
39839         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39840         this_ptr_conv.is_owned = false;
39841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39842         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
39843         return ret_val;
39844 }
39845
39846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39847         LDKRetryAttempts this_ptr_conv;
39848         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39849         this_ptr_conv.is_owned = false;
39850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39851         RetryAttempts_set_a(&this_ptr_conv, val);
39852 }
39853
39854 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
39855         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
39856         uint64_t ret_ref = 0;
39857         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39858         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39859         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39860         ret_ref = (uint64_t)ret_var.inner;
39861         if (ret_var.is_owned) {
39862                 ret_ref |= 1;
39863         }
39864         return ret_ref;
39865 }
39866
39867 static inline uint64_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
39868         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
39869 uint64_t ret_ref = 0;
39870 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39871 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39872 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39873 ret_ref = (uint64_t)ret_var.inner;
39874 if (ret_var.is_owned) {
39875         ret_ref |= 1;
39876 }
39877         return ret_ref;
39878 }
39879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39880         LDKRetryAttempts arg_conv;
39881         arg_conv.inner = (void*)(arg & (~1));
39882         arg_conv.is_owned = false;
39883         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39884         int64_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
39885         return ret_val;
39886 }
39887
39888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39889         LDKRetryAttempts orig_conv;
39890         orig_conv.inner = (void*)(orig & (~1));
39891         orig_conv.is_owned = false;
39892         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39893         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
39894         uint64_t ret_ref = 0;
39895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39898         ret_ref = (uint64_t)ret_var.inner;
39899         if (ret_var.is_owned) {
39900                 ret_ref |= 1;
39901         }
39902         return ret_ref;
39903 }
39904
39905 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39906         LDKRetryAttempts a_conv;
39907         a_conv.inner = (void*)(a & (~1));
39908         a_conv.is_owned = false;
39909         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39910         LDKRetryAttempts b_conv;
39911         b_conv.inner = (void*)(b & (~1));
39912         b_conv.is_owned = false;
39913         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39914         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
39915         return ret_val;
39916 }
39917
39918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
39919         LDKRetryAttempts o_conv;
39920         o_conv.inner = (void*)(o & (~1));
39921         o_conv.is_owned = false;
39922         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39923         int64_t ret_val = RetryAttempts_hash(&o_conv);
39924         return ret_val;
39925 }
39926
39927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39928         if ((this_ptr & 1) != 0) return;
39929         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39930         CHECK_ACCESS(this_ptr_ptr);
39931         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
39932         FREE((void*)this_ptr);
39933         PaymentError_free(this_ptr_conv);
39934 }
39935
39936 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
39937         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39938         *ret_copy = PaymentError_clone(arg);
39939 uint64_t ret_ref = (uint64_t)ret_copy;
39940         return ret_ref;
39941 }
39942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39943         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
39944         int64_t ret_val = PaymentError_clone_ptr(arg_conv);
39945         return ret_val;
39946 }
39947
39948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39949         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
39950         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39951         *ret_copy = PaymentError_clone(orig_conv);
39952         uint64_t ret_ref = (uint64_t)ret_copy;
39953         return ret_ref;
39954 }
39955
39956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
39957         LDKStr a_conv = java_to_owned_str(env, a);
39958         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39959         *ret_copy = PaymentError_invoice(a_conv);
39960         uint64_t ret_ref = (uint64_t)ret_copy;
39961         return ret_ref;
39962 }
39963
39964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
39965         LDKLightningError a_conv;
39966         a_conv.inner = (void*)(a & (~1));
39967         a_conv.is_owned = (a & 1) || (a == 0);
39968         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39969         a_conv = LightningError_clone(&a_conv);
39970         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39971         *ret_copy = PaymentError_routing(a_conv);
39972         uint64_t ret_ref = (uint64_t)ret_copy;
39973         return ret_ref;
39974 }
39975
39976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
39977         void* a_ptr = (void*)(((uint64_t)a) & ~1);
39978         CHECK_ACCESS(a_ptr);
39979         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
39980         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
39981         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39982         *ret_copy = PaymentError_sending(a_conv);
39983         uint64_t ret_ref = (uint64_t)ret_copy;
39984         return ret_ref;
39985 }
39986
39987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1new(JNIEnv *env, jclass clz, int64_t payer, int64_t router, int64_t scorer, int64_t logger, int64_t event_handler, int64_t retry_attempts) {
39988         void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
39989         CHECK_ACCESS(payer_ptr);
39990         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
39991         if (payer_conv.free == LDKPayer_JCalls_free) {
39992                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39993                 LDKPayer_JCalls_cloned(&payer_conv);
39994         }
39995         void* router_ptr = (void*)(((uint64_t)router) & ~1);
39996         CHECK_ACCESS(router_ptr);
39997         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
39998         if (router_conv.free == LDKRouter_JCalls_free) {
39999                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40000                 LDKRouter_JCalls_cloned(&router_conv);
40001         }
40002         LDKLockableScore scorer_conv;
40003         scorer_conv.inner = (void*)(scorer & (~1));
40004         scorer_conv.is_owned = false;
40005         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
40006         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
40007         CHECK_ACCESS(logger_ptr);
40008         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40009         if (logger_conv.free == LDKLogger_JCalls_free) {
40010                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40011                 LDKLogger_JCalls_cloned(&logger_conv);
40012         }
40013         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
40014         CHECK_ACCESS(event_handler_ptr);
40015         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
40016         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
40017                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40018                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
40019         }
40020         LDKRetryAttempts retry_attempts_conv;
40021         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
40022         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
40023         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
40024         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
40025         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
40026         uint64_t ret_ref = 0;
40027         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40028         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40029         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40030         ret_ref = (uint64_t)ret_var.inner;
40031         if (ret_var.is_owned) {
40032                 ret_ref |= 1;
40033         }
40034         return ret_ref;
40035 }
40036
40037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
40038         LDKInvoicePayer this_arg_conv;
40039         this_arg_conv.inner = (void*)(this_arg & (~1));
40040         this_arg_conv.is_owned = false;
40041         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40042         LDKInvoice invoice_conv;
40043         invoice_conv.inner = (void*)(invoice & (~1));
40044         invoice_conv.is_owned = false;
40045         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
40046         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40047         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
40048         return (uint64_t)ret_conv;
40049 }
40050
40051 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1zero_1value_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice, int64_t amount_msats) {
40052         LDKInvoicePayer this_arg_conv;
40053         this_arg_conv.inner = (void*)(this_arg & (~1));
40054         this_arg_conv.is_owned = false;
40055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40056         LDKInvoice invoice_conv;
40057         invoice_conv.inner = (void*)(invoice & (~1));
40058         invoice_conv.is_owned = false;
40059         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
40060         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40061         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
40062         return (uint64_t)ret_conv;
40063 }
40064
40065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
40066         LDKInvoicePayer this_arg_conv;
40067         this_arg_conv.inner = (void*)(this_arg & (~1));
40068         this_arg_conv.is_owned = false;
40069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40070         unsigned char payment_hash_arr[32];
40071         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
40072         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
40073         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
40074         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
40075 }
40076
40077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40078         LDKInvoicePayer this_arg_conv;
40079         this_arg_conv.inner = (void*)(this_arg & (~1));
40080         this_arg_conv.is_owned = false;
40081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40082         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
40083         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
40084         return (uint64_t)ret_ret;
40085 }
40086
40087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_create_1invoice_1from_1channelmanager(JNIEnv *env, jclass clz, int64_t channelmanager, int64_t keys_manager, jclass network, int64_t amt_msat, jstring description) {
40088         LDKChannelManager channelmanager_conv;
40089         channelmanager_conv.inner = (void*)(channelmanager & (~1));
40090         channelmanager_conv.is_owned = false;
40091         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
40092         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
40093         CHECK_ACCESS(keys_manager_ptr);
40094         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
40095         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
40096                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40097                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
40098         }
40099         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
40100         void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
40101         CHECK_ACCESS(amt_msat_ptr);
40102         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
40103         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
40104         LDKStr description_conv = java_to_owned_str(env, description);
40105         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
40106         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
40107         return (uint64_t)ret_conv;
40108 }
40109
40110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40111         LDKDefaultRouter this_obj_conv;
40112         this_obj_conv.inner = (void*)(this_obj & (~1));
40113         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40115         DefaultRouter_free(this_obj_conv);
40116 }
40117
40118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
40119         LDKNetworkGraph network_graph_conv;
40120         network_graph_conv.inner = (void*)(network_graph & (~1));
40121         network_graph_conv.is_owned = false;
40122         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
40123         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
40124         CHECK_ACCESS(logger_ptr);
40125         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40126         if (logger_conv.free == LDKLogger_JCalls_free) {
40127                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40128                 LDKLogger_JCalls_cloned(&logger_conv);
40129         }
40130         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
40131         uint64_t ret_ref = 0;
40132         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40133         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40134         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40135         ret_ref = (uint64_t)ret_var.inner;
40136         if (ret_var.is_owned) {
40137                 ret_ref |= 1;
40138         }
40139         return ret_ref;
40140 }
40141
40142 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
40143         LDKDefaultRouter this_arg_conv;
40144         this_arg_conv.inner = (void*)(this_arg & (~1));
40145         this_arg_conv.is_owned = false;
40146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40147         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
40148         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
40149         return (uint64_t)ret_ret;
40150 }
40151
40152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
40153         LDKChannelManager this_arg_conv;
40154         this_arg_conv.inner = (void*)(this_arg & (~1));
40155         this_arg_conv.is_owned = false;
40156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40157         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
40158         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
40159         return (uint64_t)ret_ret;
40160 }
40161
40162 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
40163         LDKStr s_conv = java_to_owned_str(env, s);
40164         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
40165         *ret_conv = SiPrefix_from_str(s_conv);
40166         return (uint64_t)ret_conv;
40167 }
40168
40169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
40170         LDKStr s_conv = java_to_owned_str(env, s);
40171         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
40172         *ret_conv = Invoice_from_str(s_conv);
40173         return (uint64_t)ret_conv;
40174 }
40175
40176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
40177         LDKStr s_conv = java_to_owned_str(env, s);
40178         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
40179         *ret_conv = SignedRawInvoice_from_str(s_conv);
40180         return (uint64_t)ret_conv;
40181 }
40182
40183 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40184         LDKInvoice o_conv;
40185         o_conv.inner = (void*)(o & (~1));
40186         o_conv.is_owned = false;
40187         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40188         LDKStr ret_str = Invoice_to_str(&o_conv);
40189         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40190         Str_free(ret_str);
40191         return ret_conv;
40192 }
40193
40194 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40195         LDKSignedRawInvoice o_conv;
40196         o_conv.inner = (void*)(o & (~1));
40197         o_conv.is_owned = false;
40198         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40199         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
40200         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40201         Str_free(ret_str);
40202         return ret_conv;
40203 }
40204
40205 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40206         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
40207         LDKStr ret_str = Currency_to_str(o_conv);
40208         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40209         Str_free(ret_str);
40210         return ret_conv;
40211 }
40212
40213 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40214         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
40215         LDKStr ret_str = SiPrefix_to_str(o_conv);
40216         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40217         Str_free(ret_str);
40218         return ret_conv;
40219 }
40220