Update auto-generated bindings
[ldk-java] / src / main / jni / bindings.c
1 #define LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ LDKCVec_TransactionOutputsZ
2 #define CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free CVec_TransactionOutputsZ_free
3 #include <jni.h>
4 // On OSX jlong (ie long long) is not equivalent to int64_t, so we override here
5 #define int64_t jlong
6 #include "org_ldk_impl_bindings.h"
7 #include <lightning.h>
8 #include <string.h>
9 #include <stdatomic.h>
10 #include <stdlib.h>
11
12 #define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
13 #define MALLOC(a, _) malloc(a)
14 #define FREE(p) if ((uint64_t)(p) > 4096) { free(p); }
15 #define CHECK_ACCESS(p)
16 #define CHECK_INNER_FIELD_ACCESS_OR_NULL(v)
17 #define DO_ASSERT(a) (void)(a)
18 #define CHECK(a)
19
20 static jmethodID ordinal_meth = NULL;
21 static jmethodID slicedef_meth = NULL;
22 static jclass slicedef_cls = NULL;
23 JNIEXPORT void Java_org_ldk_impl_bindings_init(JNIEnv * env, jclass _b, jclass enum_class, jclass slicedef_class) {
24         ordinal_meth = (*env)->GetMethodID(env, enum_class, "ordinal", "()I");
25         CHECK(ordinal_meth != NULL);
26         slicedef_meth = (*env)->GetMethodID(env, slicedef_class, "<init>", "(JJJ)V");
27         CHECK(slicedef_meth != NULL);
28         slicedef_cls = (*env)->NewGlobalRef(env, slicedef_class);
29         CHECK(slicedef_cls != NULL);
30 }
31
32 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_deref_1bool (JNIEnv * env, jclass _a, jlong ptr) {
33         return *((bool*)ptr);
34 }
35 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_deref_1long (JNIEnv * env, jclass _a, jlong ptr) {
36         return *((long*)ptr);
37 }
38 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_free_1heap_1ptr (JNIEnv * env, jclass _a, jlong ptr) {
39         FREE((void*)ptr);
40 }
41 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_read_1bytes (JNIEnv * env, jclass _b, jlong ptr, jlong len) {
42         jbyteArray ret_arr = (*env)->NewByteArray(env, len);
43         (*env)->SetByteArrayRegion(env, ret_arr, 0, len, (unsigned char*)ptr);
44         return ret_arr;
45 }
46 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes (JNIEnv * env, jclass _b, jlong slice_ptr) {
47         LDKu8slice *slice = (LDKu8slice*)slice_ptr;
48         jbyteArray ret_arr = (*env)->NewByteArray(env, slice->datalen);
49         (*env)->SetByteArrayRegion(env, ret_arr, 0, slice->datalen, slice->data);
50         return ret_arr;
51 }
52 JNIEXPORT int64_t impl_bindings_bytes_1to_1u8_1vec (JNIEnv * env, jclass _b, jbyteArray bytes) {
53         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "LDKCVec_u8");
54         vec->datalen = (*env)->GetArrayLength(env, bytes);
55         vec->data = (uint8_t*)MALLOC(vec->datalen, "LDKCVec_u8Z Bytes");
56         (*env)->GetByteArrayRegion (env, bytes, 0, vec->datalen, vec->data);
57         return (uint64_t)vec;
58 }
59 JNIEXPORT jbyteArray JNICALL Java_org_ldk_impl_bindings_txpointer_1get_1buffer (JNIEnv * env, jclass _b, jlong ptr) {
60         LDKTransaction *txdata = (LDKTransaction*)ptr;
61         LDKu8slice slice;
62         slice.data = txdata->data;
63         slice.datalen = txdata->datalen;
64         return Java_org_ldk_impl_bindings_get_1u8_1slice_1bytes(env, _b, (uint64_t)&slice);
65 }
66 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1txpointer_1copy_1data (JNIEnv * env, jclass _b, jbyteArray bytes) {
67         LDKTransaction *txdata = (LDKTransaction*)MALLOC(sizeof(LDKTransaction), "LDKTransaction");
68         txdata->datalen = (*env)->GetArrayLength(env, bytes);
69         txdata->data = (uint8_t*)MALLOC(txdata->datalen, "Tx Data Bytes");
70         txdata->data_is_owned = false;
71         (*env)->GetByteArrayRegion (env, bytes, 0, txdata->datalen, txdata->data);
72         return (uint64_t)txdata;
73 }
74 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_txpointer_1free (JNIEnv * env, jclass _b, jlong ptr) {
75         LDKTransaction *tx = (LDKTransaction*)ptr;
76         tx->data_is_owned = true;
77         Transaction_free(*tx);
78         FREE((void*)ptr);
79 }
80 JNIEXPORT jlong JNICALL Java_org_ldk_impl_bindings_vec_1slice_1len (JNIEnv * env, jclass _a, jlong ptr) {
81         // Check offsets of a few Vec types are all consistent as we're meant to be generic across types
82         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_SignatureZ, datalen), "Vec<*> needs to be mapped identically");
83         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_MessageSendEventZ, datalen), "Vec<*> needs to be mapped identically");
84         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_EventZ, datalen), "Vec<*> needs to be mapped identically");
85         _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKCVec_C2Tuple_usizeTransactionZZ, datalen), "Vec<*> needs to be mapped identically");
86         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)ptr;
87         return (uint64_t)vec->datalen;
88 }
89 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_new_1empty_1slice_1vec (JNIEnv * env, jclass _b) {
90         // Check sizes of a few Vec types are all consistent as we're meant to be generic across types
91         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_SignatureZ), "Vec<*> needs to be mapped identically");
92         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_MessageSendEventZ), "Vec<*> needs to be mapped identically");
93         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_EventZ), "Vec<*> needs to be mapped identically");
94         _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKCVec_C2Tuple_usizeTransactionZZ), "Vec<*> needs to be mapped identically");
95         LDKCVec_u8Z *vec = (LDKCVec_u8Z*)MALLOC(sizeof(LDKCVec_u8Z), "Empty LDKCVec");
96         vec->data = NULL;
97         vec->datalen = 0;
98         return (uint64_t)vec;
99 }
100
101 // We assume that CVec_u8Z and u8slice are the same size and layout (and thus pointers to the two can be mixed)
102 _Static_assert(sizeof(LDKCVec_u8Z) == sizeof(LDKu8slice), "Vec<u8> and [u8] need to have been mapped identically");
103 _Static_assert(offsetof(LDKCVec_u8Z, data) == offsetof(LDKu8slice, data), "Vec<u8> and [u8] need to have been mapped identically");
104 _Static_assert(offsetof(LDKCVec_u8Z, datalen) == offsetof(LDKu8slice, datalen), "Vec<u8> and [u8] need to have been mapped identically");
105
106 _Static_assert(sizeof(jlong) == sizeof(int64_t), "We assume that j-types are the same as C types");
107 _Static_assert(sizeof(jbyte) == sizeof(char), "We assume that j-types are the same as C types");
108 _Static_assert(sizeof(void*) <= 8, "Pointers must fit into 64 bits");
109
110 typedef jlongArray int64_tArray;
111 typedef jbyteArray int8_tArray;
112
113 static inline jstring str_ref_to_java(JNIEnv *env, const char* chars, size_t len) {
114         // Sadly we need to create a temporary because Java can't accept a char* without a 0-terminator
115         char* conv_buf = MALLOC(len + 1, "str conv buf");
116         memcpy(conv_buf, chars, len);
117         conv_buf[len] = 0;
118         jstring ret = (*env)->NewStringUTF(env, conv_buf);
119         FREE(conv_buf);
120         return ret;
121 }
122 static inline LDKStr java_to_owned_str(JNIEnv *env, jstring str) {
123         uint64_t str_len = (*env)->GetStringUTFLength(env, str);
124         char* newchars = MALLOC(str_len + 1, "String chars");
125         const char* jchars = (*env)->GetStringUTFChars(env, str, NULL);
126         memcpy(newchars, jchars, str_len);
127         newchars[str_len] = 0;
128         (*env)->ReleaseStringUTFChars(env, str, jchars);
129         LDKStr res = {
130                 .chars = newchars,
131                 .len = str_len,
132                 .chars_is_owned = true
133         };
134         return res;
135 }
136
137 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1c_1bindings_1version(JNIEnv *env, jclass _c) {
138         return str_ref_to_java(env, check_get_ldk_bindings_version(), strlen(check_get_ldk_bindings_version()));
139 }
140 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_get_1ldk_1version(JNIEnv *env, jclass _c) {
141         return str_ref_to_java(env, check_get_ldk_version(), strlen(check_get_ldk_version()));
142 }
143 #include "version.c"
144 static jclass arr_of_B_clz = NULL;
145 static jclass arr_of_J_clz = NULL;
146 JNIEXPORT void Java_org_ldk_impl_bindings_init_1class_1cache(JNIEnv * env, jclass clz) {
147         arr_of_B_clz = (*env)->FindClass(env, "[B");
148         CHECK(arr_of_B_clz != NULL);
149         arr_of_B_clz = (*env)->NewGlobalRef(env, arr_of_B_clz);
150         arr_of_J_clz = (*env)->FindClass(env, "[J");
151         CHECK(arr_of_J_clz != NULL);
152         arr_of_J_clz = (*env)->NewGlobalRef(env, arr_of_J_clz);
153 }
154 static inline struct LDKThirtyTwoBytes ThirtyTwoBytes_clone(const struct LDKThirtyTwoBytes *orig) { struct LDKThirtyTwoBytes ret; memcpy(ret.data, orig->data, 32); return ret; }
155 static inline LDKAccessError LDKAccessError_from_java(JNIEnv *env, jclass clz) {
156         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
157                 case 0: return LDKAccessError_UnknownChain;
158                 case 1: return LDKAccessError_UnknownTx;
159         }
160         abort();
161 }
162 static jclass AccessError_class = NULL;
163 static jfieldID AccessError_LDKAccessError_UnknownChain = NULL;
164 static jfieldID AccessError_LDKAccessError_UnknownTx = NULL;
165 JNIEXPORT void JNICALL Java_org_ldk_enums_AccessError_init (JNIEnv *env, jclass clz) {
166         AccessError_class = (*env)->NewGlobalRef(env, clz);
167         CHECK(AccessError_class != NULL);
168         AccessError_LDKAccessError_UnknownChain = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownChain", "Lorg/ldk/enums/AccessError;");
169         CHECK(AccessError_LDKAccessError_UnknownChain != NULL);
170         AccessError_LDKAccessError_UnknownTx = (*env)->GetStaticFieldID(env, AccessError_class, "LDKAccessError_UnknownTx", "Lorg/ldk/enums/AccessError;");
171         CHECK(AccessError_LDKAccessError_UnknownTx != NULL);
172 }
173 static inline jclass LDKAccessError_to_java(JNIEnv *env, LDKAccessError val) {
174         switch (val) {
175                 case LDKAccessError_UnknownChain:
176                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownChain);
177                 case LDKAccessError_UnknownTx:
178                         return (*env)->GetStaticObjectField(env, AccessError_class, AccessError_LDKAccessError_UnknownTx);
179                 default: abort();
180         }
181 }
182
183 static inline LDKChannelMonitorUpdateErr LDKChannelMonitorUpdateErr_from_java(JNIEnv *env, jclass clz) {
184         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
185                 case 0: return LDKChannelMonitorUpdateErr_TemporaryFailure;
186                 case 1: return LDKChannelMonitorUpdateErr_PermanentFailure;
187         }
188         abort();
189 }
190 static jclass ChannelMonitorUpdateErr_class = NULL;
191 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = NULL;
192 static jfieldID ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = NULL;
193 JNIEXPORT void JNICALL Java_org_ldk_enums_ChannelMonitorUpdateErr_init (JNIEnv *env, jclass clz) {
194         ChannelMonitorUpdateErr_class = (*env)->NewGlobalRef(env, clz);
195         CHECK(ChannelMonitorUpdateErr_class != NULL);
196         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_TemporaryFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
197         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure != NULL);
198         ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure = (*env)->GetStaticFieldID(env, ChannelMonitorUpdateErr_class, "LDKChannelMonitorUpdateErr_PermanentFailure", "Lorg/ldk/enums/ChannelMonitorUpdateErr;");
199         CHECK(ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure != NULL);
200 }
201 static inline jclass LDKChannelMonitorUpdateErr_to_java(JNIEnv *env, LDKChannelMonitorUpdateErr val) {
202         switch (val) {
203                 case LDKChannelMonitorUpdateErr_TemporaryFailure:
204                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_TemporaryFailure);
205                 case LDKChannelMonitorUpdateErr_PermanentFailure:
206                         return (*env)->GetStaticObjectField(env, ChannelMonitorUpdateErr_class, ChannelMonitorUpdateErr_LDKChannelMonitorUpdateErr_PermanentFailure);
207                 default: abort();
208         }
209 }
210
211 static inline LDKConfirmationTarget LDKConfirmationTarget_from_java(JNIEnv *env, jclass clz) {
212         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
213                 case 0: return LDKConfirmationTarget_Background;
214                 case 1: return LDKConfirmationTarget_Normal;
215                 case 2: return LDKConfirmationTarget_HighPriority;
216         }
217         abort();
218 }
219 static jclass ConfirmationTarget_class = NULL;
220 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Background = NULL;
221 static jfieldID ConfirmationTarget_LDKConfirmationTarget_Normal = NULL;
222 static jfieldID ConfirmationTarget_LDKConfirmationTarget_HighPriority = NULL;
223 JNIEXPORT void JNICALL Java_org_ldk_enums_ConfirmationTarget_init (JNIEnv *env, jclass clz) {
224         ConfirmationTarget_class = (*env)->NewGlobalRef(env, clz);
225         CHECK(ConfirmationTarget_class != NULL);
226         ConfirmationTarget_LDKConfirmationTarget_Background = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Background", "Lorg/ldk/enums/ConfirmationTarget;");
227         CHECK(ConfirmationTarget_LDKConfirmationTarget_Background != NULL);
228         ConfirmationTarget_LDKConfirmationTarget_Normal = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_Normal", "Lorg/ldk/enums/ConfirmationTarget;");
229         CHECK(ConfirmationTarget_LDKConfirmationTarget_Normal != NULL);
230         ConfirmationTarget_LDKConfirmationTarget_HighPriority = (*env)->GetStaticFieldID(env, ConfirmationTarget_class, "LDKConfirmationTarget_HighPriority", "Lorg/ldk/enums/ConfirmationTarget;");
231         CHECK(ConfirmationTarget_LDKConfirmationTarget_HighPriority != NULL);
232 }
233 static inline jclass LDKConfirmationTarget_to_java(JNIEnv *env, LDKConfirmationTarget val) {
234         switch (val) {
235                 case LDKConfirmationTarget_Background:
236                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Background);
237                 case LDKConfirmationTarget_Normal:
238                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_Normal);
239                 case LDKConfirmationTarget_HighPriority:
240                         return (*env)->GetStaticObjectField(env, ConfirmationTarget_class, ConfirmationTarget_LDKConfirmationTarget_HighPriority);
241                 default: abort();
242         }
243 }
244
245 static inline LDKCreationError LDKCreationError_from_java(JNIEnv *env, jclass clz) {
246         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
247                 case 0: return LDKCreationError_DescriptionTooLong;
248                 case 1: return LDKCreationError_RouteTooLong;
249                 case 2: return LDKCreationError_TimestampOutOfBounds;
250                 case 3: return LDKCreationError_ExpiryTimeOutOfBounds;
251         }
252         abort();
253 }
254 static jclass CreationError_class = NULL;
255 static jfieldID CreationError_LDKCreationError_DescriptionTooLong = NULL;
256 static jfieldID CreationError_LDKCreationError_RouteTooLong = NULL;
257 static jfieldID CreationError_LDKCreationError_TimestampOutOfBounds = NULL;
258 static jfieldID CreationError_LDKCreationError_ExpiryTimeOutOfBounds = NULL;
259 JNIEXPORT void JNICALL Java_org_ldk_enums_CreationError_init (JNIEnv *env, jclass clz) {
260         CreationError_class = (*env)->NewGlobalRef(env, clz);
261         CHECK(CreationError_class != NULL);
262         CreationError_LDKCreationError_DescriptionTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_DescriptionTooLong", "Lorg/ldk/enums/CreationError;");
263         CHECK(CreationError_LDKCreationError_DescriptionTooLong != NULL);
264         CreationError_LDKCreationError_RouteTooLong = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_RouteTooLong", "Lorg/ldk/enums/CreationError;");
265         CHECK(CreationError_LDKCreationError_RouteTooLong != NULL);
266         CreationError_LDKCreationError_TimestampOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_TimestampOutOfBounds", "Lorg/ldk/enums/CreationError;");
267         CHECK(CreationError_LDKCreationError_TimestampOutOfBounds != NULL);
268         CreationError_LDKCreationError_ExpiryTimeOutOfBounds = (*env)->GetStaticFieldID(env, CreationError_class, "LDKCreationError_ExpiryTimeOutOfBounds", "Lorg/ldk/enums/CreationError;");
269         CHECK(CreationError_LDKCreationError_ExpiryTimeOutOfBounds != NULL);
270 }
271 static inline jclass LDKCreationError_to_java(JNIEnv *env, LDKCreationError val) {
272         switch (val) {
273                 case LDKCreationError_DescriptionTooLong:
274                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_DescriptionTooLong);
275                 case LDKCreationError_RouteTooLong:
276                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_RouteTooLong);
277                 case LDKCreationError_TimestampOutOfBounds:
278                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_TimestampOutOfBounds);
279                 case LDKCreationError_ExpiryTimeOutOfBounds:
280                         return (*env)->GetStaticObjectField(env, CreationError_class, CreationError_LDKCreationError_ExpiryTimeOutOfBounds);
281                 default: abort();
282         }
283 }
284
285 static inline LDKCurrency LDKCurrency_from_java(JNIEnv *env, jclass clz) {
286         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
287                 case 0: return LDKCurrency_Bitcoin;
288                 case 1: return LDKCurrency_BitcoinTestnet;
289                 case 2: return LDKCurrency_Regtest;
290                 case 3: return LDKCurrency_Simnet;
291                 case 4: return LDKCurrency_Signet;
292         }
293         abort();
294 }
295 static jclass Currency_class = NULL;
296 static jfieldID Currency_LDKCurrency_Bitcoin = NULL;
297 static jfieldID Currency_LDKCurrency_BitcoinTestnet = NULL;
298 static jfieldID Currency_LDKCurrency_Regtest = NULL;
299 static jfieldID Currency_LDKCurrency_Simnet = NULL;
300 static jfieldID Currency_LDKCurrency_Signet = NULL;
301 JNIEXPORT void JNICALL Java_org_ldk_enums_Currency_init (JNIEnv *env, jclass clz) {
302         Currency_class = (*env)->NewGlobalRef(env, clz);
303         CHECK(Currency_class != NULL);
304         Currency_LDKCurrency_Bitcoin = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Bitcoin", "Lorg/ldk/enums/Currency;");
305         CHECK(Currency_LDKCurrency_Bitcoin != NULL);
306         Currency_LDKCurrency_BitcoinTestnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_BitcoinTestnet", "Lorg/ldk/enums/Currency;");
307         CHECK(Currency_LDKCurrency_BitcoinTestnet != NULL);
308         Currency_LDKCurrency_Regtest = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Regtest", "Lorg/ldk/enums/Currency;");
309         CHECK(Currency_LDKCurrency_Regtest != NULL);
310         Currency_LDKCurrency_Simnet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Simnet", "Lorg/ldk/enums/Currency;");
311         CHECK(Currency_LDKCurrency_Simnet != NULL);
312         Currency_LDKCurrency_Signet = (*env)->GetStaticFieldID(env, Currency_class, "LDKCurrency_Signet", "Lorg/ldk/enums/Currency;");
313         CHECK(Currency_LDKCurrency_Signet != NULL);
314 }
315 static inline jclass LDKCurrency_to_java(JNIEnv *env, LDKCurrency val) {
316         switch (val) {
317                 case LDKCurrency_Bitcoin:
318                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Bitcoin);
319                 case LDKCurrency_BitcoinTestnet:
320                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_BitcoinTestnet);
321                 case LDKCurrency_Regtest:
322                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Regtest);
323                 case LDKCurrency_Simnet:
324                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Simnet);
325                 case LDKCurrency_Signet:
326                         return (*env)->GetStaticObjectField(env, Currency_class, Currency_LDKCurrency_Signet);
327                 default: abort();
328         }
329 }
330
331 static inline LDKIOError LDKIOError_from_java(JNIEnv *env, jclass clz) {
332         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
333                 case 0: return LDKIOError_NotFound;
334                 case 1: return LDKIOError_PermissionDenied;
335                 case 2: return LDKIOError_ConnectionRefused;
336                 case 3: return LDKIOError_ConnectionReset;
337                 case 4: return LDKIOError_ConnectionAborted;
338                 case 5: return LDKIOError_NotConnected;
339                 case 6: return LDKIOError_AddrInUse;
340                 case 7: return LDKIOError_AddrNotAvailable;
341                 case 8: return LDKIOError_BrokenPipe;
342                 case 9: return LDKIOError_AlreadyExists;
343                 case 10: return LDKIOError_WouldBlock;
344                 case 11: return LDKIOError_InvalidInput;
345                 case 12: return LDKIOError_InvalidData;
346                 case 13: return LDKIOError_TimedOut;
347                 case 14: return LDKIOError_WriteZero;
348                 case 15: return LDKIOError_Interrupted;
349                 case 16: return LDKIOError_Other;
350                 case 17: return LDKIOError_UnexpectedEof;
351         }
352         abort();
353 }
354 static jclass IOError_class = NULL;
355 static jfieldID IOError_LDKIOError_NotFound = NULL;
356 static jfieldID IOError_LDKIOError_PermissionDenied = NULL;
357 static jfieldID IOError_LDKIOError_ConnectionRefused = NULL;
358 static jfieldID IOError_LDKIOError_ConnectionReset = NULL;
359 static jfieldID IOError_LDKIOError_ConnectionAborted = NULL;
360 static jfieldID IOError_LDKIOError_NotConnected = NULL;
361 static jfieldID IOError_LDKIOError_AddrInUse = NULL;
362 static jfieldID IOError_LDKIOError_AddrNotAvailable = NULL;
363 static jfieldID IOError_LDKIOError_BrokenPipe = NULL;
364 static jfieldID IOError_LDKIOError_AlreadyExists = NULL;
365 static jfieldID IOError_LDKIOError_WouldBlock = NULL;
366 static jfieldID IOError_LDKIOError_InvalidInput = NULL;
367 static jfieldID IOError_LDKIOError_InvalidData = NULL;
368 static jfieldID IOError_LDKIOError_TimedOut = NULL;
369 static jfieldID IOError_LDKIOError_WriteZero = NULL;
370 static jfieldID IOError_LDKIOError_Interrupted = NULL;
371 static jfieldID IOError_LDKIOError_Other = NULL;
372 static jfieldID IOError_LDKIOError_UnexpectedEof = NULL;
373 JNIEXPORT void JNICALL Java_org_ldk_enums_IOError_init (JNIEnv *env, jclass clz) {
374         IOError_class = (*env)->NewGlobalRef(env, clz);
375         CHECK(IOError_class != NULL);
376         IOError_LDKIOError_NotFound = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotFound", "Lorg/ldk/enums/IOError;");
377         CHECK(IOError_LDKIOError_NotFound != NULL);
378         IOError_LDKIOError_PermissionDenied = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_PermissionDenied", "Lorg/ldk/enums/IOError;");
379         CHECK(IOError_LDKIOError_PermissionDenied != NULL);
380         IOError_LDKIOError_ConnectionRefused = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionRefused", "Lorg/ldk/enums/IOError;");
381         CHECK(IOError_LDKIOError_ConnectionRefused != NULL);
382         IOError_LDKIOError_ConnectionReset = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionReset", "Lorg/ldk/enums/IOError;");
383         CHECK(IOError_LDKIOError_ConnectionReset != NULL);
384         IOError_LDKIOError_ConnectionAborted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_ConnectionAborted", "Lorg/ldk/enums/IOError;");
385         CHECK(IOError_LDKIOError_ConnectionAborted != NULL);
386         IOError_LDKIOError_NotConnected = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_NotConnected", "Lorg/ldk/enums/IOError;");
387         CHECK(IOError_LDKIOError_NotConnected != NULL);
388         IOError_LDKIOError_AddrInUse = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrInUse", "Lorg/ldk/enums/IOError;");
389         CHECK(IOError_LDKIOError_AddrInUse != NULL);
390         IOError_LDKIOError_AddrNotAvailable = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AddrNotAvailable", "Lorg/ldk/enums/IOError;");
391         CHECK(IOError_LDKIOError_AddrNotAvailable != NULL);
392         IOError_LDKIOError_BrokenPipe = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_BrokenPipe", "Lorg/ldk/enums/IOError;");
393         CHECK(IOError_LDKIOError_BrokenPipe != NULL);
394         IOError_LDKIOError_AlreadyExists = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_AlreadyExists", "Lorg/ldk/enums/IOError;");
395         CHECK(IOError_LDKIOError_AlreadyExists != NULL);
396         IOError_LDKIOError_WouldBlock = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WouldBlock", "Lorg/ldk/enums/IOError;");
397         CHECK(IOError_LDKIOError_WouldBlock != NULL);
398         IOError_LDKIOError_InvalidInput = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidInput", "Lorg/ldk/enums/IOError;");
399         CHECK(IOError_LDKIOError_InvalidInput != NULL);
400         IOError_LDKIOError_InvalidData = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_InvalidData", "Lorg/ldk/enums/IOError;");
401         CHECK(IOError_LDKIOError_InvalidData != NULL);
402         IOError_LDKIOError_TimedOut = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_TimedOut", "Lorg/ldk/enums/IOError;");
403         CHECK(IOError_LDKIOError_TimedOut != NULL);
404         IOError_LDKIOError_WriteZero = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_WriteZero", "Lorg/ldk/enums/IOError;");
405         CHECK(IOError_LDKIOError_WriteZero != NULL);
406         IOError_LDKIOError_Interrupted = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Interrupted", "Lorg/ldk/enums/IOError;");
407         CHECK(IOError_LDKIOError_Interrupted != NULL);
408         IOError_LDKIOError_Other = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_Other", "Lorg/ldk/enums/IOError;");
409         CHECK(IOError_LDKIOError_Other != NULL);
410         IOError_LDKIOError_UnexpectedEof = (*env)->GetStaticFieldID(env, IOError_class, "LDKIOError_UnexpectedEof", "Lorg/ldk/enums/IOError;");
411         CHECK(IOError_LDKIOError_UnexpectedEof != NULL);
412 }
413 static inline jclass LDKIOError_to_java(JNIEnv *env, LDKIOError val) {
414         switch (val) {
415                 case LDKIOError_NotFound:
416                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotFound);
417                 case LDKIOError_PermissionDenied:
418                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_PermissionDenied);
419                 case LDKIOError_ConnectionRefused:
420                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionRefused);
421                 case LDKIOError_ConnectionReset:
422                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionReset);
423                 case LDKIOError_ConnectionAborted:
424                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_ConnectionAborted);
425                 case LDKIOError_NotConnected:
426                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_NotConnected);
427                 case LDKIOError_AddrInUse:
428                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrInUse);
429                 case LDKIOError_AddrNotAvailable:
430                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AddrNotAvailable);
431                 case LDKIOError_BrokenPipe:
432                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_BrokenPipe);
433                 case LDKIOError_AlreadyExists:
434                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_AlreadyExists);
435                 case LDKIOError_WouldBlock:
436                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WouldBlock);
437                 case LDKIOError_InvalidInput:
438                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidInput);
439                 case LDKIOError_InvalidData:
440                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_InvalidData);
441                 case LDKIOError_TimedOut:
442                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_TimedOut);
443                 case LDKIOError_WriteZero:
444                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_WriteZero);
445                 case LDKIOError_Interrupted:
446                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Interrupted);
447                 case LDKIOError_Other:
448                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_Other);
449                 case LDKIOError_UnexpectedEof:
450                         return (*env)->GetStaticObjectField(env, IOError_class, IOError_LDKIOError_UnexpectedEof);
451                 default: abort();
452         }
453 }
454
455 static inline LDKLevel LDKLevel_from_java(JNIEnv *env, jclass clz) {
456         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
457                 case 0: return LDKLevel_Trace;
458                 case 1: return LDKLevel_Debug;
459                 case 2: return LDKLevel_Info;
460                 case 3: return LDKLevel_Warn;
461                 case 4: return LDKLevel_Error;
462         }
463         abort();
464 }
465 static jclass Level_class = NULL;
466 static jfieldID Level_LDKLevel_Trace = NULL;
467 static jfieldID Level_LDKLevel_Debug = NULL;
468 static jfieldID Level_LDKLevel_Info = NULL;
469 static jfieldID Level_LDKLevel_Warn = NULL;
470 static jfieldID Level_LDKLevel_Error = NULL;
471 JNIEXPORT void JNICALL Java_org_ldk_enums_Level_init (JNIEnv *env, jclass clz) {
472         Level_class = (*env)->NewGlobalRef(env, clz);
473         CHECK(Level_class != NULL);
474         Level_LDKLevel_Trace = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Trace", "Lorg/ldk/enums/Level;");
475         CHECK(Level_LDKLevel_Trace != NULL);
476         Level_LDKLevel_Debug = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Debug", "Lorg/ldk/enums/Level;");
477         CHECK(Level_LDKLevel_Debug != NULL);
478         Level_LDKLevel_Info = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Info", "Lorg/ldk/enums/Level;");
479         CHECK(Level_LDKLevel_Info != NULL);
480         Level_LDKLevel_Warn = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Warn", "Lorg/ldk/enums/Level;");
481         CHECK(Level_LDKLevel_Warn != NULL);
482         Level_LDKLevel_Error = (*env)->GetStaticFieldID(env, Level_class, "LDKLevel_Error", "Lorg/ldk/enums/Level;");
483         CHECK(Level_LDKLevel_Error != NULL);
484 }
485 static inline jclass LDKLevel_to_java(JNIEnv *env, LDKLevel val) {
486         switch (val) {
487                 case LDKLevel_Trace:
488                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Trace);
489                 case LDKLevel_Debug:
490                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Debug);
491                 case LDKLevel_Info:
492                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Info);
493                 case LDKLevel_Warn:
494                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Warn);
495                 case LDKLevel_Error:
496                         return (*env)->GetStaticObjectField(env, Level_class, Level_LDKLevel_Error);
497                 default: abort();
498         }
499 }
500
501 static inline LDKNetwork LDKNetwork_from_java(JNIEnv *env, jclass clz) {
502         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
503                 case 0: return LDKNetwork_Bitcoin;
504                 case 1: return LDKNetwork_Testnet;
505                 case 2: return LDKNetwork_Regtest;
506                 case 3: return LDKNetwork_Signet;
507         }
508         abort();
509 }
510 static jclass Network_class = NULL;
511 static jfieldID Network_LDKNetwork_Bitcoin = NULL;
512 static jfieldID Network_LDKNetwork_Testnet = NULL;
513 static jfieldID Network_LDKNetwork_Regtest = NULL;
514 static jfieldID Network_LDKNetwork_Signet = NULL;
515 JNIEXPORT void JNICALL Java_org_ldk_enums_Network_init (JNIEnv *env, jclass clz) {
516         Network_class = (*env)->NewGlobalRef(env, clz);
517         CHECK(Network_class != NULL);
518         Network_LDKNetwork_Bitcoin = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Bitcoin", "Lorg/ldk/enums/Network;");
519         CHECK(Network_LDKNetwork_Bitcoin != NULL);
520         Network_LDKNetwork_Testnet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Testnet", "Lorg/ldk/enums/Network;");
521         CHECK(Network_LDKNetwork_Testnet != NULL);
522         Network_LDKNetwork_Regtest = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Regtest", "Lorg/ldk/enums/Network;");
523         CHECK(Network_LDKNetwork_Regtest != NULL);
524         Network_LDKNetwork_Signet = (*env)->GetStaticFieldID(env, Network_class, "LDKNetwork_Signet", "Lorg/ldk/enums/Network;");
525         CHECK(Network_LDKNetwork_Signet != NULL);
526 }
527 static inline jclass LDKNetwork_to_java(JNIEnv *env, LDKNetwork val) {
528         switch (val) {
529                 case LDKNetwork_Bitcoin:
530                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Bitcoin);
531                 case LDKNetwork_Testnet:
532                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Testnet);
533                 case LDKNetwork_Regtest:
534                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Regtest);
535                 case LDKNetwork_Signet:
536                         return (*env)->GetStaticObjectField(env, Network_class, Network_LDKNetwork_Signet);
537                 default: abort();
538         }
539 }
540
541 static inline LDKSecp256k1Error LDKSecp256k1Error_from_java(JNIEnv *env, jclass clz) {
542         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
543                 case 0: return LDKSecp256k1Error_IncorrectSignature;
544                 case 1: return LDKSecp256k1Error_InvalidMessage;
545                 case 2: return LDKSecp256k1Error_InvalidPublicKey;
546                 case 3: return LDKSecp256k1Error_InvalidSignature;
547                 case 4: return LDKSecp256k1Error_InvalidSecretKey;
548                 case 5: return LDKSecp256k1Error_InvalidRecoveryId;
549                 case 6: return LDKSecp256k1Error_InvalidTweak;
550                 case 7: return LDKSecp256k1Error_TweakCheckFailed;
551                 case 8: return LDKSecp256k1Error_NotEnoughMemory;
552         }
553         abort();
554 }
555 static jclass Secp256k1Error_class = NULL;
556 static jfieldID Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = NULL;
557 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidMessage = NULL;
558 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = NULL;
559 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSignature = NULL;
560 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = NULL;
561 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = NULL;
562 static jfieldID Secp256k1Error_LDKSecp256k1Error_InvalidTweak = NULL;
563 static jfieldID Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = NULL;
564 static jfieldID Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = NULL;
565 JNIEXPORT void JNICALL Java_org_ldk_enums_Secp256k1Error_init (JNIEnv *env, jclass clz) {
566         Secp256k1Error_class = (*env)->NewGlobalRef(env, clz);
567         CHECK(Secp256k1Error_class != NULL);
568         Secp256k1Error_LDKSecp256k1Error_IncorrectSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_IncorrectSignature", "Lorg/ldk/enums/Secp256k1Error;");
569         CHECK(Secp256k1Error_LDKSecp256k1Error_IncorrectSignature != NULL);
570         Secp256k1Error_LDKSecp256k1Error_InvalidMessage = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidMessage", "Lorg/ldk/enums/Secp256k1Error;");
571         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidMessage != NULL);
572         Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidPublicKey", "Lorg/ldk/enums/Secp256k1Error;");
573         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey != NULL);
574         Secp256k1Error_LDKSecp256k1Error_InvalidSignature = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSignature", "Lorg/ldk/enums/Secp256k1Error;");
575         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSignature != NULL);
576         Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidSecretKey", "Lorg/ldk/enums/Secp256k1Error;");
577         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey != NULL);
578         Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidRecoveryId", "Lorg/ldk/enums/Secp256k1Error;");
579         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId != NULL);
580         Secp256k1Error_LDKSecp256k1Error_InvalidTweak = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_InvalidTweak", "Lorg/ldk/enums/Secp256k1Error;");
581         CHECK(Secp256k1Error_LDKSecp256k1Error_InvalidTweak != NULL);
582         Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_TweakCheckFailed", "Lorg/ldk/enums/Secp256k1Error;");
583         CHECK(Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed != NULL);
584         Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory = (*env)->GetStaticFieldID(env, Secp256k1Error_class, "LDKSecp256k1Error_NotEnoughMemory", "Lorg/ldk/enums/Secp256k1Error;");
585         CHECK(Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory != NULL);
586 }
587 static inline jclass LDKSecp256k1Error_to_java(JNIEnv *env, LDKSecp256k1Error val) {
588         switch (val) {
589                 case LDKSecp256k1Error_IncorrectSignature:
590                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_IncorrectSignature);
591                 case LDKSecp256k1Error_InvalidMessage:
592                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidMessage);
593                 case LDKSecp256k1Error_InvalidPublicKey:
594                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidPublicKey);
595                 case LDKSecp256k1Error_InvalidSignature:
596                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSignature);
597                 case LDKSecp256k1Error_InvalidSecretKey:
598                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidSecretKey);
599                 case LDKSecp256k1Error_InvalidRecoveryId:
600                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidRecoveryId);
601                 case LDKSecp256k1Error_InvalidTweak:
602                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_InvalidTweak);
603                 case LDKSecp256k1Error_TweakCheckFailed:
604                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_TweakCheckFailed);
605                 case LDKSecp256k1Error_NotEnoughMemory:
606                         return (*env)->GetStaticObjectField(env, Secp256k1Error_class, Secp256k1Error_LDKSecp256k1Error_NotEnoughMemory);
607                 default: abort();
608         }
609 }
610
611 static inline LDKSemanticError LDKSemanticError_from_java(JNIEnv *env, jclass clz) {
612         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
613                 case 0: return LDKSemanticError_NoPaymentHash;
614                 case 1: return LDKSemanticError_MultiplePaymentHashes;
615                 case 2: return LDKSemanticError_NoDescription;
616                 case 3: return LDKSemanticError_MultipleDescriptions;
617                 case 4: return LDKSemanticError_NoPaymentSecret;
618                 case 5: return LDKSemanticError_MultiplePaymentSecrets;
619                 case 6: return LDKSemanticError_InvalidFeatures;
620                 case 7: return LDKSemanticError_InvalidRecoveryId;
621                 case 8: return LDKSemanticError_InvalidSignature;
622                 case 9: return LDKSemanticError_ImpreciseAmount;
623         }
624         abort();
625 }
626 static jclass SemanticError_class = NULL;
627 static jfieldID SemanticError_LDKSemanticError_NoPaymentHash = NULL;
628 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentHashes = NULL;
629 static jfieldID SemanticError_LDKSemanticError_NoDescription = NULL;
630 static jfieldID SemanticError_LDKSemanticError_MultipleDescriptions = NULL;
631 static jfieldID SemanticError_LDKSemanticError_NoPaymentSecret = NULL;
632 static jfieldID SemanticError_LDKSemanticError_MultiplePaymentSecrets = NULL;
633 static jfieldID SemanticError_LDKSemanticError_InvalidFeatures = NULL;
634 static jfieldID SemanticError_LDKSemanticError_InvalidRecoveryId = NULL;
635 static jfieldID SemanticError_LDKSemanticError_InvalidSignature = NULL;
636 static jfieldID SemanticError_LDKSemanticError_ImpreciseAmount = NULL;
637 JNIEXPORT void JNICALL Java_org_ldk_enums_SemanticError_init (JNIEnv *env, jclass clz) {
638         SemanticError_class = (*env)->NewGlobalRef(env, clz);
639         CHECK(SemanticError_class != NULL);
640         SemanticError_LDKSemanticError_NoPaymentHash = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentHash", "Lorg/ldk/enums/SemanticError;");
641         CHECK(SemanticError_LDKSemanticError_NoPaymentHash != NULL);
642         SemanticError_LDKSemanticError_MultiplePaymentHashes = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentHashes", "Lorg/ldk/enums/SemanticError;");
643         CHECK(SemanticError_LDKSemanticError_MultiplePaymentHashes != NULL);
644         SemanticError_LDKSemanticError_NoDescription = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoDescription", "Lorg/ldk/enums/SemanticError;");
645         CHECK(SemanticError_LDKSemanticError_NoDescription != NULL);
646         SemanticError_LDKSemanticError_MultipleDescriptions = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultipleDescriptions", "Lorg/ldk/enums/SemanticError;");
647         CHECK(SemanticError_LDKSemanticError_MultipleDescriptions != NULL);
648         SemanticError_LDKSemanticError_NoPaymentSecret = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_NoPaymentSecret", "Lorg/ldk/enums/SemanticError;");
649         CHECK(SemanticError_LDKSemanticError_NoPaymentSecret != NULL);
650         SemanticError_LDKSemanticError_MultiplePaymentSecrets = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_MultiplePaymentSecrets", "Lorg/ldk/enums/SemanticError;");
651         CHECK(SemanticError_LDKSemanticError_MultiplePaymentSecrets != NULL);
652         SemanticError_LDKSemanticError_InvalidFeatures = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidFeatures", "Lorg/ldk/enums/SemanticError;");
653         CHECK(SemanticError_LDKSemanticError_InvalidFeatures != NULL);
654         SemanticError_LDKSemanticError_InvalidRecoveryId = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidRecoveryId", "Lorg/ldk/enums/SemanticError;");
655         CHECK(SemanticError_LDKSemanticError_InvalidRecoveryId != NULL);
656         SemanticError_LDKSemanticError_InvalidSignature = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_InvalidSignature", "Lorg/ldk/enums/SemanticError;");
657         CHECK(SemanticError_LDKSemanticError_InvalidSignature != NULL);
658         SemanticError_LDKSemanticError_ImpreciseAmount = (*env)->GetStaticFieldID(env, SemanticError_class, "LDKSemanticError_ImpreciseAmount", "Lorg/ldk/enums/SemanticError;");
659         CHECK(SemanticError_LDKSemanticError_ImpreciseAmount != NULL);
660 }
661 static inline jclass LDKSemanticError_to_java(JNIEnv *env, LDKSemanticError val) {
662         switch (val) {
663                 case LDKSemanticError_NoPaymentHash:
664                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentHash);
665                 case LDKSemanticError_MultiplePaymentHashes:
666                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentHashes);
667                 case LDKSemanticError_NoDescription:
668                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoDescription);
669                 case LDKSemanticError_MultipleDescriptions:
670                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultipleDescriptions);
671                 case LDKSemanticError_NoPaymentSecret:
672                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_NoPaymentSecret);
673                 case LDKSemanticError_MultiplePaymentSecrets:
674                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_MultiplePaymentSecrets);
675                 case LDKSemanticError_InvalidFeatures:
676                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidFeatures);
677                 case LDKSemanticError_InvalidRecoveryId:
678                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidRecoveryId);
679                 case LDKSemanticError_InvalidSignature:
680                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_InvalidSignature);
681                 case LDKSemanticError_ImpreciseAmount:
682                         return (*env)->GetStaticObjectField(env, SemanticError_class, SemanticError_LDKSemanticError_ImpreciseAmount);
683                 default: abort();
684         }
685 }
686
687 static inline LDKSiPrefix LDKSiPrefix_from_java(JNIEnv *env, jclass clz) {
688         switch ((*env)->CallIntMethod(env, clz, ordinal_meth)) {
689                 case 0: return LDKSiPrefix_Milli;
690                 case 1: return LDKSiPrefix_Micro;
691                 case 2: return LDKSiPrefix_Nano;
692                 case 3: return LDKSiPrefix_Pico;
693         }
694         abort();
695 }
696 static jclass SiPrefix_class = NULL;
697 static jfieldID SiPrefix_LDKSiPrefix_Milli = NULL;
698 static jfieldID SiPrefix_LDKSiPrefix_Micro = NULL;
699 static jfieldID SiPrefix_LDKSiPrefix_Nano = NULL;
700 static jfieldID SiPrefix_LDKSiPrefix_Pico = NULL;
701 JNIEXPORT void JNICALL Java_org_ldk_enums_SiPrefix_init (JNIEnv *env, jclass clz) {
702         SiPrefix_class = (*env)->NewGlobalRef(env, clz);
703         CHECK(SiPrefix_class != NULL);
704         SiPrefix_LDKSiPrefix_Milli = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Milli", "Lorg/ldk/enums/SiPrefix;");
705         CHECK(SiPrefix_LDKSiPrefix_Milli != NULL);
706         SiPrefix_LDKSiPrefix_Micro = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Micro", "Lorg/ldk/enums/SiPrefix;");
707         CHECK(SiPrefix_LDKSiPrefix_Micro != NULL);
708         SiPrefix_LDKSiPrefix_Nano = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Nano", "Lorg/ldk/enums/SiPrefix;");
709         CHECK(SiPrefix_LDKSiPrefix_Nano != NULL);
710         SiPrefix_LDKSiPrefix_Pico = (*env)->GetStaticFieldID(env, SiPrefix_class, "LDKSiPrefix_Pico", "Lorg/ldk/enums/SiPrefix;");
711         CHECK(SiPrefix_LDKSiPrefix_Pico != NULL);
712 }
713 static inline jclass LDKSiPrefix_to_java(JNIEnv *env, LDKSiPrefix val) {
714         switch (val) {
715                 case LDKSiPrefix_Milli:
716                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Milli);
717                 case LDKSiPrefix_Micro:
718                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Micro);
719                 case LDKSiPrefix_Nano:
720                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Nano);
721                 case LDKSiPrefix_Pico:
722                         return (*env)->GetStaticObjectField(env, SiPrefix_class, SiPrefix_LDKSiPrefix_Pico);
723                 default: abort();
724         }
725 }
726
727 static inline LDKCVec_u8Z CVec_u8Z_clone(const LDKCVec_u8Z *orig) {
728         LDKCVec_u8Z ret = { .data = MALLOC(sizeof(int8_t) * orig->datalen, "LDKCVec_u8Z clone bytes"), .datalen = orig->datalen };
729         memcpy(ret.data, orig->data, sizeof(int8_t) * ret.datalen);
730         return ret;
731 }
732 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) {
733         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
734         LDKCVec_u8Z ret_var = TxOut_get_script_pubkey(thing_conv);
735         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
736         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
737         CVec_u8Z_free(ret_var);
738         return ret_arr;
739 }
740
741 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) {
742         LDKTxOut* thing_conv = (LDKTxOut*)(thing & ~1);
743         int64_t ret_val = TxOut_get_value(thing_conv);
744         return ret_val;
745 }
746
747 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
748         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
749         CHECK(val->result_ok);
750         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
751         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).bytes);
752         return res_arr;
753 }
754 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SecretKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
755         LDKCResult_SecretKeyErrorZ *val = (LDKCResult_SecretKeyErrorZ*)(arg & ~1);
756         CHECK(!val->result_ok);
757         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
758         return err_conv;
759 }
760 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
761         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
762         CHECK(val->result_ok);
763         int8_tArray res_arr = (*env)->NewByteArray(env, 33);
764         (*env)->SetByteArrayRegion(env, res_arr, 0, 33, (*val->contents.result).compressed_form);
765         return res_arr;
766 }
767 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PublicKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
768         LDKCResult_PublicKeyErrorZ *val = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
769         CHECK(!val->result_ok);
770         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
771         return err_conv;
772 }
773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
774         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
775         CHECK(val->result_ok);
776         LDKTxCreationKeys res_var = (*val->contents.result);
777         uint64_t res_ref = 0;
778         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
779         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
780         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
781         res_ref = (uint64_t)res_var.inner & ~1;
782         return res_ref;
783 }
784 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
785         LDKCResult_TxCreationKeysDecodeErrorZ *val = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
786         CHECK(!val->result_ok);
787         LDKDecodeError err_var = (*val->contents.err);
788         uint64_t err_ref = 0;
789         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
790         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
791         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
792         err_ref = (uint64_t)err_var.inner & ~1;
793         return err_ref;
794 }
795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
796         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
797         CHECK(val->result_ok);
798         LDKChannelPublicKeys res_var = (*val->contents.result);
799         uint64_t res_ref = 0;
800         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
801         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
802         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
803         res_ref = (uint64_t)res_var.inner & ~1;
804         return res_ref;
805 }
806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelPublicKeysDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
807         LDKCResult_ChannelPublicKeysDecodeErrorZ *val = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
808         CHECK(!val->result_ok);
809         LDKDecodeError err_var = (*val->contents.err);
810         uint64_t err_ref = 0;
811         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
812         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
813         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
814         err_ref = (uint64_t)err_var.inner & ~1;
815         return err_ref;
816 }
817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
818         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
819         CHECK(val->result_ok);
820         LDKTxCreationKeys res_var = (*val->contents.result);
821         uint64_t res_ref = 0;
822         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
823         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
824         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
825         res_ref = (uint64_t)res_var.inner & ~1;
826         return res_ref;
827 }
828 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxCreationKeysErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
829         LDKCResult_TxCreationKeysErrorZ *val = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
830         CHECK(!val->result_ok);
831         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
832         return err_conv;
833 }
834 static jclass LDKCOption_u32Z_Some_class = NULL;
835 static jmethodID LDKCOption_u32Z_Some_meth = NULL;
836 static jclass LDKCOption_u32Z_None_class = NULL;
837 static jmethodID LDKCOption_u32Z_None_meth = NULL;
838 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u32Z_init (JNIEnv *env, jclass clz) {
839         LDKCOption_u32Z_Some_class =
840                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$Some;"));
841         CHECK(LDKCOption_u32Z_Some_class != NULL);
842         LDKCOption_u32Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_Some_class, "<init>", "(I)V");
843         CHECK(LDKCOption_u32Z_Some_meth != NULL);
844         LDKCOption_u32Z_None_class =
845                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u32Z$None;"));
846         CHECK(LDKCOption_u32Z_None_class != NULL);
847         LDKCOption_u32Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u32Z_None_class, "<init>", "()V");
848         CHECK(LDKCOption_u32Z_None_meth != NULL);
849 }
850 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u32Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
851         LDKCOption_u32Z *obj = (LDKCOption_u32Z*)(ptr & ~1);
852         switch(obj->tag) {
853                 case LDKCOption_u32Z_Some: {
854                         return (*env)->NewObject(env, LDKCOption_u32Z_Some_class, LDKCOption_u32Z_Some_meth, obj->some);
855                 }
856                 case LDKCOption_u32Z_None: {
857                         return (*env)->NewObject(env, LDKCOption_u32Z_None_class, LDKCOption_u32Z_None_meth);
858                 }
859                 default: abort();
860         }
861 }
862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
863         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
864         CHECK(val->result_ok);
865         LDKHTLCOutputInCommitment res_var = (*val->contents.result);
866         uint64_t res_ref = 0;
867         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
868         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
869         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
870         res_ref = (uint64_t)res_var.inner & ~1;
871         return res_ref;
872 }
873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCOutputInCommitmentDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
874         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *val = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
875         CHECK(!val->result_ok);
876         LDKDecodeError err_var = (*val->contents.err);
877         uint64_t err_ref = 0;
878         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
879         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
880         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
881         err_ref = (uint64_t)err_var.inner & ~1;
882         return err_ref;
883 }
884 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
885         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
886         CHECK(val->result_ok);
887         LDKCounterpartyChannelTransactionParameters res_var = (*val->contents.result);
888         uint64_t res_ref = 0;
889         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
890         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
891         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
892         res_ref = (uint64_t)res_var.inner & ~1;
893         return res_ref;
894 }
895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
896         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
897         CHECK(!val->result_ok);
898         LDKDecodeError err_var = (*val->contents.err);
899         uint64_t err_ref = 0;
900         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
901         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
902         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
903         err_ref = (uint64_t)err_var.inner & ~1;
904         return err_ref;
905 }
906 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
907         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
908         CHECK(val->result_ok);
909         LDKChannelTransactionParameters res_var = (*val->contents.result);
910         uint64_t res_ref = 0;
911         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
912         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
913         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
914         res_ref = (uint64_t)res_var.inner & ~1;
915         return res_ref;
916 }
917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelTransactionParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
918         LDKCResult_ChannelTransactionParametersDecodeErrorZ *val = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
919         CHECK(!val->result_ok);
920         LDKDecodeError err_var = (*val->contents.err);
921         uint64_t err_ref = 0;
922         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
923         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
924         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
925         err_ref = (uint64_t)err_var.inner & ~1;
926         return err_ref;
927 }
928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
929         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
930         CHECK(val->result_ok);
931         LDKHolderCommitmentTransaction res_var = (*val->contents.result);
932         uint64_t res_ref = 0;
933         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
934         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
935         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
936         res_ref = (uint64_t)res_var.inner & ~1;
937         return res_ref;
938 }
939 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HolderCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
940         LDKCResult_HolderCommitmentTransactionDecodeErrorZ *val = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
941         CHECK(!val->result_ok);
942         LDKDecodeError err_var = (*val->contents.err);
943         uint64_t err_ref = 0;
944         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
945         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
946         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
947         err_ref = (uint64_t)err_var.inner & ~1;
948         return err_ref;
949 }
950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
951         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
952         CHECK(val->result_ok);
953         LDKBuiltCommitmentTransaction res_var = (*val->contents.result);
954         uint64_t res_ref = 0;
955         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
956         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
957         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
958         res_ref = (uint64_t)res_var.inner & ~1;
959         return res_ref;
960 }
961 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1BuiltCommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
962         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *val = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
963         CHECK(!val->result_ok);
964         LDKDecodeError err_var = (*val->contents.err);
965         uint64_t err_ref = 0;
966         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
967         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
968         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
969         err_ref = (uint64_t)err_var.inner & ~1;
970         return err_ref;
971 }
972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
973         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
974         CHECK(val->result_ok);
975         LDKTrustedClosingTransaction res_var = (*val->contents.result);
976         uint64_t res_ref = 0;
977         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
978         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
979         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
980         res_ref = (uint64_t)res_var.inner & ~1;
981         return res_ref;
982 }
983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedClosingTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
984         LDKCResult_TrustedClosingTransactionNoneZ *val = (LDKCResult_TrustedClosingTransactionNoneZ*)(arg & ~1);
985         CHECK(!val->result_ok);
986         return *val->contents.err;
987 }
988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
989         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
990         CHECK(val->result_ok);
991         LDKCommitmentTransaction res_var = (*val->contents.result);
992         uint64_t res_ref = 0;
993         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
994         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
995         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
996         res_ref = (uint64_t)res_var.inner & ~1;
997         return res_ref;
998 }
999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentTransactionDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1000         LDKCResult_CommitmentTransactionDecodeErrorZ *val = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
1001         CHECK(!val->result_ok);
1002         LDKDecodeError err_var = (*val->contents.err);
1003         uint64_t err_ref = 0;
1004         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1005         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1006         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1007         err_ref = (uint64_t)err_var.inner & ~1;
1008         return err_ref;
1009 }
1010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1011         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1012         CHECK(val->result_ok);
1013         LDKTrustedCommitmentTransaction res_var = (*val->contents.result);
1014         uint64_t res_ref = 0;
1015         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1016         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1017         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1018         res_ref = (uint64_t)res_var.inner & ~1;
1019         return res_ref;
1020 }
1021 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TrustedCommitmentTransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1022         LDKCResult_TrustedCommitmentTransactionNoneZ *val = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(arg & ~1);
1023         CHECK(!val->result_ok);
1024         return *val->contents.err;
1025 }
1026 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1027         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1028         CHECK(val->result_ok);
1029         LDKCVec_SignatureZ res_var = (*val->contents.result);
1030         jobjectArray res_arr = NULL;
1031         res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
1032         ;
1033         for (size_t i = 0; i < res_var.datalen; i++) {
1034                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, 64);
1035                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, 64, res_var.data[i].compact_form);
1036                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
1037         }
1038         
1039         return res_arr;
1040 }
1041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1SignatureZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1042         LDKCResult_CVec_SignatureZNoneZ *val = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
1043         CHECK(!val->result_ok);
1044         return *val->contents.err;
1045 }
1046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1047         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1048         CHECK(val->result_ok);
1049         LDKShutdownScript res_var = (*val->contents.result);
1050         uint64_t res_ref = 0;
1051         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1052         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1053         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1054         res_ref = (uint64_t)res_var.inner & ~1;
1055         return res_ref;
1056 }
1057 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1058         LDKCResult_ShutdownScriptDecodeErrorZ *val = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
1059         CHECK(!val->result_ok);
1060         LDKDecodeError err_var = (*val->contents.err);
1061         uint64_t err_ref = 0;
1062         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1063         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1064         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1065         err_ref = (uint64_t)err_var.inner & ~1;
1066         return err_ref;
1067 }
1068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1069         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1070         CHECK(val->result_ok);
1071         LDKShutdownScript res_var = (*val->contents.result);
1072         uint64_t res_ref = 0;
1073         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1074         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1075         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1076         res_ref = (uint64_t)res_var.inner & ~1;
1077         return res_ref;
1078 }
1079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownScriptInvalidShutdownScriptZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1080         LDKCResult_ShutdownScriptInvalidShutdownScriptZ *val = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
1081         CHECK(!val->result_ok);
1082         LDKInvalidShutdownScript err_var = (*val->contents.err);
1083         uint64_t err_ref = 0;
1084         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1085         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1086         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1087         err_ref = (uint64_t)err_var.inner & ~1;
1088         return err_ref;
1089 }
1090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1091         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1092         CHECK(val->result_ok);
1093         return *val->contents.result;
1094 }
1095 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1096         LDKCResult_NoneErrorZ *val = (LDKCResult_NoneErrorZ*)(arg & ~1);
1097         CHECK(!val->result_ok);
1098         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
1099         return err_conv;
1100 }
1101 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1102         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1103         CHECK(val->result_ok);
1104         LDKRouteHop res_var = (*val->contents.result);
1105         uint64_t res_ref = 0;
1106         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1107         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1108         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1109         res_ref = (uint64_t)res_var.inner & ~1;
1110         return res_ref;
1111 }
1112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1113         LDKCResult_RouteHopDecodeErrorZ *val = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
1114         CHECK(!val->result_ok);
1115         LDKDecodeError err_var = (*val->contents.err);
1116         uint64_t err_ref = 0;
1117         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1118         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1119         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1120         err_ref = (uint64_t)err_var.inner & ~1;
1121         return err_ref;
1122 }
1123 static inline LDKCVec_RouteHopZ CVec_RouteHopZ_clone(const LDKCVec_RouteHopZ *orig) {
1124         LDKCVec_RouteHopZ ret = { .data = MALLOC(sizeof(LDKRouteHop) * orig->datalen, "LDKCVec_RouteHopZ clone bytes"), .datalen = orig->datalen };
1125         for (size_t i = 0; i < ret.datalen; i++) {
1126                 ret.data[i] = RouteHop_clone(&orig->data[i]);
1127         }
1128         return ret;
1129 }
1130 static inline LDKCVec_CVec_RouteHopZZ CVec_CVec_RouteHopZZ_clone(const LDKCVec_CVec_RouteHopZZ *orig) {
1131         LDKCVec_CVec_RouteHopZZ ret = { .data = MALLOC(sizeof(LDKCVec_RouteHopZ) * orig->datalen, "LDKCVec_CVec_RouteHopZZ clone bytes"), .datalen = orig->datalen };
1132         for (size_t i = 0; i < ret.datalen; i++) {
1133                 ret.data[i] = CVec_RouteHopZ_clone(&orig->data[i]);
1134         }
1135         return ret;
1136 }
1137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1138         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1139         CHECK(val->result_ok);
1140         LDKRoute res_var = (*val->contents.result);
1141         uint64_t res_ref = 0;
1142         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1143         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1144         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1145         res_ref = (uint64_t)res_var.inner & ~1;
1146         return res_ref;
1147 }
1148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1149         LDKCResult_RouteDecodeErrorZ *val = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
1150         CHECK(!val->result_ok);
1151         LDKDecodeError err_var = (*val->contents.err);
1152         uint64_t err_ref = 0;
1153         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1154         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1155         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1156         err_ref = (uint64_t)err_var.inner & ~1;
1157         return err_ref;
1158 }
1159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1160         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
1161         CHECK(val->result_ok);
1162         LDKRouteParameters res_var = (*val->contents.result);
1163         uint64_t res_ref = 0;
1164         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1165         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1166         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1167         res_ref = (uint64_t)res_var.inner & ~1;
1168         return res_ref;
1169 }
1170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1171         LDKCResult_RouteParametersDecodeErrorZ *val = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
1172         CHECK(!val->result_ok);
1173         LDKDecodeError err_var = (*val->contents.err);
1174         uint64_t err_ref = 0;
1175         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1176         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1177         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1178         err_ref = (uint64_t)err_var.inner & ~1;
1179         return err_ref;
1180 }
1181 static inline LDKCVec_RouteHintZ CVec_RouteHintZ_clone(const LDKCVec_RouteHintZ *orig) {
1182         LDKCVec_RouteHintZ ret = { .data = MALLOC(sizeof(LDKRouteHint) * orig->datalen, "LDKCVec_RouteHintZ clone bytes"), .datalen = orig->datalen };
1183         for (size_t i = 0; i < ret.datalen; i++) {
1184                 ret.data[i] = RouteHint_clone(&orig->data[i]);
1185         }
1186         return ret;
1187 }
1188 static jclass LDKCOption_u64Z_Some_class = NULL;
1189 static jmethodID LDKCOption_u64Z_Some_meth = NULL;
1190 static jclass LDKCOption_u64Z_None_class = NULL;
1191 static jmethodID LDKCOption_u64Z_None_meth = NULL;
1192 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u64Z_init (JNIEnv *env, jclass clz) {
1193         LDKCOption_u64Z_Some_class =
1194                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$Some;"));
1195         CHECK(LDKCOption_u64Z_Some_class != NULL);
1196         LDKCOption_u64Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_Some_class, "<init>", "(J)V");
1197         CHECK(LDKCOption_u64Z_Some_meth != NULL);
1198         LDKCOption_u64Z_None_class =
1199                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u64Z$None;"));
1200         CHECK(LDKCOption_u64Z_None_class != NULL);
1201         LDKCOption_u64Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u64Z_None_class, "<init>", "()V");
1202         CHECK(LDKCOption_u64Z_None_meth != NULL);
1203 }
1204 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u64Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1205         LDKCOption_u64Z *obj = (LDKCOption_u64Z*)(ptr & ~1);
1206         switch(obj->tag) {
1207                 case LDKCOption_u64Z_Some: {
1208                         return (*env)->NewObject(env, LDKCOption_u64Z_Some_class, LDKCOption_u64Z_Some_meth, obj->some);
1209                 }
1210                 case LDKCOption_u64Z_None: {
1211                         return (*env)->NewObject(env, LDKCOption_u64Z_None_class, LDKCOption_u64Z_None_meth);
1212                 }
1213                 default: abort();
1214         }
1215 }
1216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1217         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
1218         CHECK(val->result_ok);
1219         LDKPayee res_var = (*val->contents.result);
1220         uint64_t res_ref = 0;
1221         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1222         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1223         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1224         res_ref = (uint64_t)res_var.inner & ~1;
1225         return res_ref;
1226 }
1227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1228         LDKCResult_PayeeDecodeErrorZ *val = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
1229         CHECK(!val->result_ok);
1230         LDKDecodeError err_var = (*val->contents.err);
1231         uint64_t err_ref = 0;
1232         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1233         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1234         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1235         err_ref = (uint64_t)err_var.inner & ~1;
1236         return err_ref;
1237 }
1238 static inline LDKCVec_RouteHintHopZ CVec_RouteHintHopZ_clone(const LDKCVec_RouteHintHopZ *orig) {
1239         LDKCVec_RouteHintHopZ ret = { .data = MALLOC(sizeof(LDKRouteHintHop) * orig->datalen, "LDKCVec_RouteHintHopZ clone bytes"), .datalen = orig->datalen };
1240         for (size_t i = 0; i < ret.datalen; i++) {
1241                 ret.data[i] = RouteHintHop_clone(&orig->data[i]);
1242         }
1243         return ret;
1244 }
1245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1246         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
1247         CHECK(val->result_ok);
1248         LDKRouteHint res_var = (*val->contents.result);
1249         uint64_t res_ref = 0;
1250         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1251         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1252         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1253         res_ref = (uint64_t)res_var.inner & ~1;
1254         return res_ref;
1255 }
1256 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1257         LDKCResult_RouteHintDecodeErrorZ *val = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
1258         CHECK(!val->result_ok);
1259         LDKDecodeError err_var = (*val->contents.err);
1260         uint64_t err_ref = 0;
1261         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1262         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1263         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1264         err_ref = (uint64_t)err_var.inner & ~1;
1265         return err_ref;
1266 }
1267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1268         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
1269         CHECK(val->result_ok);
1270         LDKRouteHintHop res_var = (*val->contents.result);
1271         uint64_t res_ref = 0;
1272         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1273         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1274         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1275         res_ref = (uint64_t)res_var.inner & ~1;
1276         return res_ref;
1277 }
1278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteHintHopDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1279         LDKCResult_RouteHintHopDecodeErrorZ *val = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
1280         CHECK(!val->result_ok);
1281         LDKDecodeError err_var = (*val->contents.err);
1282         uint64_t err_ref = 0;
1283         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1284         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1285         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1286         err_ref = (uint64_t)err_var.inner & ~1;
1287         return err_ref;
1288 }
1289 static inline LDKCVec_ChannelDetailsZ CVec_ChannelDetailsZ_clone(const LDKCVec_ChannelDetailsZ *orig) {
1290         LDKCVec_ChannelDetailsZ ret = { .data = MALLOC(sizeof(LDKChannelDetails) * orig->datalen, "LDKCVec_ChannelDetailsZ clone bytes"), .datalen = orig->datalen };
1291         for (size_t i = 0; i < ret.datalen; i++) {
1292                 ret.data[i] = ChannelDetails_clone(&orig->data[i]);
1293         }
1294         return ret;
1295 }
1296 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1297         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1298         CHECK(val->result_ok);
1299         LDKRoute res_var = (*val->contents.result);
1300         uint64_t res_ref = 0;
1301         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1302         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1303         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
1304         res_ref = (uint64_t)res_var.inner & ~1;
1305         return res_ref;
1306 }
1307 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RouteLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1308         LDKCResult_RouteLightningErrorZ *val = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
1309         CHECK(!val->result_ok);
1310         LDKLightningError err_var = (*val->contents.err);
1311         uint64_t err_ref = 0;
1312         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1313         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1314         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1315         err_ref = (uint64_t)err_var.inner & ~1;
1316         return err_ref;
1317 }
1318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1319         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1320         CHECK(val->result_ok);
1321         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1322         return (uint64_t)res_ref;
1323 }
1324 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TxOutAccessErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1325         LDKCResult_TxOutAccessErrorZ *val = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
1326         CHECK(!val->result_ok);
1327         jclass err_conv = LDKAccessError_to_java(env, (*val->contents.err));
1328         return err_conv;
1329 }
1330 static inline uintptr_t C2Tuple_usizeTransactionZ_get_a(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1331         return tuple->a;
1332 }
1333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
1334         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1335         int64_t ret_val = C2Tuple_usizeTransactionZ_get_a(tuple_conv);
1336         return ret_val;
1337 }
1338
1339 static inline struct LDKTransaction C2Tuple_usizeTransactionZ_get_b(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR tuple){
1340         return tuple->b;
1341 }
1342 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
1343         LDKC2Tuple_usizeTransactionZ* tuple_conv = (LDKC2Tuple_usizeTransactionZ*)(tuple & ~1);
1344         LDKTransaction ret_var = C2Tuple_usizeTransactionZ_get_b(tuple_conv);
1345         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
1346         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
1347         Transaction_free(ret_var);
1348         return ret_arr;
1349 }
1350
1351 static inline LDKCVec_C2Tuple_usizeTransactionZZ CVec_C2Tuple_usizeTransactionZZ_clone(const LDKCVec_C2Tuple_usizeTransactionZZ *orig) {
1352         LDKCVec_C2Tuple_usizeTransactionZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ) * orig->datalen, "LDKCVec_C2Tuple_usizeTransactionZZ clone bytes"), .datalen = orig->datalen };
1353         for (size_t i = 0; i < ret.datalen; i++) {
1354                 ret.data[i] = C2Tuple_usizeTransactionZ_clone(&orig->data[i]);
1355         }
1356         return ret;
1357 }
1358 static inline LDKCVec_TxidZ CVec_ThirtyTwoBytesZ_clone(const LDKCVec_TxidZ *orig) {
1359         LDKCVec_TxidZ ret = { .data = MALLOC(sizeof(LDKThirtyTwoBytes) * orig->datalen, "LDKCVec_TxidZ clone bytes"), .datalen = orig->datalen };
1360         for (size_t i = 0; i < ret.datalen; i++) {
1361                 ret.data[i] = ThirtyTwoBytes_clone(&orig->data[i]);
1362         }
1363         return ret;
1364 }
1365 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1366         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1367         CHECK(val->result_ok);
1368         return *val->contents.result;
1369 }
1370 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneChannelMonitorUpdateErrZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1371         LDKCResult_NoneChannelMonitorUpdateErrZ *val = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
1372         CHECK(!val->result_ok);
1373         jclass err_conv = LDKChannelMonitorUpdateErr_to_java(env, (*val->contents.err));
1374         return err_conv;
1375 }
1376 static jclass LDKMonitorEvent_HTLCEvent_class = NULL;
1377 static jmethodID LDKMonitorEvent_HTLCEvent_meth = NULL;
1378 static jclass LDKMonitorEvent_CommitmentTxConfirmed_class = NULL;
1379 static jmethodID LDKMonitorEvent_CommitmentTxConfirmed_meth = NULL;
1380 static jclass LDKMonitorEvent_UpdateCompleted_class = NULL;
1381 static jmethodID LDKMonitorEvent_UpdateCompleted_meth = NULL;
1382 static jclass LDKMonitorEvent_UpdateFailed_class = NULL;
1383 static jmethodID LDKMonitorEvent_UpdateFailed_meth = NULL;
1384 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMonitorEvent_init (JNIEnv *env, jclass clz) {
1385         LDKMonitorEvent_HTLCEvent_class =
1386                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$HTLCEvent;"));
1387         CHECK(LDKMonitorEvent_HTLCEvent_class != NULL);
1388         LDKMonitorEvent_HTLCEvent_meth = (*env)->GetMethodID(env, LDKMonitorEvent_HTLCEvent_class, "<init>", "(J)V");
1389         CHECK(LDKMonitorEvent_HTLCEvent_meth != NULL);
1390         LDKMonitorEvent_CommitmentTxConfirmed_class =
1391                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$CommitmentTxConfirmed;"));
1392         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_class != NULL);
1393         LDKMonitorEvent_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_CommitmentTxConfirmed_class, "<init>", "(J)V");
1394         CHECK(LDKMonitorEvent_CommitmentTxConfirmed_meth != NULL);
1395         LDKMonitorEvent_UpdateCompleted_class =
1396                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateCompleted;"));
1397         CHECK(LDKMonitorEvent_UpdateCompleted_class != NULL);
1398         LDKMonitorEvent_UpdateCompleted_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateCompleted_class, "<init>", "(JJ)V");
1399         CHECK(LDKMonitorEvent_UpdateCompleted_meth != NULL);
1400         LDKMonitorEvent_UpdateFailed_class =
1401                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMonitorEvent$UpdateFailed;"));
1402         CHECK(LDKMonitorEvent_UpdateFailed_class != NULL);
1403         LDKMonitorEvent_UpdateFailed_meth = (*env)->GetMethodID(env, LDKMonitorEvent_UpdateFailed_class, "<init>", "(J)V");
1404         CHECK(LDKMonitorEvent_UpdateFailed_meth != NULL);
1405 }
1406 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMonitorEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1407         LDKMonitorEvent *obj = (LDKMonitorEvent*)(ptr & ~1);
1408         switch(obj->tag) {
1409                 case LDKMonitorEvent_HTLCEvent: {
1410                         LDKHTLCUpdate htlc_event_var = obj->htlc_event;
1411                         uint64_t htlc_event_ref = 0;
1412                         CHECK((((uint64_t)htlc_event_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1413                         CHECK((((uint64_t)&htlc_event_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1414                         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_event_var);
1415                         htlc_event_ref = (uint64_t)htlc_event_var.inner & ~1;
1416                         return (*env)->NewObject(env, LDKMonitorEvent_HTLCEvent_class, LDKMonitorEvent_HTLCEvent_meth, htlc_event_ref);
1417                 }
1418                 case LDKMonitorEvent_CommitmentTxConfirmed: {
1419                         LDKOutPoint commitment_tx_confirmed_var = obj->commitment_tx_confirmed;
1420                         uint64_t commitment_tx_confirmed_ref = 0;
1421                         CHECK((((uint64_t)commitment_tx_confirmed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1422                         CHECK((((uint64_t)&commitment_tx_confirmed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1423                         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_confirmed_var);
1424                         commitment_tx_confirmed_ref = (uint64_t)commitment_tx_confirmed_var.inner & ~1;
1425                         return (*env)->NewObject(env, LDKMonitorEvent_CommitmentTxConfirmed_class, LDKMonitorEvent_CommitmentTxConfirmed_meth, commitment_tx_confirmed_ref);
1426                 }
1427                 case LDKMonitorEvent_UpdateCompleted: {
1428                         LDKOutPoint funding_txo_var = obj->update_completed.funding_txo;
1429                         uint64_t funding_txo_ref = 0;
1430                         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1431                         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1432                         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
1433                         funding_txo_ref = (uint64_t)funding_txo_var.inner & ~1;
1434                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateCompleted_class, LDKMonitorEvent_UpdateCompleted_meth, funding_txo_ref, obj->update_completed.monitor_update_id);
1435                 }
1436                 case LDKMonitorEvent_UpdateFailed: {
1437                         LDKOutPoint update_failed_var = obj->update_failed;
1438                         uint64_t update_failed_ref = 0;
1439                         CHECK((((uint64_t)update_failed_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1440                         CHECK((((uint64_t)&update_failed_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1441                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_failed_var);
1442                         update_failed_ref = (uint64_t)update_failed_var.inner & ~1;
1443                         return (*env)->NewObject(env, LDKMonitorEvent_UpdateFailed_class, LDKMonitorEvent_UpdateFailed_meth, update_failed_ref);
1444                 }
1445                 default: abort();
1446         }
1447 }
1448 static inline LDKCVec_MonitorEventZ CVec_MonitorEventZ_clone(const LDKCVec_MonitorEventZ *orig) {
1449         LDKCVec_MonitorEventZ ret = { .data = MALLOC(sizeof(LDKMonitorEvent) * orig->datalen, "LDKCVec_MonitorEventZ clone bytes"), .datalen = orig->datalen };
1450         for (size_t i = 0; i < ret.datalen; i++) {
1451                 ret.data[i] = MonitorEvent_clone(&orig->data[i]);
1452         }
1453         return ret;
1454 }
1455 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_Some_class = NULL;
1456 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = NULL;
1457 static jclass LDKCOption_C2Tuple_usizeTransactionZZ_None_class = NULL;
1458 static jmethodID LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = NULL;
1459 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1C2Tuple_1usizeTransactionZZ_init (JNIEnv *env, jclass clz) {
1460         LDKCOption_C2Tuple_usizeTransactionZZ_Some_class =
1461                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$Some;"));
1462         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_class != NULL);
1463         LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, "<init>", "(J)V");
1464         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth != NULL);
1465         LDKCOption_C2Tuple_usizeTransactionZZ_None_class =
1466                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_C2Tuple_usizeTransactionZZ$None;"));
1467         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_class != NULL);
1468         LDKCOption_C2Tuple_usizeTransactionZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, "<init>", "()V");
1469         CHECK(LDKCOption_C2Tuple_usizeTransactionZZ_None_meth != NULL);
1470 }
1471 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1C2Tuple_1usizeTransactionZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1472         LDKCOption_C2Tuple_usizeTransactionZZ *obj = (LDKCOption_C2Tuple_usizeTransactionZZ*)(ptr & ~1);
1473         switch(obj->tag) {
1474                 case LDKCOption_C2Tuple_usizeTransactionZZ_Some: {
1475                         LDKC2Tuple_usizeTransactionZ* some_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
1476                         *some_conv = obj->some;
1477                         *some_conv = C2Tuple_usizeTransactionZ_clone(some_conv);
1478                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_Some_class, LDKCOption_C2Tuple_usizeTransactionZZ_Some_meth, ((uint64_t)some_conv));
1479                 }
1480                 case LDKCOption_C2Tuple_usizeTransactionZZ_None: {
1481                         return (*env)->NewObject(env, LDKCOption_C2Tuple_usizeTransactionZZ_None_class, LDKCOption_C2Tuple_usizeTransactionZZ_None_meth);
1482                 }
1483                 default: abort();
1484         }
1485 }
1486 static jclass LDKClosureReason_CounterpartyForceClosed_class = NULL;
1487 static jmethodID LDKClosureReason_CounterpartyForceClosed_meth = NULL;
1488 static jclass LDKClosureReason_HolderForceClosed_class = NULL;
1489 static jmethodID LDKClosureReason_HolderForceClosed_meth = NULL;
1490 static jclass LDKClosureReason_CooperativeClosure_class = NULL;
1491 static jmethodID LDKClosureReason_CooperativeClosure_meth = NULL;
1492 static jclass LDKClosureReason_CommitmentTxConfirmed_class = NULL;
1493 static jmethodID LDKClosureReason_CommitmentTxConfirmed_meth = NULL;
1494 static jclass LDKClosureReason_ProcessingError_class = NULL;
1495 static jmethodID LDKClosureReason_ProcessingError_meth = NULL;
1496 static jclass LDKClosureReason_DisconnectedPeer_class = NULL;
1497 static jmethodID LDKClosureReason_DisconnectedPeer_meth = NULL;
1498 static jclass LDKClosureReason_OutdatedChannelManager_class = NULL;
1499 static jmethodID LDKClosureReason_OutdatedChannelManager_meth = NULL;
1500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKClosureReason_init (JNIEnv *env, jclass clz) {
1501         LDKClosureReason_CounterpartyForceClosed_class =
1502                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CounterpartyForceClosed;"));
1503         CHECK(LDKClosureReason_CounterpartyForceClosed_class != NULL);
1504         LDKClosureReason_CounterpartyForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_CounterpartyForceClosed_class, "<init>", "(Ljava/lang/String;)V");
1505         CHECK(LDKClosureReason_CounterpartyForceClosed_meth != NULL);
1506         LDKClosureReason_HolderForceClosed_class =
1507                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$HolderForceClosed;"));
1508         CHECK(LDKClosureReason_HolderForceClosed_class != NULL);
1509         LDKClosureReason_HolderForceClosed_meth = (*env)->GetMethodID(env, LDKClosureReason_HolderForceClosed_class, "<init>", "()V");
1510         CHECK(LDKClosureReason_HolderForceClosed_meth != NULL);
1511         LDKClosureReason_CooperativeClosure_class =
1512                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CooperativeClosure;"));
1513         CHECK(LDKClosureReason_CooperativeClosure_class != NULL);
1514         LDKClosureReason_CooperativeClosure_meth = (*env)->GetMethodID(env, LDKClosureReason_CooperativeClosure_class, "<init>", "()V");
1515         CHECK(LDKClosureReason_CooperativeClosure_meth != NULL);
1516         LDKClosureReason_CommitmentTxConfirmed_class =
1517                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$CommitmentTxConfirmed;"));
1518         CHECK(LDKClosureReason_CommitmentTxConfirmed_class != NULL);
1519         LDKClosureReason_CommitmentTxConfirmed_meth = (*env)->GetMethodID(env, LDKClosureReason_CommitmentTxConfirmed_class, "<init>", "()V");
1520         CHECK(LDKClosureReason_CommitmentTxConfirmed_meth != NULL);
1521         LDKClosureReason_ProcessingError_class =
1522                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$ProcessingError;"));
1523         CHECK(LDKClosureReason_ProcessingError_class != NULL);
1524         LDKClosureReason_ProcessingError_meth = (*env)->GetMethodID(env, LDKClosureReason_ProcessingError_class, "<init>", "(Ljava/lang/String;)V");
1525         CHECK(LDKClosureReason_ProcessingError_meth != NULL);
1526         LDKClosureReason_DisconnectedPeer_class =
1527                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$DisconnectedPeer;"));
1528         CHECK(LDKClosureReason_DisconnectedPeer_class != NULL);
1529         LDKClosureReason_DisconnectedPeer_meth = (*env)->GetMethodID(env, LDKClosureReason_DisconnectedPeer_class, "<init>", "()V");
1530         CHECK(LDKClosureReason_DisconnectedPeer_meth != NULL);
1531         LDKClosureReason_OutdatedChannelManager_class =
1532                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKClosureReason$OutdatedChannelManager;"));
1533         CHECK(LDKClosureReason_OutdatedChannelManager_class != NULL);
1534         LDKClosureReason_OutdatedChannelManager_meth = (*env)->GetMethodID(env, LDKClosureReason_OutdatedChannelManager_class, "<init>", "()V");
1535         CHECK(LDKClosureReason_OutdatedChannelManager_meth != NULL);
1536 }
1537 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKClosureReason_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1538         LDKClosureReason *obj = (LDKClosureReason*)(ptr & ~1);
1539         switch(obj->tag) {
1540                 case LDKClosureReason_CounterpartyForceClosed: {
1541                         LDKStr peer_msg_str = obj->counterparty_force_closed.peer_msg;
1542                         jstring peer_msg_conv = str_ref_to_java(env, peer_msg_str.chars, peer_msg_str.len);
1543                         return (*env)->NewObject(env, LDKClosureReason_CounterpartyForceClosed_class, LDKClosureReason_CounterpartyForceClosed_meth, peer_msg_conv);
1544                 }
1545                 case LDKClosureReason_HolderForceClosed: {
1546                         return (*env)->NewObject(env, LDKClosureReason_HolderForceClosed_class, LDKClosureReason_HolderForceClosed_meth);
1547                 }
1548                 case LDKClosureReason_CooperativeClosure: {
1549                         return (*env)->NewObject(env, LDKClosureReason_CooperativeClosure_class, LDKClosureReason_CooperativeClosure_meth);
1550                 }
1551                 case LDKClosureReason_CommitmentTxConfirmed: {
1552                         return (*env)->NewObject(env, LDKClosureReason_CommitmentTxConfirmed_class, LDKClosureReason_CommitmentTxConfirmed_meth);
1553                 }
1554                 case LDKClosureReason_ProcessingError: {
1555                         LDKStr err_str = obj->processing_error.err;
1556                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
1557                         return (*env)->NewObject(env, LDKClosureReason_ProcessingError_class, LDKClosureReason_ProcessingError_meth, err_conv);
1558                 }
1559                 case LDKClosureReason_DisconnectedPeer: {
1560                         return (*env)->NewObject(env, LDKClosureReason_DisconnectedPeer_class, LDKClosureReason_DisconnectedPeer_meth);
1561                 }
1562                 case LDKClosureReason_OutdatedChannelManager: {
1563                         return (*env)->NewObject(env, LDKClosureReason_OutdatedChannelManager_class, LDKClosureReason_OutdatedChannelManager_meth);
1564                 }
1565                 default: abort();
1566         }
1567 }
1568 static jclass LDKCOption_ClosureReasonZ_Some_class = NULL;
1569 static jmethodID LDKCOption_ClosureReasonZ_Some_meth = NULL;
1570 static jclass LDKCOption_ClosureReasonZ_None_class = NULL;
1571 static jmethodID LDKCOption_ClosureReasonZ_None_meth = NULL;
1572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1ClosureReasonZ_init (JNIEnv *env, jclass clz) {
1573         LDKCOption_ClosureReasonZ_Some_class =
1574                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_ClosureReasonZ$Some;"));
1575         CHECK(LDKCOption_ClosureReasonZ_Some_class != NULL);
1576         LDKCOption_ClosureReasonZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_Some_class, "<init>", "(J)V");
1577         CHECK(LDKCOption_ClosureReasonZ_Some_meth != NULL);
1578         LDKCOption_ClosureReasonZ_None_class =
1579                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_ClosureReasonZ$None;"));
1580         CHECK(LDKCOption_ClosureReasonZ_None_class != NULL);
1581         LDKCOption_ClosureReasonZ_None_meth = (*env)->GetMethodID(env, LDKCOption_ClosureReasonZ_None_class, "<init>", "()V");
1582         CHECK(LDKCOption_ClosureReasonZ_None_meth != NULL);
1583 }
1584 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1ClosureReasonZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1585         LDKCOption_ClosureReasonZ *obj = (LDKCOption_ClosureReasonZ*)(ptr & ~1);
1586         switch(obj->tag) {
1587                 case LDKCOption_ClosureReasonZ_Some: {
1588                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1589                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_Some_class, LDKCOption_ClosureReasonZ_Some_meth, some_ref);
1590                 }
1591                 case LDKCOption_ClosureReasonZ_None: {
1592                         return (*env)->NewObject(env, LDKCOption_ClosureReasonZ_None_class, LDKCOption_ClosureReasonZ_None_meth);
1593                 }
1594                 default: abort();
1595         }
1596 }
1597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1598         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1599         CHECK(val->result_ok);
1600         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1601         return res_ref;
1602 }
1603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1ClosureReasonZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1604         LDKCResult_COption_ClosureReasonZDecodeErrorZ *val = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
1605         CHECK(!val->result_ok);
1606         LDKDecodeError err_var = (*val->contents.err);
1607         uint64_t err_ref = 0;
1608         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1609         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1610         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1611         err_ref = (uint64_t)err_var.inner & ~1;
1612         return err_ref;
1613 }
1614 static jclass LDKNetworkUpdate_ChannelUpdateMessage_class = NULL;
1615 static jmethodID LDKNetworkUpdate_ChannelUpdateMessage_meth = NULL;
1616 static jclass LDKNetworkUpdate_ChannelClosed_class = NULL;
1617 static jmethodID LDKNetworkUpdate_ChannelClosed_meth = NULL;
1618 static jclass LDKNetworkUpdate_NodeFailure_class = NULL;
1619 static jmethodID LDKNetworkUpdate_NodeFailure_meth = NULL;
1620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetworkUpdate_init (JNIEnv *env, jclass clz) {
1621         LDKNetworkUpdate_ChannelUpdateMessage_class =
1622                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelUpdateMessage;"));
1623         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_class != NULL);
1624         LDKNetworkUpdate_ChannelUpdateMessage_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelUpdateMessage_class, "<init>", "(J)V");
1625         CHECK(LDKNetworkUpdate_ChannelUpdateMessage_meth != NULL);
1626         LDKNetworkUpdate_ChannelClosed_class =
1627                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$ChannelClosed;"));
1628         CHECK(LDKNetworkUpdate_ChannelClosed_class != NULL);
1629         LDKNetworkUpdate_ChannelClosed_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_ChannelClosed_class, "<init>", "(JZ)V");
1630         CHECK(LDKNetworkUpdate_ChannelClosed_meth != NULL);
1631         LDKNetworkUpdate_NodeFailure_class =
1632                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetworkUpdate$NodeFailure;"));
1633         CHECK(LDKNetworkUpdate_NodeFailure_class != NULL);
1634         LDKNetworkUpdate_NodeFailure_meth = (*env)->GetMethodID(env, LDKNetworkUpdate_NodeFailure_class, "<init>", "([BZ)V");
1635         CHECK(LDKNetworkUpdate_NodeFailure_meth != NULL);
1636 }
1637 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetworkUpdate_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1638         LDKNetworkUpdate *obj = (LDKNetworkUpdate*)(ptr & ~1);
1639         switch(obj->tag) {
1640                 case LDKNetworkUpdate_ChannelUpdateMessage: {
1641                         LDKChannelUpdate msg_var = obj->channel_update_message.msg;
1642                         uint64_t msg_ref = 0;
1643                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1644                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1645                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
1646                         msg_ref = (uint64_t)msg_var.inner & ~1;
1647                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelUpdateMessage_class, LDKNetworkUpdate_ChannelUpdateMessage_meth, msg_ref);
1648                 }
1649                 case LDKNetworkUpdate_ChannelClosed: {
1650                         return (*env)->NewObject(env, LDKNetworkUpdate_ChannelClosed_class, LDKNetworkUpdate_ChannelClosed_meth, obj->channel_closed.short_channel_id, obj->channel_closed.is_permanent);
1651                 }
1652                 case LDKNetworkUpdate_NodeFailure: {
1653                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
1654                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->node_failure.node_id.compressed_form);
1655                         return (*env)->NewObject(env, LDKNetworkUpdate_NodeFailure_class, LDKNetworkUpdate_NodeFailure_meth, node_id_arr, obj->node_failure.is_permanent);
1656                 }
1657                 default: abort();
1658         }
1659 }
1660 static jclass LDKCOption_NetworkUpdateZ_Some_class = NULL;
1661 static jmethodID LDKCOption_NetworkUpdateZ_Some_meth = NULL;
1662 static jclass LDKCOption_NetworkUpdateZ_None_class = NULL;
1663 static jmethodID LDKCOption_NetworkUpdateZ_None_meth = NULL;
1664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1NetworkUpdateZ_init (JNIEnv *env, jclass clz) {
1665         LDKCOption_NetworkUpdateZ_Some_class =
1666                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$Some;"));
1667         CHECK(LDKCOption_NetworkUpdateZ_Some_class != NULL);
1668         LDKCOption_NetworkUpdateZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_Some_class, "<init>", "(J)V");
1669         CHECK(LDKCOption_NetworkUpdateZ_Some_meth != NULL);
1670         LDKCOption_NetworkUpdateZ_None_class =
1671                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_NetworkUpdateZ$None;"));
1672         CHECK(LDKCOption_NetworkUpdateZ_None_class != NULL);
1673         LDKCOption_NetworkUpdateZ_None_meth = (*env)->GetMethodID(env, LDKCOption_NetworkUpdateZ_None_class, "<init>", "()V");
1674         CHECK(LDKCOption_NetworkUpdateZ_None_meth != NULL);
1675 }
1676 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1NetworkUpdateZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1677         LDKCOption_NetworkUpdateZ *obj = (LDKCOption_NetworkUpdateZ*)(ptr & ~1);
1678         switch(obj->tag) {
1679                 case LDKCOption_NetworkUpdateZ_Some: {
1680                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1681                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_Some_class, LDKCOption_NetworkUpdateZ_Some_meth, some_ref);
1682                 }
1683                 case LDKCOption_NetworkUpdateZ_None: {
1684                         return (*env)->NewObject(env, LDKCOption_NetworkUpdateZ_None_class, LDKCOption_NetworkUpdateZ_None_meth);
1685                 }
1686                 default: abort();
1687         }
1688 }
1689 static jclass LDKSpendableOutputDescriptor_StaticOutput_class = NULL;
1690 static jmethodID LDKSpendableOutputDescriptor_StaticOutput_meth = NULL;
1691 static jclass LDKSpendableOutputDescriptor_DelayedPaymentOutput_class = NULL;
1692 static jmethodID LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = NULL;
1693 static jclass LDKSpendableOutputDescriptor_StaticPaymentOutput_class = NULL;
1694 static jmethodID LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = NULL;
1695 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSpendableOutputDescriptor_init (JNIEnv *env, jclass clz) {
1696         LDKSpendableOutputDescriptor_StaticOutput_class =
1697                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticOutput;"));
1698         CHECK(LDKSpendableOutputDescriptor_StaticOutput_class != NULL);
1699         LDKSpendableOutputDescriptor_StaticOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticOutput_class, "<init>", "(JJ)V");
1700         CHECK(LDKSpendableOutputDescriptor_StaticOutput_meth != NULL);
1701         LDKSpendableOutputDescriptor_DelayedPaymentOutput_class =
1702                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$DelayedPaymentOutput;"));
1703         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_class != NULL);
1704         LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, "<init>", "(J)V");
1705         CHECK(LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth != NULL);
1706         LDKSpendableOutputDescriptor_StaticPaymentOutput_class =
1707                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSpendableOutputDescriptor$StaticPaymentOutput;"));
1708         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_class != NULL);
1709         LDKSpendableOutputDescriptor_StaticPaymentOutput_meth = (*env)->GetMethodID(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, "<init>", "(J)V");
1710         CHECK(LDKSpendableOutputDescriptor_StaticPaymentOutput_meth != NULL);
1711 }
1712 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSpendableOutputDescriptor_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1713         LDKSpendableOutputDescriptor *obj = (LDKSpendableOutputDescriptor*)(ptr & ~1);
1714         switch(obj->tag) {
1715                 case LDKSpendableOutputDescriptor_StaticOutput: {
1716                         LDKOutPoint outpoint_var = obj->static_output.outpoint;
1717                         uint64_t outpoint_ref = 0;
1718                         CHECK((((uint64_t)outpoint_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1719                         CHECK((((uint64_t)&outpoint_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1720                         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_var);
1721                         outpoint_ref = (uint64_t)outpoint_var.inner & ~1;
1722                         uint64_t output_ref = ((uint64_t)&obj->static_output.output) | 1;
1723                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticOutput_class, LDKSpendableOutputDescriptor_StaticOutput_meth, outpoint_ref, (uint64_t)output_ref);
1724                 }
1725                 case LDKSpendableOutputDescriptor_DelayedPaymentOutput: {
1726                         LDKDelayedPaymentOutputDescriptor delayed_payment_output_var = obj->delayed_payment_output;
1727                         uint64_t delayed_payment_output_ref = 0;
1728                         CHECK((((uint64_t)delayed_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1729                         CHECK((((uint64_t)&delayed_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1730                         CHECK_INNER_FIELD_ACCESS_OR_NULL(delayed_payment_output_var);
1731                         delayed_payment_output_ref = (uint64_t)delayed_payment_output_var.inner & ~1;
1732                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_DelayedPaymentOutput_class, LDKSpendableOutputDescriptor_DelayedPaymentOutput_meth, delayed_payment_output_ref);
1733                 }
1734                 case LDKSpendableOutputDescriptor_StaticPaymentOutput: {
1735                         LDKStaticPaymentOutputDescriptor static_payment_output_var = obj->static_payment_output;
1736                         uint64_t static_payment_output_ref = 0;
1737                         CHECK((((uint64_t)static_payment_output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1738                         CHECK((((uint64_t)&static_payment_output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1739                         CHECK_INNER_FIELD_ACCESS_OR_NULL(static_payment_output_var);
1740                         static_payment_output_ref = (uint64_t)static_payment_output_var.inner & ~1;
1741                         return (*env)->NewObject(env, LDKSpendableOutputDescriptor_StaticPaymentOutput_class, LDKSpendableOutputDescriptor_StaticPaymentOutput_meth, static_payment_output_ref);
1742                 }
1743                 default: abort();
1744         }
1745 }
1746 static inline LDKCVec_SpendableOutputDescriptorZ CVec_SpendableOutputDescriptorZ_clone(const LDKCVec_SpendableOutputDescriptorZ *orig) {
1747         LDKCVec_SpendableOutputDescriptorZ ret = { .data = MALLOC(sizeof(LDKSpendableOutputDescriptor) * orig->datalen, "LDKCVec_SpendableOutputDescriptorZ clone bytes"), .datalen = orig->datalen };
1748         for (size_t i = 0; i < ret.datalen; i++) {
1749                 ret.data[i] = SpendableOutputDescriptor_clone(&orig->data[i]);
1750         }
1751         return ret;
1752 }
1753 static jclass LDKPaymentPurpose_InvoicePayment_class = NULL;
1754 static jmethodID LDKPaymentPurpose_InvoicePayment_meth = NULL;
1755 static jclass LDKPaymentPurpose_SpontaneousPayment_class = NULL;
1756 static jmethodID LDKPaymentPurpose_SpontaneousPayment_meth = NULL;
1757 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentPurpose_init (JNIEnv *env, jclass clz) {
1758         LDKPaymentPurpose_InvoicePayment_class =
1759                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$InvoicePayment;"));
1760         CHECK(LDKPaymentPurpose_InvoicePayment_class != NULL);
1761         LDKPaymentPurpose_InvoicePayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_InvoicePayment_class, "<init>", "([B[BJ)V");
1762         CHECK(LDKPaymentPurpose_InvoicePayment_meth != NULL);
1763         LDKPaymentPurpose_SpontaneousPayment_class =
1764                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentPurpose$SpontaneousPayment;"));
1765         CHECK(LDKPaymentPurpose_SpontaneousPayment_class != NULL);
1766         LDKPaymentPurpose_SpontaneousPayment_meth = (*env)->GetMethodID(env, LDKPaymentPurpose_SpontaneousPayment_class, "<init>", "([B)V");
1767         CHECK(LDKPaymentPurpose_SpontaneousPayment_meth != NULL);
1768 }
1769 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentPurpose_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1770         LDKPaymentPurpose *obj = (LDKPaymentPurpose*)(ptr & ~1);
1771         switch(obj->tag) {
1772                 case LDKPaymentPurpose_InvoicePayment: {
1773                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1774                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->invoice_payment.payment_preimage.data);
1775                         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
1776                         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, obj->invoice_payment.payment_secret.data);
1777                         return (*env)->NewObject(env, LDKPaymentPurpose_InvoicePayment_class, LDKPaymentPurpose_InvoicePayment_meth, payment_preimage_arr, payment_secret_arr, obj->invoice_payment.user_payment_id);
1778                 }
1779                 case LDKPaymentPurpose_SpontaneousPayment: {
1780                         int8_tArray spontaneous_payment_arr = (*env)->NewByteArray(env, 32);
1781                         (*env)->SetByteArrayRegion(env, spontaneous_payment_arr, 0, 32, obj->spontaneous_payment.data);
1782                         return (*env)->NewObject(env, LDKPaymentPurpose_SpontaneousPayment_class, LDKPaymentPurpose_SpontaneousPayment_meth, spontaneous_payment_arr);
1783                 }
1784                 default: abort();
1785         }
1786 }
1787 static jclass LDKEvent_FundingGenerationReady_class = NULL;
1788 static jmethodID LDKEvent_FundingGenerationReady_meth = NULL;
1789 static jclass LDKEvent_PaymentReceived_class = NULL;
1790 static jmethodID LDKEvent_PaymentReceived_meth = NULL;
1791 static jclass LDKEvent_PaymentSent_class = NULL;
1792 static jmethodID LDKEvent_PaymentSent_meth = NULL;
1793 static jclass LDKEvent_PaymentPathFailed_class = NULL;
1794 static jmethodID LDKEvent_PaymentPathFailed_meth = NULL;
1795 static jclass LDKEvent_PendingHTLCsForwardable_class = NULL;
1796 static jmethodID LDKEvent_PendingHTLCsForwardable_meth = NULL;
1797 static jclass LDKEvent_SpendableOutputs_class = NULL;
1798 static jmethodID LDKEvent_SpendableOutputs_meth = NULL;
1799 static jclass LDKEvent_PaymentForwarded_class = NULL;
1800 static jmethodID LDKEvent_PaymentForwarded_meth = NULL;
1801 static jclass LDKEvent_ChannelClosed_class = NULL;
1802 static jmethodID LDKEvent_ChannelClosed_meth = NULL;
1803 static jclass LDKEvent_DiscardFunding_class = NULL;
1804 static jmethodID LDKEvent_DiscardFunding_meth = NULL;
1805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKEvent_init (JNIEnv *env, jclass clz) {
1806         LDKEvent_FundingGenerationReady_class =
1807                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$FundingGenerationReady;"));
1808         CHECK(LDKEvent_FundingGenerationReady_class != NULL);
1809         LDKEvent_FundingGenerationReady_meth = (*env)->GetMethodID(env, LDKEvent_FundingGenerationReady_class, "<init>", "([BJ[BJ)V");
1810         CHECK(LDKEvent_FundingGenerationReady_meth != NULL);
1811         LDKEvent_PaymentReceived_class =
1812                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentReceived;"));
1813         CHECK(LDKEvent_PaymentReceived_class != NULL);
1814         LDKEvent_PaymentReceived_meth = (*env)->GetMethodID(env, LDKEvent_PaymentReceived_class, "<init>", "([BJJ)V");
1815         CHECK(LDKEvent_PaymentReceived_meth != NULL);
1816         LDKEvent_PaymentSent_class =
1817                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentSent;"));
1818         CHECK(LDKEvent_PaymentSent_class != NULL);
1819         LDKEvent_PaymentSent_meth = (*env)->GetMethodID(env, LDKEvent_PaymentSent_class, "<init>", "([B[B[BJ)V");
1820         CHECK(LDKEvent_PaymentSent_meth != NULL);
1821         LDKEvent_PaymentPathFailed_class =
1822                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentPathFailed;"));
1823         CHECK(LDKEvent_PaymentPathFailed_class != NULL);
1824         LDKEvent_PaymentPathFailed_meth = (*env)->GetMethodID(env, LDKEvent_PaymentPathFailed_class, "<init>", "([B[BZJZ[JJJ)V");
1825         CHECK(LDKEvent_PaymentPathFailed_meth != NULL);
1826         LDKEvent_PendingHTLCsForwardable_class =
1827                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PendingHTLCsForwardable;"));
1828         CHECK(LDKEvent_PendingHTLCsForwardable_class != NULL);
1829         LDKEvent_PendingHTLCsForwardable_meth = (*env)->GetMethodID(env, LDKEvent_PendingHTLCsForwardable_class, "<init>", "(J)V");
1830         CHECK(LDKEvent_PendingHTLCsForwardable_meth != NULL);
1831         LDKEvent_SpendableOutputs_class =
1832                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$SpendableOutputs;"));
1833         CHECK(LDKEvent_SpendableOutputs_class != NULL);
1834         LDKEvent_SpendableOutputs_meth = (*env)->GetMethodID(env, LDKEvent_SpendableOutputs_class, "<init>", "([J)V");
1835         CHECK(LDKEvent_SpendableOutputs_meth != NULL);
1836         LDKEvent_PaymentForwarded_class =
1837                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$PaymentForwarded;"));
1838         CHECK(LDKEvent_PaymentForwarded_class != NULL);
1839         LDKEvent_PaymentForwarded_meth = (*env)->GetMethodID(env, LDKEvent_PaymentForwarded_class, "<init>", "(JZ)V");
1840         CHECK(LDKEvent_PaymentForwarded_meth != NULL);
1841         LDKEvent_ChannelClosed_class =
1842                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$ChannelClosed;"));
1843         CHECK(LDKEvent_ChannelClosed_class != NULL);
1844         LDKEvent_ChannelClosed_meth = (*env)->GetMethodID(env, LDKEvent_ChannelClosed_class, "<init>", "([BJJ)V");
1845         CHECK(LDKEvent_ChannelClosed_meth != NULL);
1846         LDKEvent_DiscardFunding_class =
1847                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKEvent$DiscardFunding;"));
1848         CHECK(LDKEvent_DiscardFunding_class != NULL);
1849         LDKEvent_DiscardFunding_meth = (*env)->GetMethodID(env, LDKEvent_DiscardFunding_class, "<init>", "([B[B)V");
1850         CHECK(LDKEvent_DiscardFunding_meth != NULL);
1851 }
1852 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1853         LDKEvent *obj = (LDKEvent*)(ptr & ~1);
1854         switch(obj->tag) {
1855                 case LDKEvent_FundingGenerationReady: {
1856                         int8_tArray temporary_channel_id_arr = (*env)->NewByteArray(env, 32);
1857                         (*env)->SetByteArrayRegion(env, temporary_channel_id_arr, 0, 32, obj->funding_generation_ready.temporary_channel_id.data);
1858                         LDKCVec_u8Z output_script_var = obj->funding_generation_ready.output_script;
1859                         int8_tArray output_script_arr = (*env)->NewByteArray(env, output_script_var.datalen);
1860                         (*env)->SetByteArrayRegion(env, output_script_arr, 0, output_script_var.datalen, output_script_var.data);
1861                         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);
1862                 }
1863                 case LDKEvent_PaymentReceived: {
1864                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1865                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_received.payment_hash.data);
1866                         uint64_t purpose_ref = ((uint64_t)&obj->payment_received.purpose) | 1;
1867                         return (*env)->NewObject(env, LDKEvent_PaymentReceived_class, LDKEvent_PaymentReceived_meth, payment_hash_arr, obj->payment_received.amt, purpose_ref);
1868                 }
1869                 case LDKEvent_PaymentSent: {
1870                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
1871                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_sent.payment_id.data);
1872                         int8_tArray payment_preimage_arr = (*env)->NewByteArray(env, 32);
1873                         (*env)->SetByteArrayRegion(env, payment_preimage_arr, 0, 32, obj->payment_sent.payment_preimage.data);
1874                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1875                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_sent.payment_hash.data);
1876                         uint64_t fee_paid_msat_ref = ((uint64_t)&obj->payment_sent.fee_paid_msat) | 1;
1877                         return (*env)->NewObject(env, LDKEvent_PaymentSent_class, LDKEvent_PaymentSent_meth, payment_id_arr, payment_preimage_arr, payment_hash_arr, fee_paid_msat_ref);
1878                 }
1879                 case LDKEvent_PaymentPathFailed: {
1880                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
1881                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->payment_path_failed.payment_id.data);
1882                         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
1883                         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, obj->payment_path_failed.payment_hash.data);
1884                         uint64_t network_update_ref = ((uint64_t)&obj->payment_path_failed.network_update) | 1;
1885                         LDKCVec_RouteHopZ path_var = obj->payment_path_failed.path;
1886                         int64_tArray path_arr = NULL;
1887                         path_arr = (*env)->NewLongArray(env, path_var.datalen);
1888                         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
1889                         for (size_t k = 0; k < path_var.datalen; k++) {
1890                                 LDKRouteHop path_conv_10_var = path_var.data[k];
1891                                 uint64_t path_conv_10_ref = 0;
1892                                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1893                                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1894                                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
1895                                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner & ~1;
1896                                 path_arr_ptr[k] = path_conv_10_ref;
1897                         }
1898                         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
1899                         uint64_t short_channel_id_ref = ((uint64_t)&obj->payment_path_failed.short_channel_id) | 1;
1900                         LDKRouteParameters retry_var = obj->payment_path_failed.retry;
1901                         uint64_t retry_ref = 0;
1902                         if ((uint64_t)retry_var.inner > 4096) {
1903                                 CHECK((((uint64_t)retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1904                                 CHECK((((uint64_t)&retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1905                         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_var);
1906                                 retry_ref = (uint64_t)retry_var.inner & ~1;
1907                         }
1908                         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);
1909                 }
1910                 case LDKEvent_PendingHTLCsForwardable: {
1911                         return (*env)->NewObject(env, LDKEvent_PendingHTLCsForwardable_class, LDKEvent_PendingHTLCsForwardable_meth, obj->pending_htl_cs_forwardable.time_forwardable);
1912                 }
1913                 case LDKEvent_SpendableOutputs: {
1914                         LDKCVec_SpendableOutputDescriptorZ outputs_var = obj->spendable_outputs.outputs;
1915                         int64_tArray outputs_arr = NULL;
1916                         outputs_arr = (*env)->NewLongArray(env, outputs_var.datalen);
1917                         int64_t *outputs_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, outputs_arr, NULL);
1918                         for (size_t b = 0; b < outputs_var.datalen; b++) {
1919                                 uint64_t outputs_conv_27_ref = ((uint64_t)&outputs_var.data[b]) | 1;
1920                                 outputs_arr_ptr[b] = outputs_conv_27_ref;
1921                         }
1922                         (*env)->ReleasePrimitiveArrayCritical(env, outputs_arr, outputs_arr_ptr, 0);
1923                         return (*env)->NewObject(env, LDKEvent_SpendableOutputs_class, LDKEvent_SpendableOutputs_meth, outputs_arr);
1924                 }
1925                 case LDKEvent_PaymentForwarded: {
1926                         uint64_t fee_earned_msat_ref = ((uint64_t)&obj->payment_forwarded.fee_earned_msat) | 1;
1927                         return (*env)->NewObject(env, LDKEvent_PaymentForwarded_class, LDKEvent_PaymentForwarded_meth, fee_earned_msat_ref, obj->payment_forwarded.claim_from_onchain_tx);
1928                 }
1929                 case LDKEvent_ChannelClosed: {
1930                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
1931                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->channel_closed.channel_id.data);
1932                         uint64_t reason_ref = ((uint64_t)&obj->channel_closed.reason) | 1;
1933                         return (*env)->NewObject(env, LDKEvent_ChannelClosed_class, LDKEvent_ChannelClosed_meth, channel_id_arr, obj->channel_closed.user_channel_id, reason_ref);
1934                 }
1935                 case LDKEvent_DiscardFunding: {
1936                         int8_tArray channel_id_arr = (*env)->NewByteArray(env, 32);
1937                         (*env)->SetByteArrayRegion(env, channel_id_arr, 0, 32, obj->discard_funding.channel_id.data);
1938                         LDKTransaction transaction_var = obj->discard_funding.transaction;
1939                         int8_tArray transaction_arr = (*env)->NewByteArray(env, transaction_var.datalen);
1940                         (*env)->SetByteArrayRegion(env, transaction_arr, 0, transaction_var.datalen, transaction_var.data);
1941                         return (*env)->NewObject(env, LDKEvent_DiscardFunding_class, LDKEvent_DiscardFunding_meth, channel_id_arr, transaction_arr);
1942                 }
1943                 default: abort();
1944         }
1945 }
1946 static jclass LDKCOption_EventZ_Some_class = NULL;
1947 static jmethodID LDKCOption_EventZ_Some_meth = NULL;
1948 static jclass LDKCOption_EventZ_None_class = NULL;
1949 static jmethodID LDKCOption_EventZ_None_meth = NULL;
1950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1EventZ_init (JNIEnv *env, jclass clz) {
1951         LDKCOption_EventZ_Some_class =
1952                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_EventZ$Some;"));
1953         CHECK(LDKCOption_EventZ_Some_class != NULL);
1954         LDKCOption_EventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_Some_class, "<init>", "(J)V");
1955         CHECK(LDKCOption_EventZ_Some_meth != NULL);
1956         LDKCOption_EventZ_None_class =
1957                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_EventZ$None;"));
1958         CHECK(LDKCOption_EventZ_None_class != NULL);
1959         LDKCOption_EventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_EventZ_None_class, "<init>", "()V");
1960         CHECK(LDKCOption_EventZ_None_meth != NULL);
1961 }
1962 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1EventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
1963         LDKCOption_EventZ *obj = (LDKCOption_EventZ*)(ptr & ~1);
1964         switch(obj->tag) {
1965                 case LDKCOption_EventZ_Some: {
1966                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
1967                         return (*env)->NewObject(env, LDKCOption_EventZ_Some_class, LDKCOption_EventZ_Some_meth, some_ref);
1968                 }
1969                 case LDKCOption_EventZ_None: {
1970                         return (*env)->NewObject(env, LDKCOption_EventZ_None_class, LDKCOption_EventZ_None_meth);
1971                 }
1972                 default: abort();
1973         }
1974 }
1975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1EventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
1976         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
1977         CHECK(val->result_ok);
1978         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
1979         return res_ref;
1980 }
1981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1EventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
1982         LDKCResult_COption_EventZDecodeErrorZ *val = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
1983         CHECK(!val->result_ok);
1984         LDKDecodeError err_var = (*val->contents.err);
1985         uint64_t err_ref = 0;
1986         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
1987         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
1988         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
1989         err_ref = (uint64_t)err_var.inner & ~1;
1990         return err_ref;
1991 }
1992 static jclass LDKErrorAction_DisconnectPeer_class = NULL;
1993 static jmethodID LDKErrorAction_DisconnectPeer_meth = NULL;
1994 static jclass LDKErrorAction_IgnoreError_class = NULL;
1995 static jmethodID LDKErrorAction_IgnoreError_meth = NULL;
1996 static jclass LDKErrorAction_IgnoreAndLog_class = NULL;
1997 static jmethodID LDKErrorAction_IgnoreAndLog_meth = NULL;
1998 static jclass LDKErrorAction_SendErrorMessage_class = NULL;
1999 static jmethodID LDKErrorAction_SendErrorMessage_meth = NULL;
2000 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKErrorAction_init (JNIEnv *env, jclass clz) {
2001         LDKErrorAction_DisconnectPeer_class =
2002                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$DisconnectPeer;"));
2003         CHECK(LDKErrorAction_DisconnectPeer_class != NULL);
2004         LDKErrorAction_DisconnectPeer_meth = (*env)->GetMethodID(env, LDKErrorAction_DisconnectPeer_class, "<init>", "(J)V");
2005         CHECK(LDKErrorAction_DisconnectPeer_meth != NULL);
2006         LDKErrorAction_IgnoreError_class =
2007                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreError;"));
2008         CHECK(LDKErrorAction_IgnoreError_class != NULL);
2009         LDKErrorAction_IgnoreError_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreError_class, "<init>", "()V");
2010         CHECK(LDKErrorAction_IgnoreError_meth != NULL);
2011         LDKErrorAction_IgnoreAndLog_class =
2012                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$IgnoreAndLog;"));
2013         CHECK(LDKErrorAction_IgnoreAndLog_class != NULL);
2014         LDKErrorAction_IgnoreAndLog_meth = (*env)->GetMethodID(env, LDKErrorAction_IgnoreAndLog_class, "<init>", "(Lorg/ldk/enums/Level;)V");
2015         CHECK(LDKErrorAction_IgnoreAndLog_meth != NULL);
2016         LDKErrorAction_SendErrorMessage_class =
2017                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKErrorAction$SendErrorMessage;"));
2018         CHECK(LDKErrorAction_SendErrorMessage_class != NULL);
2019         LDKErrorAction_SendErrorMessage_meth = (*env)->GetMethodID(env, LDKErrorAction_SendErrorMessage_class, "<init>", "(J)V");
2020         CHECK(LDKErrorAction_SendErrorMessage_meth != NULL);
2021 }
2022 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKErrorAction_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2023         LDKErrorAction *obj = (LDKErrorAction*)(ptr & ~1);
2024         switch(obj->tag) {
2025                 case LDKErrorAction_DisconnectPeer: {
2026                         LDKErrorMessage msg_var = obj->disconnect_peer.msg;
2027                         uint64_t msg_ref = 0;
2028                         if ((uint64_t)msg_var.inner > 4096) {
2029                                 CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2030                                 CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2031                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2032                                 msg_ref = (uint64_t)msg_var.inner & ~1;
2033                         }
2034                         return (*env)->NewObject(env, LDKErrorAction_DisconnectPeer_class, LDKErrorAction_DisconnectPeer_meth, msg_ref);
2035                 }
2036                 case LDKErrorAction_IgnoreError: {
2037                         return (*env)->NewObject(env, LDKErrorAction_IgnoreError_class, LDKErrorAction_IgnoreError_meth);
2038                 }
2039                 case LDKErrorAction_IgnoreAndLog: {
2040                         jclass ignore_and_log_conv = LDKLevel_to_java(env, obj->ignore_and_log);
2041                         return (*env)->NewObject(env, LDKErrorAction_IgnoreAndLog_class, LDKErrorAction_IgnoreAndLog_meth, ignore_and_log_conv);
2042                 }
2043                 case LDKErrorAction_SendErrorMessage: {
2044                         LDKErrorMessage msg_var = obj->send_error_message.msg;
2045                         uint64_t msg_ref = 0;
2046                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2047                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2048                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2049                         msg_ref = (uint64_t)msg_var.inner & ~1;
2050                         return (*env)->NewObject(env, LDKErrorAction_SendErrorMessage_class, LDKErrorAction_SendErrorMessage_meth, msg_ref);
2051                 }
2052                 default: abort();
2053         }
2054 }
2055 static jclass LDKMessageSendEvent_SendAcceptChannel_class = NULL;
2056 static jmethodID LDKMessageSendEvent_SendAcceptChannel_meth = NULL;
2057 static jclass LDKMessageSendEvent_SendOpenChannel_class = NULL;
2058 static jmethodID LDKMessageSendEvent_SendOpenChannel_meth = NULL;
2059 static jclass LDKMessageSendEvent_SendFundingCreated_class = NULL;
2060 static jmethodID LDKMessageSendEvent_SendFundingCreated_meth = NULL;
2061 static jclass LDKMessageSendEvent_SendFundingSigned_class = NULL;
2062 static jmethodID LDKMessageSendEvent_SendFundingSigned_meth = NULL;
2063 static jclass LDKMessageSendEvent_SendFundingLocked_class = NULL;
2064 static jmethodID LDKMessageSendEvent_SendFundingLocked_meth = NULL;
2065 static jclass LDKMessageSendEvent_SendAnnouncementSignatures_class = NULL;
2066 static jmethodID LDKMessageSendEvent_SendAnnouncementSignatures_meth = NULL;
2067 static jclass LDKMessageSendEvent_UpdateHTLCs_class = NULL;
2068 static jmethodID LDKMessageSendEvent_UpdateHTLCs_meth = NULL;
2069 static jclass LDKMessageSendEvent_SendRevokeAndACK_class = NULL;
2070 static jmethodID LDKMessageSendEvent_SendRevokeAndACK_meth = NULL;
2071 static jclass LDKMessageSendEvent_SendClosingSigned_class = NULL;
2072 static jmethodID LDKMessageSendEvent_SendClosingSigned_meth = NULL;
2073 static jclass LDKMessageSendEvent_SendShutdown_class = NULL;
2074 static jmethodID LDKMessageSendEvent_SendShutdown_meth = NULL;
2075 static jclass LDKMessageSendEvent_SendChannelReestablish_class = NULL;
2076 static jmethodID LDKMessageSendEvent_SendChannelReestablish_meth = NULL;
2077 static jclass LDKMessageSendEvent_BroadcastChannelAnnouncement_class = NULL;
2078 static jmethodID LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = NULL;
2079 static jclass LDKMessageSendEvent_BroadcastNodeAnnouncement_class = NULL;
2080 static jmethodID LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = NULL;
2081 static jclass LDKMessageSendEvent_BroadcastChannelUpdate_class = NULL;
2082 static jmethodID LDKMessageSendEvent_BroadcastChannelUpdate_meth = NULL;
2083 static jclass LDKMessageSendEvent_SendChannelUpdate_class = NULL;
2084 static jmethodID LDKMessageSendEvent_SendChannelUpdate_meth = NULL;
2085 static jclass LDKMessageSendEvent_HandleError_class = NULL;
2086 static jmethodID LDKMessageSendEvent_HandleError_meth = NULL;
2087 static jclass LDKMessageSendEvent_SendChannelRangeQuery_class = NULL;
2088 static jmethodID LDKMessageSendEvent_SendChannelRangeQuery_meth = NULL;
2089 static jclass LDKMessageSendEvent_SendShortIdsQuery_class = NULL;
2090 static jmethodID LDKMessageSendEvent_SendShortIdsQuery_meth = NULL;
2091 static jclass LDKMessageSendEvent_SendReplyChannelRange_class = NULL;
2092 static jmethodID LDKMessageSendEvent_SendReplyChannelRange_meth = NULL;
2093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKMessageSendEvent_init (JNIEnv *env, jclass clz) {
2094         LDKMessageSendEvent_SendAcceptChannel_class =
2095                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAcceptChannel;"));
2096         CHECK(LDKMessageSendEvent_SendAcceptChannel_class != NULL);
2097         LDKMessageSendEvent_SendAcceptChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAcceptChannel_class, "<init>", "([BJ)V");
2098         CHECK(LDKMessageSendEvent_SendAcceptChannel_meth != NULL);
2099         LDKMessageSendEvent_SendOpenChannel_class =
2100                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendOpenChannel;"));
2101         CHECK(LDKMessageSendEvent_SendOpenChannel_class != NULL);
2102         LDKMessageSendEvent_SendOpenChannel_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendOpenChannel_class, "<init>", "([BJ)V");
2103         CHECK(LDKMessageSendEvent_SendOpenChannel_meth != NULL);
2104         LDKMessageSendEvent_SendFundingCreated_class =
2105                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingCreated;"));
2106         CHECK(LDKMessageSendEvent_SendFundingCreated_class != NULL);
2107         LDKMessageSendEvent_SendFundingCreated_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingCreated_class, "<init>", "([BJ)V");
2108         CHECK(LDKMessageSendEvent_SendFundingCreated_meth != NULL);
2109         LDKMessageSendEvent_SendFundingSigned_class =
2110                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingSigned;"));
2111         CHECK(LDKMessageSendEvent_SendFundingSigned_class != NULL);
2112         LDKMessageSendEvent_SendFundingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingSigned_class, "<init>", "([BJ)V");
2113         CHECK(LDKMessageSendEvent_SendFundingSigned_meth != NULL);
2114         LDKMessageSendEvent_SendFundingLocked_class =
2115                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendFundingLocked;"));
2116         CHECK(LDKMessageSendEvent_SendFundingLocked_class != NULL);
2117         LDKMessageSendEvent_SendFundingLocked_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendFundingLocked_class, "<init>", "([BJ)V");
2118         CHECK(LDKMessageSendEvent_SendFundingLocked_meth != NULL);
2119         LDKMessageSendEvent_SendAnnouncementSignatures_class =
2120                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendAnnouncementSignatures;"));
2121         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_class != NULL);
2122         LDKMessageSendEvent_SendAnnouncementSignatures_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, "<init>", "([BJ)V");
2123         CHECK(LDKMessageSendEvent_SendAnnouncementSignatures_meth != NULL);
2124         LDKMessageSendEvent_UpdateHTLCs_class =
2125                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$UpdateHTLCs;"));
2126         CHECK(LDKMessageSendEvent_UpdateHTLCs_class != NULL);
2127         LDKMessageSendEvent_UpdateHTLCs_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_UpdateHTLCs_class, "<init>", "([BJ)V");
2128         CHECK(LDKMessageSendEvent_UpdateHTLCs_meth != NULL);
2129         LDKMessageSendEvent_SendRevokeAndACK_class =
2130                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendRevokeAndACK;"));
2131         CHECK(LDKMessageSendEvent_SendRevokeAndACK_class != NULL);
2132         LDKMessageSendEvent_SendRevokeAndACK_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendRevokeAndACK_class, "<init>", "([BJ)V");
2133         CHECK(LDKMessageSendEvent_SendRevokeAndACK_meth != NULL);
2134         LDKMessageSendEvent_SendClosingSigned_class =
2135                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendClosingSigned;"));
2136         CHECK(LDKMessageSendEvent_SendClosingSigned_class != NULL);
2137         LDKMessageSendEvent_SendClosingSigned_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendClosingSigned_class, "<init>", "([BJ)V");
2138         CHECK(LDKMessageSendEvent_SendClosingSigned_meth != NULL);
2139         LDKMessageSendEvent_SendShutdown_class =
2140                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShutdown;"));
2141         CHECK(LDKMessageSendEvent_SendShutdown_class != NULL);
2142         LDKMessageSendEvent_SendShutdown_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShutdown_class, "<init>", "([BJ)V");
2143         CHECK(LDKMessageSendEvent_SendShutdown_meth != NULL);
2144         LDKMessageSendEvent_SendChannelReestablish_class =
2145                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelReestablish;"));
2146         CHECK(LDKMessageSendEvent_SendChannelReestablish_class != NULL);
2147         LDKMessageSendEvent_SendChannelReestablish_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelReestablish_class, "<init>", "([BJ)V");
2148         CHECK(LDKMessageSendEvent_SendChannelReestablish_meth != NULL);
2149         LDKMessageSendEvent_BroadcastChannelAnnouncement_class =
2150                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelAnnouncement;"));
2151         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_class != NULL);
2152         LDKMessageSendEvent_BroadcastChannelAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, "<init>", "(JJ)V");
2153         CHECK(LDKMessageSendEvent_BroadcastChannelAnnouncement_meth != NULL);
2154         LDKMessageSendEvent_BroadcastNodeAnnouncement_class =
2155                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastNodeAnnouncement;"));
2156         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_class != NULL);
2157         LDKMessageSendEvent_BroadcastNodeAnnouncement_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, "<init>", "(J)V");
2158         CHECK(LDKMessageSendEvent_BroadcastNodeAnnouncement_meth != NULL);
2159         LDKMessageSendEvent_BroadcastChannelUpdate_class =
2160                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$BroadcastChannelUpdate;"));
2161         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_class != NULL);
2162         LDKMessageSendEvent_BroadcastChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, "<init>", "(J)V");
2163         CHECK(LDKMessageSendEvent_BroadcastChannelUpdate_meth != NULL);
2164         LDKMessageSendEvent_SendChannelUpdate_class =
2165                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelUpdate;"));
2166         CHECK(LDKMessageSendEvent_SendChannelUpdate_class != NULL);
2167         LDKMessageSendEvent_SendChannelUpdate_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelUpdate_class, "<init>", "([BJ)V");
2168         CHECK(LDKMessageSendEvent_SendChannelUpdate_meth != NULL);
2169         LDKMessageSendEvent_HandleError_class =
2170                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$HandleError;"));
2171         CHECK(LDKMessageSendEvent_HandleError_class != NULL);
2172         LDKMessageSendEvent_HandleError_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_HandleError_class, "<init>", "([BJ)V");
2173         CHECK(LDKMessageSendEvent_HandleError_meth != NULL);
2174         LDKMessageSendEvent_SendChannelRangeQuery_class =
2175                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendChannelRangeQuery;"));
2176         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_class != NULL);
2177         LDKMessageSendEvent_SendChannelRangeQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendChannelRangeQuery_class, "<init>", "([BJ)V");
2178         CHECK(LDKMessageSendEvent_SendChannelRangeQuery_meth != NULL);
2179         LDKMessageSendEvent_SendShortIdsQuery_class =
2180                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendShortIdsQuery;"));
2181         CHECK(LDKMessageSendEvent_SendShortIdsQuery_class != NULL);
2182         LDKMessageSendEvent_SendShortIdsQuery_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendShortIdsQuery_class, "<init>", "([BJ)V");
2183         CHECK(LDKMessageSendEvent_SendShortIdsQuery_meth != NULL);
2184         LDKMessageSendEvent_SendReplyChannelRange_class =
2185                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKMessageSendEvent$SendReplyChannelRange;"));
2186         CHECK(LDKMessageSendEvent_SendReplyChannelRange_class != NULL);
2187         LDKMessageSendEvent_SendReplyChannelRange_meth = (*env)->GetMethodID(env, LDKMessageSendEvent_SendReplyChannelRange_class, "<init>", "([BJ)V");
2188         CHECK(LDKMessageSendEvent_SendReplyChannelRange_meth != NULL);
2189 }
2190 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEvent_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
2191         LDKMessageSendEvent *obj = (LDKMessageSendEvent*)(ptr & ~1);
2192         switch(obj->tag) {
2193                 case LDKMessageSendEvent_SendAcceptChannel: {
2194                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2195                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_accept_channel.node_id.compressed_form);
2196                         LDKAcceptChannel msg_var = obj->send_accept_channel.msg;
2197                         uint64_t msg_ref = 0;
2198                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2199                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2200                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2201                         msg_ref = (uint64_t)msg_var.inner & ~1;
2202                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAcceptChannel_class, LDKMessageSendEvent_SendAcceptChannel_meth, node_id_arr, msg_ref);
2203                 }
2204                 case LDKMessageSendEvent_SendOpenChannel: {
2205                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2206                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_open_channel.node_id.compressed_form);
2207                         LDKOpenChannel msg_var = obj->send_open_channel.msg;
2208                         uint64_t msg_ref = 0;
2209                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2210                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2211                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2212                         msg_ref = (uint64_t)msg_var.inner & ~1;
2213                         return (*env)->NewObject(env, LDKMessageSendEvent_SendOpenChannel_class, LDKMessageSendEvent_SendOpenChannel_meth, node_id_arr, msg_ref);
2214                 }
2215                 case LDKMessageSendEvent_SendFundingCreated: {
2216                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2217                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_created.node_id.compressed_form);
2218                         LDKFundingCreated msg_var = obj->send_funding_created.msg;
2219                         uint64_t msg_ref = 0;
2220                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2221                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2222                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2223                         msg_ref = (uint64_t)msg_var.inner & ~1;
2224                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingCreated_class, LDKMessageSendEvent_SendFundingCreated_meth, node_id_arr, msg_ref);
2225                 }
2226                 case LDKMessageSendEvent_SendFundingSigned: {
2227                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2228                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_signed.node_id.compressed_form);
2229                         LDKFundingSigned msg_var = obj->send_funding_signed.msg;
2230                         uint64_t msg_ref = 0;
2231                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2232                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2233                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2234                         msg_ref = (uint64_t)msg_var.inner & ~1;
2235                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingSigned_class, LDKMessageSendEvent_SendFundingSigned_meth, node_id_arr, msg_ref);
2236                 }
2237                 case LDKMessageSendEvent_SendFundingLocked: {
2238                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2239                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_funding_locked.node_id.compressed_form);
2240                         LDKFundingLocked msg_var = obj->send_funding_locked.msg;
2241                         uint64_t msg_ref = 0;
2242                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2243                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2244                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2245                         msg_ref = (uint64_t)msg_var.inner & ~1;
2246                         return (*env)->NewObject(env, LDKMessageSendEvent_SendFundingLocked_class, LDKMessageSendEvent_SendFundingLocked_meth, node_id_arr, msg_ref);
2247                 }
2248                 case LDKMessageSendEvent_SendAnnouncementSignatures: {
2249                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2250                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_announcement_signatures.node_id.compressed_form);
2251                         LDKAnnouncementSignatures msg_var = obj->send_announcement_signatures.msg;
2252                         uint64_t msg_ref = 0;
2253                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2254                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2255                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2256                         msg_ref = (uint64_t)msg_var.inner & ~1;
2257                         return (*env)->NewObject(env, LDKMessageSendEvent_SendAnnouncementSignatures_class, LDKMessageSendEvent_SendAnnouncementSignatures_meth, node_id_arr, msg_ref);
2258                 }
2259                 case LDKMessageSendEvent_UpdateHTLCs: {
2260                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2261                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->update_htl_cs.node_id.compressed_form);
2262                         LDKCommitmentUpdate updates_var = obj->update_htl_cs.updates;
2263                         uint64_t updates_ref = 0;
2264                         CHECK((((uint64_t)updates_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2265                         CHECK((((uint64_t)&updates_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2266                         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_var);
2267                         updates_ref = (uint64_t)updates_var.inner & ~1;
2268                         return (*env)->NewObject(env, LDKMessageSendEvent_UpdateHTLCs_class, LDKMessageSendEvent_UpdateHTLCs_meth, node_id_arr, updates_ref);
2269                 }
2270                 case LDKMessageSendEvent_SendRevokeAndACK: {
2271                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2272                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_revoke_and_ack.node_id.compressed_form);
2273                         LDKRevokeAndACK msg_var = obj->send_revoke_and_ack.msg;
2274                         uint64_t msg_ref = 0;
2275                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2276                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2277                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2278                         msg_ref = (uint64_t)msg_var.inner & ~1;
2279                         return (*env)->NewObject(env, LDKMessageSendEvent_SendRevokeAndACK_class, LDKMessageSendEvent_SendRevokeAndACK_meth, node_id_arr, msg_ref);
2280                 }
2281                 case LDKMessageSendEvent_SendClosingSigned: {
2282                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2283                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_closing_signed.node_id.compressed_form);
2284                         LDKClosingSigned msg_var = obj->send_closing_signed.msg;
2285                         uint64_t msg_ref = 0;
2286                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2287                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2288                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2289                         msg_ref = (uint64_t)msg_var.inner & ~1;
2290                         return (*env)->NewObject(env, LDKMessageSendEvent_SendClosingSigned_class, LDKMessageSendEvent_SendClosingSigned_meth, node_id_arr, msg_ref);
2291                 }
2292                 case LDKMessageSendEvent_SendShutdown: {
2293                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2294                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_shutdown.node_id.compressed_form);
2295                         LDKShutdown msg_var = obj->send_shutdown.msg;
2296                         uint64_t msg_ref = 0;
2297                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2298                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2299                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2300                         msg_ref = (uint64_t)msg_var.inner & ~1;
2301                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShutdown_class, LDKMessageSendEvent_SendShutdown_meth, node_id_arr, msg_ref);
2302                 }
2303                 case LDKMessageSendEvent_SendChannelReestablish: {
2304                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2305                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_reestablish.node_id.compressed_form);
2306                         LDKChannelReestablish msg_var = obj->send_channel_reestablish.msg;
2307                         uint64_t msg_ref = 0;
2308                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2309                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2310                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2311                         msg_ref = (uint64_t)msg_var.inner & ~1;
2312                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelReestablish_class, LDKMessageSendEvent_SendChannelReestablish_meth, node_id_arr, msg_ref);
2313                 }
2314                 case LDKMessageSendEvent_BroadcastChannelAnnouncement: {
2315                         LDKChannelAnnouncement msg_var = obj->broadcast_channel_announcement.msg;
2316                         uint64_t msg_ref = 0;
2317                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2318                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2319                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2320                         msg_ref = (uint64_t)msg_var.inner & ~1;
2321                         LDKChannelUpdate update_msg_var = obj->broadcast_channel_announcement.update_msg;
2322                         uint64_t update_msg_ref = 0;
2323                         CHECK((((uint64_t)update_msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2324                         CHECK((((uint64_t)&update_msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2325                         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_var);
2326                         update_msg_ref = (uint64_t)update_msg_var.inner & ~1;
2327                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelAnnouncement_class, LDKMessageSendEvent_BroadcastChannelAnnouncement_meth, msg_ref, update_msg_ref);
2328                 }
2329                 case LDKMessageSendEvent_BroadcastNodeAnnouncement: {
2330                         LDKNodeAnnouncement msg_var = obj->broadcast_node_announcement.msg;
2331                         uint64_t msg_ref = 0;
2332                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2333                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2334                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2335                         msg_ref = (uint64_t)msg_var.inner & ~1;
2336                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastNodeAnnouncement_class, LDKMessageSendEvent_BroadcastNodeAnnouncement_meth, msg_ref);
2337                 }
2338                 case LDKMessageSendEvent_BroadcastChannelUpdate: {
2339                         LDKChannelUpdate msg_var = obj->broadcast_channel_update.msg;
2340                         uint64_t msg_ref = 0;
2341                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2342                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2343                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2344                         msg_ref = (uint64_t)msg_var.inner & ~1;
2345                         return (*env)->NewObject(env, LDKMessageSendEvent_BroadcastChannelUpdate_class, LDKMessageSendEvent_BroadcastChannelUpdate_meth, msg_ref);
2346                 }
2347                 case LDKMessageSendEvent_SendChannelUpdate: {
2348                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2349                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_update.node_id.compressed_form);
2350                         LDKChannelUpdate msg_var = obj->send_channel_update.msg;
2351                         uint64_t msg_ref = 0;
2352                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2353                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2354                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2355                         msg_ref = (uint64_t)msg_var.inner & ~1;
2356                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelUpdate_class, LDKMessageSendEvent_SendChannelUpdate_meth, node_id_arr, msg_ref);
2357                 }
2358                 case LDKMessageSendEvent_HandleError: {
2359                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2360                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->handle_error.node_id.compressed_form);
2361                         uint64_t action_ref = ((uint64_t)&obj->handle_error.action) | 1;
2362                         return (*env)->NewObject(env, LDKMessageSendEvent_HandleError_class, LDKMessageSendEvent_HandleError_meth, node_id_arr, action_ref);
2363                 }
2364                 case LDKMessageSendEvent_SendChannelRangeQuery: {
2365                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2366                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_channel_range_query.node_id.compressed_form);
2367                         LDKQueryChannelRange msg_var = obj->send_channel_range_query.msg;
2368                         uint64_t msg_ref = 0;
2369                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2370                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2371                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2372                         msg_ref = (uint64_t)msg_var.inner & ~1;
2373                         return (*env)->NewObject(env, LDKMessageSendEvent_SendChannelRangeQuery_class, LDKMessageSendEvent_SendChannelRangeQuery_meth, node_id_arr, msg_ref);
2374                 }
2375                 case LDKMessageSendEvent_SendShortIdsQuery: {
2376                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2377                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_short_ids_query.node_id.compressed_form);
2378                         LDKQueryShortChannelIds msg_var = obj->send_short_ids_query.msg;
2379                         uint64_t msg_ref = 0;
2380                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2381                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2382                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2383                         msg_ref = (uint64_t)msg_var.inner & ~1;
2384                         return (*env)->NewObject(env, LDKMessageSendEvent_SendShortIdsQuery_class, LDKMessageSendEvent_SendShortIdsQuery_meth, node_id_arr, msg_ref);
2385                 }
2386                 case LDKMessageSendEvent_SendReplyChannelRange: {
2387                         int8_tArray node_id_arr = (*env)->NewByteArray(env, 33);
2388                         (*env)->SetByteArrayRegion(env, node_id_arr, 0, 33, obj->send_reply_channel_range.node_id.compressed_form);
2389                         LDKReplyChannelRange msg_var = obj->send_reply_channel_range.msg;
2390                         uint64_t msg_ref = 0;
2391                         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2392                         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2393                         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
2394                         msg_ref = (uint64_t)msg_var.inner & ~1;
2395                         return (*env)->NewObject(env, LDKMessageSendEvent_SendReplyChannelRange_class, LDKMessageSendEvent_SendReplyChannelRange_meth, node_id_arr, msg_ref);
2396                 }
2397                 default: abort();
2398         }
2399 }
2400 static inline LDKCVec_MessageSendEventZ CVec_MessageSendEventZ_clone(const LDKCVec_MessageSendEventZ *orig) {
2401         LDKCVec_MessageSendEventZ ret = { .data = MALLOC(sizeof(LDKMessageSendEvent) * orig->datalen, "LDKCVec_MessageSendEventZ clone bytes"), .datalen = orig->datalen };
2402         for (size_t i = 0; i < ret.datalen; i++) {
2403                 ret.data[i] = MessageSendEvent_clone(&orig->data[i]);
2404         }
2405         return ret;
2406 }
2407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2408         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2409         CHECK(val->result_ok);
2410         LDKInitFeatures res_var = (*val->contents.result);
2411         uint64_t res_ref = 0;
2412         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2413         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2414         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2415         res_ref = (uint64_t)res_var.inner & ~1;
2416         return res_ref;
2417 }
2418 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2419         LDKCResult_InitFeaturesDecodeErrorZ *val = (LDKCResult_InitFeaturesDecodeErrorZ*)(arg & ~1);
2420         CHECK(!val->result_ok);
2421         LDKDecodeError err_var = (*val->contents.err);
2422         uint64_t err_ref = 0;
2423         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2424         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2425         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2426         err_ref = (uint64_t)err_var.inner & ~1;
2427         return err_ref;
2428 }
2429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2430         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2431         CHECK(val->result_ok);
2432         LDKNodeFeatures res_var = (*val->contents.result);
2433         uint64_t res_ref = 0;
2434         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2435         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2436         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2437         res_ref = (uint64_t)res_var.inner & ~1;
2438         return res_ref;
2439 }
2440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2441         LDKCResult_NodeFeaturesDecodeErrorZ *val = (LDKCResult_NodeFeaturesDecodeErrorZ*)(arg & ~1);
2442         CHECK(!val->result_ok);
2443         LDKDecodeError err_var = (*val->contents.err);
2444         uint64_t err_ref = 0;
2445         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2446         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2447         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2448         err_ref = (uint64_t)err_var.inner & ~1;
2449         return err_ref;
2450 }
2451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2452         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2453         CHECK(val->result_ok);
2454         LDKChannelFeatures res_var = (*val->contents.result);
2455         uint64_t res_ref = 0;
2456         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2457         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2458         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2459         res_ref = (uint64_t)res_var.inner & ~1;
2460         return res_ref;
2461 }
2462 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2463         LDKCResult_ChannelFeaturesDecodeErrorZ *val = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(arg & ~1);
2464         CHECK(!val->result_ok);
2465         LDKDecodeError err_var = (*val->contents.err);
2466         uint64_t err_ref = 0;
2467         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2468         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2469         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2470         err_ref = (uint64_t)err_var.inner & ~1;
2471         return err_ref;
2472 }
2473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2474         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2475         CHECK(val->result_ok);
2476         LDKInvoiceFeatures res_var = (*val->contents.result);
2477         uint64_t res_ref = 0;
2478         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2479         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2480         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2481         res_ref = (uint64_t)res_var.inner & ~1;
2482         return res_ref;
2483 }
2484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceFeaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2485         LDKCResult_InvoiceFeaturesDecodeErrorZ *val = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(arg & ~1);
2486         CHECK(!val->result_ok);
2487         LDKDecodeError err_var = (*val->contents.err);
2488         uint64_t err_ref = 0;
2489         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2490         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2491         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2492         err_ref = (uint64_t)err_var.inner & ~1;
2493         return err_ref;
2494 }
2495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2496         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
2497         CHECK(val->result_ok);
2498         LDKScoringParameters res_var = (*val->contents.result);
2499         uint64_t res_ref = 0;
2500         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2501         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2502         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2503         res_ref = (uint64_t)res_var.inner & ~1;
2504         return res_ref;
2505 }
2506 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScoringParametersDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2507         LDKCResult_ScoringParametersDecodeErrorZ *val = (LDKCResult_ScoringParametersDecodeErrorZ*)(arg & ~1);
2508         CHECK(!val->result_ok);
2509         LDKDecodeError err_var = (*val->contents.err);
2510         uint64_t err_ref = 0;
2511         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2512         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2513         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2514         err_ref = (uint64_t)err_var.inner & ~1;
2515         return err_ref;
2516 }
2517 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2518         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
2519         CHECK(val->result_ok);
2520         LDKScorer res_var = (*val->contents.result);
2521         uint64_t res_ref = 0;
2522         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2523         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2524         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2525         res_ref = (uint64_t)res_var.inner & ~1;
2526         return res_ref;
2527 }
2528 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ScorerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2529         LDKCResult_ScorerDecodeErrorZ *val = (LDKCResult_ScorerDecodeErrorZ*)(arg & ~1);
2530         CHECK(!val->result_ok);
2531         LDKDecodeError err_var = (*val->contents.err);
2532         uint64_t err_ref = 0;
2533         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2534         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2535         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2536         err_ref = (uint64_t)err_var.inner & ~1;
2537         return err_ref;
2538 }
2539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2540         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2541         CHECK(val->result_ok);
2542         LDKDelayedPaymentOutputDescriptor res_var = (*val->contents.result);
2543         uint64_t res_ref = 0;
2544         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2545         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2546         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2547         res_ref = (uint64_t)res_var.inner & ~1;
2548         return res_ref;
2549 }
2550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2551         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2552         CHECK(!val->result_ok);
2553         LDKDecodeError err_var = (*val->contents.err);
2554         uint64_t err_ref = 0;
2555         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2556         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2557         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2558         err_ref = (uint64_t)err_var.inner & ~1;
2559         return err_ref;
2560 }
2561 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2562         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2563         CHECK(val->result_ok);
2564         LDKStaticPaymentOutputDescriptor res_var = (*val->contents.result);
2565         uint64_t res_ref = 0;
2566         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2567         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2568         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
2569         res_ref = (uint64_t)res_var.inner & ~1;
2570         return res_ref;
2571 }
2572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2573         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *val = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
2574         CHECK(!val->result_ok);
2575         LDKDecodeError err_var = (*val->contents.err);
2576         uint64_t err_ref = 0;
2577         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2578         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2579         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2580         err_ref = (uint64_t)err_var.inner & ~1;
2581         return err_ref;
2582 }
2583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2584         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2585         CHECK(val->result_ok);
2586         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
2587         return res_ref;
2588 }
2589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SpendableOutputDescriptorDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2590         LDKCResult_SpendableOutputDescriptorDecodeErrorZ *val = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
2591         CHECK(!val->result_ok);
2592         LDKDecodeError err_var = (*val->contents.err);
2593         uint64_t err_ref = 0;
2594         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2595         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2596         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
2597         err_ref = (uint64_t)err_var.inner & ~1;
2598         return err_ref;
2599 }
2600 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2601         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2602         CHECK(val->result_ok);
2603         return *val->contents.result;
2604 }
2605 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2606         LDKCResult_NoneNoneZ *val = (LDKCResult_NoneNoneZ*)(arg & ~1);
2607         CHECK(!val->result_ok);
2608         return *val->contents.err;
2609 }
2610 static inline struct LDKSignature C2Tuple_SignatureCVec_SignatureZZ_get_a(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2611         return tuple->a;
2612 }
2613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
2614         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2615         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
2616         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, C2Tuple_SignatureCVec_SignatureZZ_get_a(tuple_conv).compact_form);
2617         return ret_arr;
2618 }
2619
2620 static inline struct LDKCVec_SignatureZ C2Tuple_SignatureCVec_SignatureZZ_get_b(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR tuple){
2621         return tuple->b;
2622 }
2623 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
2624         LDKC2Tuple_SignatureCVec_SignatureZZ* tuple_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(tuple & ~1);
2625         LDKCVec_SignatureZ ret_var = C2Tuple_SignatureCVec_SignatureZZ_get_b(tuple_conv);
2626         jobjectArray ret_arr = NULL;
2627         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
2628         ;
2629         for (size_t i = 0; i < ret_var.datalen; i++) {
2630                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 64);
2631                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 64, ret_var.data[i].compact_form);
2632                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
2633         }
2634         
2635         FREE(ret_var.data);
2636         return ret_arr;
2637 }
2638
2639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2640         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2641         CHECK(val->result_ok);
2642         LDKC2Tuple_SignatureCVec_SignatureZZ* res_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
2643         *res_conv = (*val->contents.result);
2644         *res_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(res_conv);
2645         return ((uint64_t)res_conv);
2646 }
2647 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2648         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *val = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
2649         CHECK(!val->result_ok);
2650         return *val->contents.err;
2651 }
2652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
2653         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2654         CHECK(val->result_ok);
2655         int8_tArray res_arr = (*env)->NewByteArray(env, 64);
2656         (*env)->SetByteArrayRegion(env, res_arr, 0, 64, (*val->contents.result).compact_form);
2657         return res_arr;
2658 }
2659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
2660         LDKCResult_SignatureNoneZ *val = (LDKCResult_SignatureNoneZ*)(arg & ~1);
2661         CHECK(!val->result_ok);
2662         return *val->contents.err;
2663 }
2664 typedef struct LDKBaseSign_JCalls {
2665         atomic_size_t refcnt;
2666         JavaVM *vm;
2667         jweak o;
2668         jmethodID get_per_commitment_point_meth;
2669         jmethodID release_commitment_secret_meth;
2670         jmethodID validate_holder_commitment_meth;
2671         jmethodID channel_keys_id_meth;
2672         jmethodID sign_counterparty_commitment_meth;
2673         jmethodID validate_counterparty_revocation_meth;
2674         jmethodID sign_holder_commitment_and_htlcs_meth;
2675         jmethodID sign_justice_revoked_output_meth;
2676         jmethodID sign_justice_revoked_htlc_meth;
2677         jmethodID sign_counterparty_htlc_transaction_meth;
2678         jmethodID sign_closing_transaction_meth;
2679         jmethodID sign_channel_announcement_meth;
2680         jmethodID ready_channel_meth;
2681 } LDKBaseSign_JCalls;
2682 static void LDKBaseSign_JCalls_free(void* this_arg) {
2683         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2684         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
2685                 JNIEnv *env;
2686                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2687                 if (get_jenv_res == JNI_EDETACHED) {
2688                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2689                 } else {
2690                         DO_ASSERT(get_jenv_res == JNI_OK);
2691                 }
2692                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
2693                 if (get_jenv_res == JNI_EDETACHED) {
2694                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2695                 }
2696                 FREE(j_calls);
2697         }
2698 }
2699 LDKPublicKey get_per_commitment_point_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2700         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2701         JNIEnv *env;
2702         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2703         if (get_jenv_res == JNI_EDETACHED) {
2704                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2705         } else {
2706                 DO_ASSERT(get_jenv_res == JNI_OK);
2707         }
2708         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2709         CHECK(obj != NULL);
2710         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_per_commitment_point_meth, idx);
2711         if ((*env)->ExceptionCheck(env)) {
2712                 (*env)->ExceptionDescribe(env);
2713                 (*env)->FatalError(env, "A call to get_per_commitment_point in LDKBaseSign from rust threw an exception.");
2714         }
2715         LDKPublicKey ret_ref;
2716         CHECK((*env)->GetArrayLength(env, ret) == 33);
2717         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
2718         if (get_jenv_res == JNI_EDETACHED) {
2719                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2720         }
2721         return ret_ref;
2722 }
2723 LDKThirtyTwoBytes release_commitment_secret_LDKBaseSign_jcall(const void* this_arg, uint64_t idx) {
2724         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2725         JNIEnv *env;
2726         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2727         if (get_jenv_res == JNI_EDETACHED) {
2728                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2729         } else {
2730                 DO_ASSERT(get_jenv_res == JNI_OK);
2731         }
2732         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2733         CHECK(obj != NULL);
2734         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_commitment_secret_meth, idx);
2735         if ((*env)->ExceptionCheck(env)) {
2736                 (*env)->ExceptionDescribe(env);
2737                 (*env)->FatalError(env, "A call to release_commitment_secret in LDKBaseSign from rust threw an exception.");
2738         }
2739         LDKThirtyTwoBytes ret_ref;
2740         CHECK((*env)->GetArrayLength(env, ret) == 32);
2741         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2742         if (get_jenv_res == JNI_EDETACHED) {
2743                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2744         }
2745         return ret_ref;
2746 }
2747 LDKCResult_NoneNoneZ validate_holder_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * holder_tx) {
2748         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2749         JNIEnv *env;
2750         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2751         if (get_jenv_res == JNI_EDETACHED) {
2752                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2753         } else {
2754                 DO_ASSERT(get_jenv_res == JNI_OK);
2755         }
2756         LDKHolderCommitmentTransaction holder_tx_var = *holder_tx;
2757         uint64_t holder_tx_ref = 0;
2758         holder_tx_var = HolderCommitmentTransaction_clone(holder_tx);
2759         CHECK((((uint64_t)holder_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2760         CHECK((((uint64_t)&holder_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2761         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_var);
2762         holder_tx_ref = (uint64_t)holder_tx_var.inner;
2763         if (holder_tx_var.is_owned) {
2764                 holder_tx_ref |= 1;
2765         }
2766         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2767         CHECK(obj != NULL);
2768         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_holder_commitment_meth, holder_tx_ref);
2769         if ((*env)->ExceptionCheck(env)) {
2770                 (*env)->ExceptionDescribe(env);
2771                 (*env)->FatalError(env, "A call to validate_holder_commitment in LDKBaseSign from rust threw an exception.");
2772         }
2773         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2774         CHECK_ACCESS(ret_ptr);
2775         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2776         FREE((void*)ret);
2777         if (get_jenv_res == JNI_EDETACHED) {
2778                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2779         }
2780         return ret_conv;
2781 }
2782 LDKThirtyTwoBytes channel_keys_id_LDKBaseSign_jcall(const void* this_arg) {
2783         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2784         JNIEnv *env;
2785         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2786         if (get_jenv_res == JNI_EDETACHED) {
2787                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2788         } else {
2789                 DO_ASSERT(get_jenv_res == JNI_OK);
2790         }
2791         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2792         CHECK(obj != NULL);
2793         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->channel_keys_id_meth);
2794         if ((*env)->ExceptionCheck(env)) {
2795                 (*env)->ExceptionDescribe(env);
2796                 (*env)->FatalError(env, "A call to channel_keys_id in LDKBaseSign from rust threw an exception.");
2797         }
2798         LDKThirtyTwoBytes ret_ref;
2799         CHECK((*env)->GetArrayLength(env, ret) == 32);
2800         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
2801         if (get_jenv_res == JNI_EDETACHED) {
2802                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2803         }
2804         return ret_ref;
2805 }
2806 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_counterparty_commitment_LDKBaseSign_jcall(const void* this_arg, const LDKCommitmentTransaction * commitment_tx) {
2807         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2808         JNIEnv *env;
2809         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2810         if (get_jenv_res == JNI_EDETACHED) {
2811                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2812         } else {
2813                 DO_ASSERT(get_jenv_res == JNI_OK);
2814         }
2815         LDKCommitmentTransaction commitment_tx_var = *commitment_tx;
2816         uint64_t commitment_tx_ref = 0;
2817         commitment_tx_var = CommitmentTransaction_clone(commitment_tx);
2818         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2819         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2820         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2821         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2822         if (commitment_tx_var.is_owned) {
2823                 commitment_tx_ref |= 1;
2824         }
2825         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2826         CHECK(obj != NULL);
2827         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_counterparty_commitment_meth, commitment_tx_ref);
2828         if ((*env)->ExceptionCheck(env)) {
2829                 (*env)->ExceptionDescribe(env);
2830                 (*env)->FatalError(env, "A call to sign_counterparty_commitment in LDKBaseSign from rust threw an exception.");
2831         }
2832         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2833         CHECK_ACCESS(ret_ptr);
2834         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2835         FREE((void*)ret);
2836         if (get_jenv_res == JNI_EDETACHED) {
2837                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2838         }
2839         return ret_conv;
2840 }
2841 LDKCResult_NoneNoneZ validate_counterparty_revocation_LDKBaseSign_jcall(const void* this_arg, uint64_t idx, const uint8_t (* secret)[32]) {
2842         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2843         JNIEnv *env;
2844         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2845         if (get_jenv_res == JNI_EDETACHED) {
2846                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2847         } else {
2848                 DO_ASSERT(get_jenv_res == JNI_OK);
2849         }
2850         int8_tArray secret_arr = (*env)->NewByteArray(env, 32);
2851         (*env)->SetByteArrayRegion(env, secret_arr, 0, 32, *secret);
2852         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2853         CHECK(obj != NULL);
2854         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->validate_counterparty_revocation_meth, idx, secret_arr);
2855         if ((*env)->ExceptionCheck(env)) {
2856                 (*env)->ExceptionDescribe(env);
2857                 (*env)->FatalError(env, "A call to validate_counterparty_revocation in LDKBaseSign from rust threw an exception.");
2858         }
2859         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2860         CHECK_ACCESS(ret_ptr);
2861         LDKCResult_NoneNoneZ ret_conv = *(LDKCResult_NoneNoneZ*)(ret_ptr);
2862         FREE((void*)ret);
2863         if (get_jenv_res == JNI_EDETACHED) {
2864                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2865         }
2866         return ret_conv;
2867 }
2868 LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ sign_holder_commitment_and_htlcs_LDKBaseSign_jcall(const void* this_arg, const LDKHolderCommitmentTransaction * commitment_tx) {
2869         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2870         JNIEnv *env;
2871         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2872         if (get_jenv_res == JNI_EDETACHED) {
2873                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2874         } else {
2875                 DO_ASSERT(get_jenv_res == JNI_OK);
2876         }
2877         LDKHolderCommitmentTransaction commitment_tx_var = *commitment_tx;
2878         uint64_t commitment_tx_ref = 0;
2879         commitment_tx_var = HolderCommitmentTransaction_clone(commitment_tx);
2880         CHECK((((uint64_t)commitment_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2881         CHECK((((uint64_t)&commitment_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2882         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_var);
2883         commitment_tx_ref = (uint64_t)commitment_tx_var.inner;
2884         if (commitment_tx_var.is_owned) {
2885                 commitment_tx_ref |= 1;
2886         }
2887         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2888         CHECK(obj != NULL);
2889         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_holder_commitment_and_htlcs_meth, commitment_tx_ref);
2890         if ((*env)->ExceptionCheck(env)) {
2891                 (*env)->ExceptionDescribe(env);
2892                 (*env)->FatalError(env, "A call to sign_holder_commitment_and_htlcs in LDKBaseSign from rust threw an exception.");
2893         }
2894         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2895         CHECK_ACCESS(ret_ptr);
2896         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ ret_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(ret_ptr);
2897         FREE((void*)ret);
2898         if (get_jenv_res == JNI_EDETACHED) {
2899                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2900         }
2901         return ret_conv;
2902 }
2903 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]) {
2904         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2905         JNIEnv *env;
2906         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2907         if (get_jenv_res == JNI_EDETACHED) {
2908                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2909         } else {
2910                 DO_ASSERT(get_jenv_res == JNI_OK);
2911         }
2912         LDKTransaction justice_tx_var = justice_tx;
2913         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2914         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2915         Transaction_free(justice_tx_var);
2916         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2917         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2918         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2919         CHECK(obj != NULL);
2920         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_justice_revoked_output_meth, justice_tx_arr, input, amount, per_commitment_key_arr);
2921         if ((*env)->ExceptionCheck(env)) {
2922                 (*env)->ExceptionDescribe(env);
2923                 (*env)->FatalError(env, "A call to sign_justice_revoked_output in LDKBaseSign from rust threw an exception.");
2924         }
2925         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2926         CHECK_ACCESS(ret_ptr);
2927         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2928         FREE((void*)ret);
2929         if (get_jenv_res == JNI_EDETACHED) {
2930                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2931         }
2932         return ret_conv;
2933 }
2934 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) {
2935         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2936         JNIEnv *env;
2937         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2938         if (get_jenv_res == JNI_EDETACHED) {
2939                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2940         } else {
2941                 DO_ASSERT(get_jenv_res == JNI_OK);
2942         }
2943         LDKTransaction justice_tx_var = justice_tx;
2944         int8_tArray justice_tx_arr = (*env)->NewByteArray(env, justice_tx_var.datalen);
2945         (*env)->SetByteArrayRegion(env, justice_tx_arr, 0, justice_tx_var.datalen, justice_tx_var.data);
2946         Transaction_free(justice_tx_var);
2947         int8_tArray per_commitment_key_arr = (*env)->NewByteArray(env, 32);
2948         (*env)->SetByteArrayRegion(env, per_commitment_key_arr, 0, 32, *per_commitment_key);
2949         LDKHTLCOutputInCommitment htlc_var = *htlc;
2950         uint64_t htlc_ref = 0;
2951         htlc_var = HTLCOutputInCommitment_clone(htlc);
2952         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2953         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2954         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2955         htlc_ref = (uint64_t)htlc_var.inner;
2956         if (htlc_var.is_owned) {
2957                 htlc_ref |= 1;
2958         }
2959         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
2960         CHECK(obj != NULL);
2961         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);
2962         if ((*env)->ExceptionCheck(env)) {
2963                 (*env)->ExceptionDescribe(env);
2964                 (*env)->FatalError(env, "A call to sign_justice_revoked_htlc in LDKBaseSign from rust threw an exception.");
2965         }
2966         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
2967         CHECK_ACCESS(ret_ptr);
2968         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
2969         FREE((void*)ret);
2970         if (get_jenv_res == JNI_EDETACHED) {
2971                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
2972         }
2973         return ret_conv;
2974 }
2975 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) {
2976         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
2977         JNIEnv *env;
2978         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
2979         if (get_jenv_res == JNI_EDETACHED) {
2980                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
2981         } else {
2982                 DO_ASSERT(get_jenv_res == JNI_OK);
2983         }
2984         LDKTransaction htlc_tx_var = htlc_tx;
2985         int8_tArray htlc_tx_arr = (*env)->NewByteArray(env, htlc_tx_var.datalen);
2986         (*env)->SetByteArrayRegion(env, htlc_tx_arr, 0, htlc_tx_var.datalen, htlc_tx_var.data);
2987         Transaction_free(htlc_tx_var);
2988         int8_tArray per_commitment_point_arr = (*env)->NewByteArray(env, 33);
2989         (*env)->SetByteArrayRegion(env, per_commitment_point_arr, 0, 33, per_commitment_point.compressed_form);
2990         LDKHTLCOutputInCommitment htlc_var = *htlc;
2991         uint64_t htlc_ref = 0;
2992         htlc_var = HTLCOutputInCommitment_clone(htlc);
2993         CHECK((((uint64_t)htlc_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
2994         CHECK((((uint64_t)&htlc_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
2995         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_var);
2996         htlc_ref = (uint64_t)htlc_var.inner;
2997         if (htlc_var.is_owned) {
2998                 htlc_ref |= 1;
2999         }
3000         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3001         CHECK(obj != NULL);
3002         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);
3003         if ((*env)->ExceptionCheck(env)) {
3004                 (*env)->ExceptionDescribe(env);
3005                 (*env)->FatalError(env, "A call to sign_counterparty_htlc_transaction in LDKBaseSign from rust threw an exception.");
3006         }
3007         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3008         CHECK_ACCESS(ret_ptr);
3009         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3010         FREE((void*)ret);
3011         if (get_jenv_res == JNI_EDETACHED) {
3012                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3013         }
3014         return ret_conv;
3015 }
3016 LDKCResult_SignatureNoneZ sign_closing_transaction_LDKBaseSign_jcall(const void* this_arg, const LDKClosingTransaction * closing_tx) {
3017         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3018         JNIEnv *env;
3019         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3020         if (get_jenv_res == JNI_EDETACHED) {
3021                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3022         } else {
3023                 DO_ASSERT(get_jenv_res == JNI_OK);
3024         }
3025         LDKClosingTransaction closing_tx_var = *closing_tx;
3026         uint64_t closing_tx_ref = 0;
3027         closing_tx_var = ClosingTransaction_clone(closing_tx);
3028         CHECK((((uint64_t)closing_tx_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3029         CHECK((((uint64_t)&closing_tx_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3030         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_var);
3031         closing_tx_ref = (uint64_t)closing_tx_var.inner;
3032         if (closing_tx_var.is_owned) {
3033                 closing_tx_ref |= 1;
3034         }
3035         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3036         CHECK(obj != NULL);
3037         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_closing_transaction_meth, closing_tx_ref);
3038         if ((*env)->ExceptionCheck(env)) {
3039                 (*env)->ExceptionDescribe(env);
3040                 (*env)->FatalError(env, "A call to sign_closing_transaction in LDKBaseSign from rust threw an exception.");
3041         }
3042         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3043         CHECK_ACCESS(ret_ptr);
3044         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3045         FREE((void*)ret);
3046         if (get_jenv_res == JNI_EDETACHED) {
3047                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3048         }
3049         return ret_conv;
3050 }
3051 LDKCResult_SignatureNoneZ sign_channel_announcement_LDKBaseSign_jcall(const void* this_arg, const LDKUnsignedChannelAnnouncement * msg) {
3052         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3053         JNIEnv *env;
3054         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3055         if (get_jenv_res == JNI_EDETACHED) {
3056                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3057         } else {
3058                 DO_ASSERT(get_jenv_res == JNI_OK);
3059         }
3060         LDKUnsignedChannelAnnouncement msg_var = *msg;
3061         uint64_t msg_ref = 0;
3062         msg_var = UnsignedChannelAnnouncement_clone(msg);
3063         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3064         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3065         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
3066         msg_ref = (uint64_t)msg_var.inner;
3067         if (msg_var.is_owned) {
3068                 msg_ref |= 1;
3069         }
3070         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3071         CHECK(obj != NULL);
3072         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_channel_announcement_meth, msg_ref);
3073         if ((*env)->ExceptionCheck(env)) {
3074                 (*env)->ExceptionDescribe(env);
3075                 (*env)->FatalError(env, "A call to sign_channel_announcement in LDKBaseSign from rust threw an exception.");
3076         }
3077         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
3078         CHECK_ACCESS(ret_ptr);
3079         LDKCResult_SignatureNoneZ ret_conv = *(LDKCResult_SignatureNoneZ*)(ret_ptr);
3080         FREE((void*)ret);
3081         if (get_jenv_res == JNI_EDETACHED) {
3082                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3083         }
3084         return ret_conv;
3085 }
3086 void ready_channel_LDKBaseSign_jcall(void* this_arg, const LDKChannelTransactionParameters * channel_parameters) {
3087         LDKBaseSign_JCalls *j_calls = (LDKBaseSign_JCalls*) this_arg;
3088         JNIEnv *env;
3089         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3090         if (get_jenv_res == JNI_EDETACHED) {
3091                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3092         } else {
3093                 DO_ASSERT(get_jenv_res == JNI_OK);
3094         }
3095         LDKChannelTransactionParameters channel_parameters_var = *channel_parameters;
3096         uint64_t channel_parameters_ref = 0;
3097         channel_parameters_var = ChannelTransactionParameters_clone(channel_parameters);
3098         CHECK((((uint64_t)channel_parameters_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3099         CHECK((((uint64_t)&channel_parameters_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3100         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_var);
3101         channel_parameters_ref = (uint64_t)channel_parameters_var.inner;
3102         if (channel_parameters_var.is_owned) {
3103                 channel_parameters_ref |= 1;
3104         }
3105         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3106         CHECK(obj != NULL);
3107         (*env)->CallVoidMethod(env, obj, j_calls->ready_channel_meth, channel_parameters_ref);
3108         if ((*env)->ExceptionCheck(env)) {
3109                 (*env)->ExceptionDescribe(env);
3110                 (*env)->FatalError(env, "A call to ready_channel in LDKBaseSign from rust threw an exception.");
3111         }
3112         if (get_jenv_res == JNI_EDETACHED) {
3113                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3114         }
3115 }
3116 static inline LDKBaseSign LDKBaseSign_init (JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3117         jclass c = (*env)->GetObjectClass(env, o);
3118         CHECK(c != NULL);
3119         LDKBaseSign_JCalls *calls = MALLOC(sizeof(LDKBaseSign_JCalls), "LDKBaseSign_JCalls");
3120         atomic_init(&calls->refcnt, 1);
3121         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3122         calls->o = (*env)->NewWeakGlobalRef(env, o);
3123         calls->get_per_commitment_point_meth = (*env)->GetMethodID(env, c, "get_per_commitment_point", "(J)[B");
3124         CHECK(calls->get_per_commitment_point_meth != NULL);
3125         calls->release_commitment_secret_meth = (*env)->GetMethodID(env, c, "release_commitment_secret", "(J)[B");
3126         CHECK(calls->release_commitment_secret_meth != NULL);
3127         calls->validate_holder_commitment_meth = (*env)->GetMethodID(env, c, "validate_holder_commitment", "(J)J");
3128         CHECK(calls->validate_holder_commitment_meth != NULL);
3129         calls->channel_keys_id_meth = (*env)->GetMethodID(env, c, "channel_keys_id", "()[B");
3130         CHECK(calls->channel_keys_id_meth != NULL);
3131         calls->sign_counterparty_commitment_meth = (*env)->GetMethodID(env, c, "sign_counterparty_commitment", "(J)J");
3132         CHECK(calls->sign_counterparty_commitment_meth != NULL);
3133         calls->validate_counterparty_revocation_meth = (*env)->GetMethodID(env, c, "validate_counterparty_revocation", "(J[B)J");
3134         CHECK(calls->validate_counterparty_revocation_meth != NULL);
3135         calls->sign_holder_commitment_and_htlcs_meth = (*env)->GetMethodID(env, c, "sign_holder_commitment_and_htlcs", "(J)J");
3136         CHECK(calls->sign_holder_commitment_and_htlcs_meth != NULL);
3137         calls->sign_justice_revoked_output_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_output", "([BJJ[B)J");
3138         CHECK(calls->sign_justice_revoked_output_meth != NULL);
3139         calls->sign_justice_revoked_htlc_meth = (*env)->GetMethodID(env, c, "sign_justice_revoked_htlc", "([BJJ[BJ)J");
3140         CHECK(calls->sign_justice_revoked_htlc_meth != NULL);
3141         calls->sign_counterparty_htlc_transaction_meth = (*env)->GetMethodID(env, c, "sign_counterparty_htlc_transaction", "([BJJ[BJ)J");
3142         CHECK(calls->sign_counterparty_htlc_transaction_meth != NULL);
3143         calls->sign_closing_transaction_meth = (*env)->GetMethodID(env, c, "sign_closing_transaction", "(J)J");
3144         CHECK(calls->sign_closing_transaction_meth != NULL);
3145         calls->sign_channel_announcement_meth = (*env)->GetMethodID(env, c, "sign_channel_announcement", "(J)J");
3146         CHECK(calls->sign_channel_announcement_meth != NULL);
3147         calls->ready_channel_meth = (*env)->GetMethodID(env, c, "ready_channel", "(J)V");
3148         CHECK(calls->ready_channel_meth != NULL);
3149
3150         LDKChannelPublicKeys pubkeys_conv;
3151         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3152         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3153         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3154
3155         LDKBaseSign ret = {
3156                 .this_arg = (void*) calls,
3157                 .get_per_commitment_point = get_per_commitment_point_LDKBaseSign_jcall,
3158                 .release_commitment_secret = release_commitment_secret_LDKBaseSign_jcall,
3159                 .validate_holder_commitment = validate_holder_commitment_LDKBaseSign_jcall,
3160                 .channel_keys_id = channel_keys_id_LDKBaseSign_jcall,
3161                 .sign_counterparty_commitment = sign_counterparty_commitment_LDKBaseSign_jcall,
3162                 .validate_counterparty_revocation = validate_counterparty_revocation_LDKBaseSign_jcall,
3163                 .sign_holder_commitment_and_htlcs = sign_holder_commitment_and_htlcs_LDKBaseSign_jcall,
3164                 .sign_justice_revoked_output = sign_justice_revoked_output_LDKBaseSign_jcall,
3165                 .sign_justice_revoked_htlc = sign_justice_revoked_htlc_LDKBaseSign_jcall,
3166                 .sign_counterparty_htlc_transaction = sign_counterparty_htlc_transaction_LDKBaseSign_jcall,
3167                 .sign_closing_transaction = sign_closing_transaction_LDKBaseSign_jcall,
3168                 .sign_channel_announcement = sign_channel_announcement_LDKBaseSign_jcall,
3169                 .ready_channel = ready_channel_LDKBaseSign_jcall,
3170                 .free = LDKBaseSign_JCalls_free,
3171                 .pubkeys = pubkeys_conv,
3172                 .set_pubkeys = NULL,
3173         };
3174         return ret;
3175 }
3176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBaseSign_1new(JNIEnv *env, jclass clz, jobject o, int64_t pubkeys) {
3177         LDKBaseSign *res_ptr = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
3178         *res_ptr = LDKBaseSign_init(env, clz, o, pubkeys);
3179         return (uint64_t)res_ptr;
3180 }
3181 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) {
3182         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3183         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3184         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3185         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
3186         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->get_per_commitment_point)(this_arg_conv->this_arg, idx).compressed_form);
3187         return ret_arr;
3188 }
3189
3190 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1release_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_arg, int64_t idx) {
3191         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3192         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3193         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3194         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3195         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->release_commitment_secret)(this_arg_conv->this_arg, idx).data);
3196         return ret_arr;
3197 }
3198
3199 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) {
3200         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3201         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3202         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3203         LDKHolderCommitmentTransaction holder_tx_conv;
3204         holder_tx_conv.inner = (void*)(holder_tx & (~1));
3205         holder_tx_conv.is_owned = false;
3206         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_tx_conv);
3207         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3208         *ret_conv = (this_arg_conv->validate_holder_commitment)(this_arg_conv->this_arg, &holder_tx_conv);
3209         return (uint64_t)ret_conv;
3210 }
3211
3212 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BaseSign_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
3213         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3214         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3215         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3216         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3217         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->channel_keys_id)(this_arg_conv->this_arg).data);
3218         return ret_arr;
3219 }
3220
3221 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) {
3222         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3223         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3224         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3225         LDKCommitmentTransaction commitment_tx_conv;
3226         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3227         commitment_tx_conv.is_owned = false;
3228         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3229         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3230         *ret_conv = (this_arg_conv->sign_counterparty_commitment)(this_arg_conv->this_arg, &commitment_tx_conv);
3231         return (uint64_t)ret_conv;
3232 }
3233
3234 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) {
3235         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3236         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3237         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3238         unsigned char secret_arr[32];
3239         CHECK((*env)->GetArrayLength(env, secret) == 32);
3240         (*env)->GetByteArrayRegion(env, secret, 0, 32, secret_arr);
3241         unsigned char (*secret_ref)[32] = &secret_arr;
3242         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
3243         *ret_conv = (this_arg_conv->validate_counterparty_revocation)(this_arg_conv->this_arg, idx, secret_ref);
3244         return (uint64_t)ret_conv;
3245 }
3246
3247 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) {
3248         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3249         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3250         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3251         LDKHolderCommitmentTransaction commitment_tx_conv;
3252         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
3253         commitment_tx_conv.is_owned = false;
3254         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
3255         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
3256         *ret_conv = (this_arg_conv->sign_holder_commitment_and_htlcs)(this_arg_conv->this_arg, &commitment_tx_conv);
3257         return (uint64_t)ret_conv;
3258 }
3259
3260 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) {
3261         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3262         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3263         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3264         LDKTransaction justice_tx_ref;
3265         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3266         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3267         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3268         justice_tx_ref.data_is_owned = true;
3269         unsigned char per_commitment_key_arr[32];
3270         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3271         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3272         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3273         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3274         *ret_conv = (this_arg_conv->sign_justice_revoked_output)(this_arg_conv->this_arg, justice_tx_ref, input, amount, per_commitment_key_ref);
3275         return (uint64_t)ret_conv;
3276 }
3277
3278 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) {
3279         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3280         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3281         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3282         LDKTransaction justice_tx_ref;
3283         justice_tx_ref.datalen = (*env)->GetArrayLength(env, justice_tx);
3284         justice_tx_ref.data = MALLOC(justice_tx_ref.datalen, "LDKTransaction Bytes");
3285         (*env)->GetByteArrayRegion(env, justice_tx, 0, justice_tx_ref.datalen, justice_tx_ref.data);
3286         justice_tx_ref.data_is_owned = true;
3287         unsigned char per_commitment_key_arr[32];
3288         CHECK((*env)->GetArrayLength(env, per_commitment_key) == 32);
3289         (*env)->GetByteArrayRegion(env, per_commitment_key, 0, 32, per_commitment_key_arr);
3290         unsigned char (*per_commitment_key_ref)[32] = &per_commitment_key_arr;
3291         LDKHTLCOutputInCommitment htlc_conv;
3292         htlc_conv.inner = (void*)(htlc & (~1));
3293         htlc_conv.is_owned = false;
3294         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3295         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3296         *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);
3297         return (uint64_t)ret_conv;
3298 }
3299
3300 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) {
3301         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3302         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3303         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3304         LDKTransaction htlc_tx_ref;
3305         htlc_tx_ref.datalen = (*env)->GetArrayLength(env, htlc_tx);
3306         htlc_tx_ref.data = MALLOC(htlc_tx_ref.datalen, "LDKTransaction Bytes");
3307         (*env)->GetByteArrayRegion(env, htlc_tx, 0, htlc_tx_ref.datalen, htlc_tx_ref.data);
3308         htlc_tx_ref.data_is_owned = true;
3309         LDKPublicKey per_commitment_point_ref;
3310         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
3311         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
3312         LDKHTLCOutputInCommitment htlc_conv;
3313         htlc_conv.inner = (void*)(htlc & (~1));
3314         htlc_conv.is_owned = false;
3315         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
3316         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3317         *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);
3318         return (uint64_t)ret_conv;
3319 }
3320
3321 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) {
3322         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3323         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3324         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3325         LDKClosingTransaction closing_tx_conv;
3326         closing_tx_conv.inner = (void*)(closing_tx & (~1));
3327         closing_tx_conv.is_owned = false;
3328         CHECK_INNER_FIELD_ACCESS_OR_NULL(closing_tx_conv);
3329         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3330         *ret_conv = (this_arg_conv->sign_closing_transaction)(this_arg_conv->this_arg, &closing_tx_conv);
3331         return (uint64_t)ret_conv;
3332 }
3333
3334 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1sign_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
3335         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3336         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3337         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3338         LDKUnsignedChannelAnnouncement msg_conv;
3339         msg_conv.inner = (void*)(msg & (~1));
3340         msg_conv.is_owned = false;
3341         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
3342         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
3343         *ret_conv = (this_arg_conv->sign_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
3344         return (uint64_t)ret_conv;
3345 }
3346
3347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1ready_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_parameters) {
3348         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3349         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3350         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3351         LDKChannelTransactionParameters channel_parameters_conv;
3352         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
3353         channel_parameters_conv.is_owned = false;
3354         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
3355         (this_arg_conv->ready_channel)(this_arg_conv->this_arg, &channel_parameters_conv);
3356 }
3357
3358 LDKChannelPublicKeys LDKBaseSign_set_get_pubkeys(LDKBaseSign* this_arg) {
3359         if (this_arg->set_pubkeys != NULL)
3360                 this_arg->set_pubkeys(this_arg);
3361         return this_arg->pubkeys;
3362 }
3363 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BaseSign_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
3364         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3365         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3366         LDKBaseSign* this_arg_conv = (LDKBaseSign*)this_arg_ptr;
3367         LDKChannelPublicKeys ret_var = LDKBaseSign_set_get_pubkeys(this_arg_conv);
3368         uint64_t ret_ref = 0;
3369         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3370         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3371         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3372         ret_ref = (uint64_t)ret_var.inner;
3373         if (ret_var.is_owned) {
3374                 ret_ref |= 1;
3375         }
3376         return ret_ref;
3377 }
3378
3379 typedef struct LDKSign_JCalls {
3380         atomic_size_t refcnt;
3381         JavaVM *vm;
3382         jweak o;
3383         LDKBaseSign_JCalls* BaseSign;
3384         jmethodID write_meth;
3385 } LDKSign_JCalls;
3386 static void LDKSign_JCalls_free(void* this_arg) {
3387         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3388         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
3389                 JNIEnv *env;
3390                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3391                 if (get_jenv_res == JNI_EDETACHED) {
3392                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3393                 } else {
3394                         DO_ASSERT(get_jenv_res == JNI_OK);
3395                 }
3396                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
3397                 if (get_jenv_res == JNI_EDETACHED) {
3398                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3399                 }
3400                 FREE(j_calls);
3401         }
3402 }
3403 LDKCVec_u8Z write_LDKSign_jcall(const void* this_arg) {
3404         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) this_arg;
3405         JNIEnv *env;
3406         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
3407         if (get_jenv_res == JNI_EDETACHED) {
3408                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
3409         } else {
3410                 DO_ASSERT(get_jenv_res == JNI_OK);
3411         }
3412         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
3413         CHECK(obj != NULL);
3414         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
3415         if ((*env)->ExceptionCheck(env)) {
3416                 (*env)->ExceptionDescribe(env);
3417                 (*env)->FatalError(env, "A call to write in LDKSign from rust threw an exception.");
3418         }
3419         LDKCVec_u8Z ret_ref;
3420         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
3421         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
3422         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
3423         if (get_jenv_res == JNI_EDETACHED) {
3424                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
3425         }
3426         return ret_ref;
3427 }
3428 static void LDKSign_JCalls_cloned(LDKSign* new_obj) {
3429         LDKSign_JCalls *j_calls = (LDKSign_JCalls*) new_obj->this_arg;
3430         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
3431         atomic_fetch_add_explicit(&j_calls->BaseSign->refcnt, 1, memory_order_release);
3432 }
3433 static inline LDKSign LDKSign_init (JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3434         jclass c = (*env)->GetObjectClass(env, o);
3435         CHECK(c != NULL);
3436         LDKSign_JCalls *calls = MALLOC(sizeof(LDKSign_JCalls), "LDKSign_JCalls");
3437         atomic_init(&calls->refcnt, 1);
3438         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
3439         calls->o = (*env)->NewWeakGlobalRef(env, o);
3440         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
3441         CHECK(calls->write_meth != NULL);
3442
3443         LDKChannelPublicKeys pubkeys_conv;
3444         pubkeys_conv.inner = (void*)(pubkeys & (~1));
3445         pubkeys_conv.is_owned = (pubkeys & 1) || (pubkeys == 0);
3446         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_conv);
3447
3448         LDKSign ret = {
3449                 .this_arg = (void*) calls,
3450                 .write = write_LDKSign_jcall,
3451                 .cloned = LDKSign_JCalls_cloned,
3452                 .free = LDKSign_JCalls_free,
3453                 .BaseSign = LDKBaseSign_init(env, clz, BaseSign, pubkeys),
3454         };
3455         calls->BaseSign = ret.BaseSign.this_arg;
3456         return ret;
3457 }
3458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1new(JNIEnv *env, jclass clz, jobject o, jobject BaseSign, int64_t pubkeys) {
3459         LDKSign *res_ptr = MALLOC(sizeof(LDKSign), "LDKSign");
3460         *res_ptr = LDKSign_init(env, clz, o, BaseSign, pubkeys);
3461         return (uint64_t)res_ptr;
3462 }
3463 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSign_1get_1BaseSign(JNIEnv *env, jclass clz, int64_t arg) {
3464         LDKSign *inp = (LDKSign *)(arg & ~1);
3465         uint64_t res_ptr = (uint64_t)&inp->BaseSign;
3466         DO_ASSERT((res_ptr & 1) == 0);
3467         return (int64_t)(res_ptr | 1);
3468 }
3469 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Sign_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
3470         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
3471         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
3472         LDKSign* this_arg_conv = (LDKSign*)this_arg_ptr;
3473         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
3474         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
3475         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
3476         CVec_u8Z_free(ret_var);
3477         return ret_arr;
3478 }
3479
3480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3481         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3482         CHECK(val->result_ok);
3483         LDKSign* res_ret = MALLOC(sizeof(LDKSign), "LDKSign");
3484         *res_ret = Sign_clone(&(*val->contents.result));
3485         return (uint64_t)res_ret;
3486 }
3487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3488         LDKCResult_SignDecodeErrorZ *val = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
3489         CHECK(!val->result_ok);
3490         LDKDecodeError err_var = (*val->contents.err);
3491         uint64_t err_ref = 0;
3492         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3493         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3494         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3495         err_ref = (uint64_t)err_var.inner & ~1;
3496         return err_ref;
3497 }
3498 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3499         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3500         CHECK(val->result_ok);
3501         int8_tArray es_arr = (*env)->NewByteArray(env, 68);
3502         (*env)->SetByteArrayRegion(env, es_arr, 0, 68, (*val->contents.result).serialized_form);
3503         return es_arr;
3504 }
3505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RecoverableSignatureNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3506         LDKCResult_RecoverableSignatureNoneZ *val = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
3507         CHECK(!val->result_ok);
3508         return *val->contents.err;
3509 }
3510 static inline LDKCVec_CVec_u8ZZ CVec_CVec_u8ZZ_clone(const LDKCVec_CVec_u8ZZ *orig) {
3511         LDKCVec_CVec_u8ZZ ret = { .data = MALLOC(sizeof(LDKCVec_u8Z) * orig->datalen, "LDKCVec_CVec_u8ZZ clone bytes"), .datalen = orig->datalen };
3512         for (size_t i = 0; i < ret.datalen; i++) {
3513                 ret.data[i] = CVec_u8Z_clone(&orig->data[i]);
3514         }
3515         return ret;
3516 }
3517 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3518         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3519         CHECK(val->result_ok);
3520         LDKCVec_CVec_u8ZZ res_var = (*val->contents.result);
3521         jobjectArray res_arr = NULL;
3522         res_arr = (*env)->NewObjectArray(env, res_var.datalen, arr_of_B_clz, NULL);
3523         ;
3524         for (size_t i = 0; i < res_var.datalen; i++) {
3525                 LDKCVec_u8Z res_conv_8_var = res_var.data[i];
3526                 int8_tArray res_conv_8_arr = (*env)->NewByteArray(env, res_conv_8_var.datalen);
3527                 (*env)->SetByteArrayRegion(env, res_conv_8_arr, 0, res_conv_8_var.datalen, res_conv_8_var.data);
3528                 (*env)->SetObjectArrayElement(env, res_arr, i, res_conv_8_arr);
3529         }
3530         
3531         return res_arr;
3532 }
3533 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1CVec_1u8ZZNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3534         LDKCResult_CVec_CVec_u8ZZNoneZ *val = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
3535         CHECK(!val->result_ok);
3536         return *val->contents.err;
3537 }
3538 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3539         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3540         CHECK(val->result_ok);
3541         LDKInMemorySigner res_var = (*val->contents.result);
3542         uint64_t res_ref = 0;
3543         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3544         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3545         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
3546         res_ref = (uint64_t)res_var.inner & ~1;
3547         return res_ref;
3548 }
3549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InMemorySignerDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3550         LDKCResult_InMemorySignerDecodeErrorZ *val = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
3551         CHECK(!val->result_ok);
3552         LDKDecodeError err_var = (*val->contents.err);
3553         uint64_t err_ref = 0;
3554         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3555         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3556         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
3557         err_ref = (uint64_t)err_var.inner & ~1;
3558         return err_ref;
3559 }
3560 static inline LDKCVec_TxOutZ CVec_TxOutZ_clone(const LDKCVec_TxOutZ *orig) {
3561         LDKCVec_TxOutZ ret = { .data = MALLOC(sizeof(LDKTxOut) * orig->datalen, "LDKCVec_TxOutZ clone bytes"), .datalen = orig->datalen };
3562         for (size_t i = 0; i < ret.datalen; i++) {
3563                 ret.data[i] = TxOut_clone(&orig->data[i]);
3564         }
3565         return ret;
3566 }
3567 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3568         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3569         CHECK(val->result_ok);
3570         LDKTransaction res_var = (*val->contents.result);
3571         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
3572         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
3573         return res_arr;
3574 }
3575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1TransactionNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3576         LDKCResult_TransactionNoneZ *val = (LDKCResult_TransactionNoneZ*)(arg & ~1);
3577         CHECK(!val->result_ok);
3578         return *val->contents.err;
3579 }
3580 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelMonitorZ_get_a(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3581         return ThirtyTwoBytes_clone(&tuple->a);
3582 }
3583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3584         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3585         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3586         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelMonitorZ_get_a(tuple_conv).data);
3587         return ret_arr;
3588 }
3589
3590 static inline struct LDKChannelMonitor C2Tuple_BlockHashChannelMonitorZ_get_b(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR tuple){
3591         return ChannelMonitor_clone(&tuple->b);
3592 }
3593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3594         LDKC2Tuple_BlockHashChannelMonitorZ* tuple_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(tuple & ~1);
3595         LDKChannelMonitor ret_var = C2Tuple_BlockHashChannelMonitorZ_get_b(tuple_conv);
3596         uint64_t ret_ref = 0;
3597         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3598         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3599         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
3600         ret_ref = (uint64_t)ret_var.inner;
3601         if (ret_var.is_owned) {
3602                 ret_ref |= 1;
3603         }
3604         return ret_ref;
3605 }
3606
3607 static inline LDKCVec_C2Tuple_BlockHashChannelMonitorZZ CVec_C2Tuple_BlockHashChannelMonitorZZ_clone(const LDKCVec_C2Tuple_BlockHashChannelMonitorZZ *orig) {
3608         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ) * orig->datalen, "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ clone bytes"), .datalen = orig->datalen };
3609         for (size_t i = 0; i < ret.datalen; i++) {
3610                 ret.data[i] = C2Tuple_BlockHashChannelMonitorZ_clone(&orig->data[i]);
3611         }
3612         return ret;
3613 }
3614 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3615         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3616         CHECK(val->result_ok);
3617         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ res_var = (*val->contents.result);
3618         int64_tArray res_arr = NULL;
3619         res_arr = (*env)->NewLongArray(env, res_var.datalen);
3620         int64_t *res_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, res_arr, NULL);
3621         for (size_t j = 0; j < res_var.datalen; j++) {
3622                 LDKC2Tuple_BlockHashChannelMonitorZ* res_conv_35_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
3623                 *res_conv_35_conv = res_var.data[j];
3624                 *res_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv_35_conv);
3625                 res_arr_ptr[j] = ((uint64_t)res_conv_35_conv);
3626         }
3627         (*env)->ReleasePrimitiveArrayCritical(env, res_arr, res_arr_ptr, 0);
3628         return res_arr;
3629 }
3630 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3631         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *val = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
3632         CHECK(!val->result_ok);
3633         jclass err_conv = LDKIOError_to_java(env, (*val->contents.err));
3634         return err_conv;
3635 }
3636 static jclass LDKCOption_u16Z_Some_class = NULL;
3637 static jmethodID LDKCOption_u16Z_Some_meth = NULL;
3638 static jclass LDKCOption_u16Z_None_class = NULL;
3639 static jmethodID LDKCOption_u16Z_None_meth = NULL;
3640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1u16Z_init (JNIEnv *env, jclass clz) {
3641         LDKCOption_u16Z_Some_class =
3642                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$Some;"));
3643         CHECK(LDKCOption_u16Z_Some_class != NULL);
3644         LDKCOption_u16Z_Some_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_Some_class, "<init>", "(S)V");
3645         CHECK(LDKCOption_u16Z_Some_meth != NULL);
3646         LDKCOption_u16Z_None_class =
3647                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_u16Z$None;"));
3648         CHECK(LDKCOption_u16Z_None_class != NULL);
3649         LDKCOption_u16Z_None_meth = (*env)->GetMethodID(env, LDKCOption_u16Z_None_class, "<init>", "()V");
3650         CHECK(LDKCOption_u16Z_None_meth != NULL);
3651 }
3652 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1u16Z_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3653         LDKCOption_u16Z *obj = (LDKCOption_u16Z*)(ptr & ~1);
3654         switch(obj->tag) {
3655                 case LDKCOption_u16Z_Some: {
3656                         return (*env)->NewObject(env, LDKCOption_u16Z_Some_class, LDKCOption_u16Z_Some_meth, obj->some);
3657                 }
3658                 case LDKCOption_u16Z_None: {
3659                         return (*env)->NewObject(env, LDKCOption_u16Z_None_class, LDKCOption_u16Z_None_meth);
3660                 }
3661                 default: abort();
3662         }
3663 }
3664 static jclass LDKAPIError_APIMisuseError_class = NULL;
3665 static jmethodID LDKAPIError_APIMisuseError_meth = NULL;
3666 static jclass LDKAPIError_FeeRateTooHigh_class = NULL;
3667 static jmethodID LDKAPIError_FeeRateTooHigh_meth = NULL;
3668 static jclass LDKAPIError_RouteError_class = NULL;
3669 static jmethodID LDKAPIError_RouteError_meth = NULL;
3670 static jclass LDKAPIError_ChannelUnavailable_class = NULL;
3671 static jmethodID LDKAPIError_ChannelUnavailable_meth = NULL;
3672 static jclass LDKAPIError_MonitorUpdateFailed_class = NULL;
3673 static jmethodID LDKAPIError_MonitorUpdateFailed_meth = NULL;
3674 static jclass LDKAPIError_IncompatibleShutdownScript_class = NULL;
3675 static jmethodID LDKAPIError_IncompatibleShutdownScript_meth = NULL;
3676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKAPIError_init (JNIEnv *env, jclass clz) {
3677         LDKAPIError_APIMisuseError_class =
3678                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$APIMisuseError;"));
3679         CHECK(LDKAPIError_APIMisuseError_class != NULL);
3680         LDKAPIError_APIMisuseError_meth = (*env)->GetMethodID(env, LDKAPIError_APIMisuseError_class, "<init>", "(Ljava/lang/String;)V");
3681         CHECK(LDKAPIError_APIMisuseError_meth != NULL);
3682         LDKAPIError_FeeRateTooHigh_class =
3683                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$FeeRateTooHigh;"));
3684         CHECK(LDKAPIError_FeeRateTooHigh_class != NULL);
3685         LDKAPIError_FeeRateTooHigh_meth = (*env)->GetMethodID(env, LDKAPIError_FeeRateTooHigh_class, "<init>", "(Ljava/lang/String;I)V");
3686         CHECK(LDKAPIError_FeeRateTooHigh_meth != NULL);
3687         LDKAPIError_RouteError_class =
3688                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$RouteError;"));
3689         CHECK(LDKAPIError_RouteError_class != NULL);
3690         LDKAPIError_RouteError_meth = (*env)->GetMethodID(env, LDKAPIError_RouteError_class, "<init>", "(Ljava/lang/String;)V");
3691         CHECK(LDKAPIError_RouteError_meth != NULL);
3692         LDKAPIError_ChannelUnavailable_class =
3693                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$ChannelUnavailable;"));
3694         CHECK(LDKAPIError_ChannelUnavailable_class != NULL);
3695         LDKAPIError_ChannelUnavailable_meth = (*env)->GetMethodID(env, LDKAPIError_ChannelUnavailable_class, "<init>", "(Ljava/lang/String;)V");
3696         CHECK(LDKAPIError_ChannelUnavailable_meth != NULL);
3697         LDKAPIError_MonitorUpdateFailed_class =
3698                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$MonitorUpdateFailed;"));
3699         CHECK(LDKAPIError_MonitorUpdateFailed_class != NULL);
3700         LDKAPIError_MonitorUpdateFailed_meth = (*env)->GetMethodID(env, LDKAPIError_MonitorUpdateFailed_class, "<init>", "()V");
3701         CHECK(LDKAPIError_MonitorUpdateFailed_meth != NULL);
3702         LDKAPIError_IncompatibleShutdownScript_class =
3703                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKAPIError$IncompatibleShutdownScript;"));
3704         CHECK(LDKAPIError_IncompatibleShutdownScript_class != NULL);
3705         LDKAPIError_IncompatibleShutdownScript_meth = (*env)->GetMethodID(env, LDKAPIError_IncompatibleShutdownScript_class, "<init>", "(J)V");
3706         CHECK(LDKAPIError_IncompatibleShutdownScript_meth != NULL);
3707 }
3708 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKAPIError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3709         LDKAPIError *obj = (LDKAPIError*)(ptr & ~1);
3710         switch(obj->tag) {
3711                 case LDKAPIError_APIMisuseError: {
3712                         LDKStr err_str = obj->api_misuse_error.err;
3713                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3714                         return (*env)->NewObject(env, LDKAPIError_APIMisuseError_class, LDKAPIError_APIMisuseError_meth, err_conv);
3715                 }
3716                 case LDKAPIError_FeeRateTooHigh: {
3717                         LDKStr err_str = obj->fee_rate_too_high.err;
3718                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3719                         return (*env)->NewObject(env, LDKAPIError_FeeRateTooHigh_class, LDKAPIError_FeeRateTooHigh_meth, err_conv, obj->fee_rate_too_high.feerate);
3720                 }
3721                 case LDKAPIError_RouteError: {
3722                         LDKStr err_str = obj->route_error.err;
3723                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3724                         return (*env)->NewObject(env, LDKAPIError_RouteError_class, LDKAPIError_RouteError_meth, err_conv);
3725                 }
3726                 case LDKAPIError_ChannelUnavailable: {
3727                         LDKStr err_str = obj->channel_unavailable.err;
3728                         jstring err_conv = str_ref_to_java(env, err_str.chars, err_str.len);
3729                         return (*env)->NewObject(env, LDKAPIError_ChannelUnavailable_class, LDKAPIError_ChannelUnavailable_meth, err_conv);
3730                 }
3731                 case LDKAPIError_MonitorUpdateFailed: {
3732                         return (*env)->NewObject(env, LDKAPIError_MonitorUpdateFailed_class, LDKAPIError_MonitorUpdateFailed_meth);
3733                 }
3734                 case LDKAPIError_IncompatibleShutdownScript: {
3735                         LDKShutdownScript script_var = obj->incompatible_shutdown_script.script;
3736                         uint64_t script_ref = 0;
3737                         CHECK((((uint64_t)script_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3738                         CHECK((((uint64_t)&script_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3739                         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_var);
3740                         script_ref = (uint64_t)script_var.inner & ~1;
3741                         return (*env)->NewObject(env, LDKAPIError_IncompatibleShutdownScript_class, LDKAPIError_IncompatibleShutdownScript_meth, script_ref);
3742                 }
3743                 default: abort();
3744         }
3745 }
3746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3747         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3748         CHECK(val->result_ok);
3749         return *val->contents.result;
3750 }
3751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3752         LDKCResult_NoneAPIErrorZ *val = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
3753         CHECK(!val->result_ok);
3754         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3755         return err_ref;
3756 }
3757 static inline LDKCVec_CResult_NoneAPIErrorZZ CVec_CResult_NoneAPIErrorZZ_clone(const LDKCVec_CResult_NoneAPIErrorZZ *orig) {
3758         LDKCVec_CResult_NoneAPIErrorZZ ret = { .data = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ) * orig->datalen, "LDKCVec_CResult_NoneAPIErrorZZ clone bytes"), .datalen = orig->datalen };
3759         for (size_t i = 0; i < ret.datalen; i++) {
3760                 ret.data[i] = CResult_NoneAPIErrorZ_clone(&orig->data[i]);
3761         }
3762         return ret;
3763 }
3764 static inline LDKCVec_APIErrorZ CVec_APIErrorZ_clone(const LDKCVec_APIErrorZ *orig) {
3765         LDKCVec_APIErrorZ ret = { .data = MALLOC(sizeof(LDKAPIError) * orig->datalen, "LDKCVec_APIErrorZ clone bytes"), .datalen = orig->datalen };
3766         for (size_t i = 0; i < ret.datalen; i++) {
3767                 ret.data[i] = APIError_clone(&orig->data[i]);
3768         }
3769         return ret;
3770 }
3771 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3772         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3773         CHECK(val->result_ok);
3774         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3775         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3776         return res_arr;
3777 }
3778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1_1u832APIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3779         LDKCResult__u832APIErrorZ *val = (LDKCResult__u832APIErrorZ*)(arg & ~1);
3780         CHECK(!val->result_ok);
3781         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3782         return err_ref;
3783 }
3784 static jclass LDKPaymentSendFailure_ParameterError_class = NULL;
3785 static jmethodID LDKPaymentSendFailure_ParameterError_meth = NULL;
3786 static jclass LDKPaymentSendFailure_PathParameterError_class = NULL;
3787 static jmethodID LDKPaymentSendFailure_PathParameterError_meth = NULL;
3788 static jclass LDKPaymentSendFailure_AllFailedRetrySafe_class = NULL;
3789 static jmethodID LDKPaymentSendFailure_AllFailedRetrySafe_meth = NULL;
3790 static jclass LDKPaymentSendFailure_PartialFailure_class = NULL;
3791 static jmethodID LDKPaymentSendFailure_PartialFailure_meth = NULL;
3792 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentSendFailure_init (JNIEnv *env, jclass clz) {
3793         LDKPaymentSendFailure_ParameterError_class =
3794                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$ParameterError;"));
3795         CHECK(LDKPaymentSendFailure_ParameterError_class != NULL);
3796         LDKPaymentSendFailure_ParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_ParameterError_class, "<init>", "(J)V");
3797         CHECK(LDKPaymentSendFailure_ParameterError_meth != NULL);
3798         LDKPaymentSendFailure_PathParameterError_class =
3799                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PathParameterError;"));
3800         CHECK(LDKPaymentSendFailure_PathParameterError_class != NULL);
3801         LDKPaymentSendFailure_PathParameterError_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PathParameterError_class, "<init>", "([J)V");
3802         CHECK(LDKPaymentSendFailure_PathParameterError_meth != NULL);
3803         LDKPaymentSendFailure_AllFailedRetrySafe_class =
3804                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$AllFailedRetrySafe;"));
3805         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_class != NULL);
3806         LDKPaymentSendFailure_AllFailedRetrySafe_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, "<init>", "([J)V");
3807         CHECK(LDKPaymentSendFailure_AllFailedRetrySafe_meth != NULL);
3808         LDKPaymentSendFailure_PartialFailure_class =
3809                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentSendFailure$PartialFailure;"));
3810         CHECK(LDKPaymentSendFailure_PartialFailure_class != NULL);
3811         LDKPaymentSendFailure_PartialFailure_meth = (*env)->GetMethodID(env, LDKPaymentSendFailure_PartialFailure_class, "<init>", "([JJ[B)V");
3812         CHECK(LDKPaymentSendFailure_PartialFailure_meth != NULL);
3813 }
3814 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentSendFailure_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3815         LDKPaymentSendFailure *obj = (LDKPaymentSendFailure*)(ptr & ~1);
3816         switch(obj->tag) {
3817                 case LDKPaymentSendFailure_ParameterError: {
3818                         uint64_t parameter_error_ref = ((uint64_t)&obj->parameter_error) | 1;
3819                         return (*env)->NewObject(env, LDKPaymentSendFailure_ParameterError_class, LDKPaymentSendFailure_ParameterError_meth, parameter_error_ref);
3820                 }
3821                 case LDKPaymentSendFailure_PathParameterError: {
3822                         LDKCVec_CResult_NoneAPIErrorZZ path_parameter_error_var = obj->path_parameter_error;
3823                         int64_tArray path_parameter_error_arr = NULL;
3824                         path_parameter_error_arr = (*env)->NewLongArray(env, path_parameter_error_var.datalen);
3825                         int64_t *path_parameter_error_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_parameter_error_arr, NULL);
3826                         for (size_t w = 0; w < path_parameter_error_var.datalen; w++) {
3827                                 LDKCResult_NoneAPIErrorZ* path_parameter_error_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3828                                 *path_parameter_error_conv_22_conv = path_parameter_error_var.data[w];
3829                                 *path_parameter_error_conv_22_conv = CResult_NoneAPIErrorZ_clone(path_parameter_error_conv_22_conv);
3830                                 path_parameter_error_arr_ptr[w] = (uint64_t)path_parameter_error_conv_22_conv;
3831                         }
3832                         (*env)->ReleasePrimitiveArrayCritical(env, path_parameter_error_arr, path_parameter_error_arr_ptr, 0);
3833                         return (*env)->NewObject(env, LDKPaymentSendFailure_PathParameterError_class, LDKPaymentSendFailure_PathParameterError_meth, path_parameter_error_arr);
3834                 }
3835                 case LDKPaymentSendFailure_AllFailedRetrySafe: {
3836                         LDKCVec_APIErrorZ all_failed_retry_safe_var = obj->all_failed_retry_safe;
3837                         int64_tArray all_failed_retry_safe_arr = NULL;
3838                         all_failed_retry_safe_arr = (*env)->NewLongArray(env, all_failed_retry_safe_var.datalen);
3839                         int64_t *all_failed_retry_safe_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, all_failed_retry_safe_arr, NULL);
3840                         for (size_t k = 0; k < all_failed_retry_safe_var.datalen; k++) {
3841                                 uint64_t all_failed_retry_safe_conv_10_ref = ((uint64_t)&all_failed_retry_safe_var.data[k]) | 1;
3842                                 all_failed_retry_safe_arr_ptr[k] = all_failed_retry_safe_conv_10_ref;
3843                         }
3844                         (*env)->ReleasePrimitiveArrayCritical(env, all_failed_retry_safe_arr, all_failed_retry_safe_arr_ptr, 0);
3845                         return (*env)->NewObject(env, LDKPaymentSendFailure_AllFailedRetrySafe_class, LDKPaymentSendFailure_AllFailedRetrySafe_meth, all_failed_retry_safe_arr);
3846                 }
3847                 case LDKPaymentSendFailure_PartialFailure: {
3848                         LDKCVec_CResult_NoneAPIErrorZZ results_var = obj->partial_failure.results;
3849                         int64_tArray results_arr = NULL;
3850                         results_arr = (*env)->NewLongArray(env, results_var.datalen);
3851                         int64_t *results_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, results_arr, NULL);
3852                         for (size_t w = 0; w < results_var.datalen; w++) {
3853                                 LDKCResult_NoneAPIErrorZ* results_conv_22_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
3854                                 *results_conv_22_conv = results_var.data[w];
3855                                 *results_conv_22_conv = CResult_NoneAPIErrorZ_clone(results_conv_22_conv);
3856                                 results_arr_ptr[w] = (uint64_t)results_conv_22_conv;
3857                         }
3858                         (*env)->ReleasePrimitiveArrayCritical(env, results_arr, results_arr_ptr, 0);
3859                         LDKRouteParameters failed_paths_retry_var = obj->partial_failure.failed_paths_retry;
3860                         uint64_t failed_paths_retry_ref = 0;
3861                         if ((uint64_t)failed_paths_retry_var.inner > 4096) {
3862                                 CHECK((((uint64_t)failed_paths_retry_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
3863                                 CHECK((((uint64_t)&failed_paths_retry_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
3864                         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_var);
3865                                 failed_paths_retry_ref = (uint64_t)failed_paths_retry_var.inner & ~1;
3866                         }
3867                         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
3868                         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, obj->partial_failure.payment_id.data);
3869                         return (*env)->NewObject(env, LDKPaymentSendFailure_PartialFailure_class, LDKPaymentSendFailure_PartialFailure_meth, results_arr, failed_paths_retry_ref, payment_id_arr);
3870                 }
3871                 default: abort();
3872         }
3873 }
3874 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3875         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3876         CHECK(val->result_ok);
3877         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
3878         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
3879         return res_arr;
3880 }
3881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3882         LDKCResult_PaymentIdPaymentSendFailureZ *val = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
3883         CHECK(!val->result_ok);
3884         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3885         return err_ref;
3886 }
3887 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3888         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3889         CHECK(val->result_ok);
3890         return *val->contents.result;
3891 }
3892 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3893         LDKCResult_NonePaymentSendFailureZ *val = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
3894         CHECK(!val->result_ok);
3895         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3896         return err_ref;
3897 }
3898 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_a(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3899         return ThirtyTwoBytes_clone(&tuple->a);
3900 }
3901 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3902         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3903         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3904         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_a(tuple_conv).data);
3905         return ret_arr;
3906 }
3907
3908 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentIdZ_get_b(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR tuple){
3909         return ThirtyTwoBytes_clone(&tuple->b);
3910 }
3911 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
3912         LDKC2Tuple_PaymentHashPaymentIdZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(tuple & ~1);
3913         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
3914         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentIdZ_get_b(tuple_conv).data);
3915         return ret_arr;
3916 }
3917
3918 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
3919         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3920         CHECK(val->result_ok);
3921         LDKC2Tuple_PaymentHashPaymentIdZ* res_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
3922         *res_conv = (*val->contents.result);
3923         *res_conv = C2Tuple_PaymentHashPaymentIdZ_clone(res_conv);
3924         return ((uint64_t)res_conv);
3925 }
3926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
3927         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *val = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
3928         CHECK(!val->result_ok);
3929         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
3930         return err_ref;
3931 }
3932 static jclass LDKNetAddress_IPv4_class = NULL;
3933 static jmethodID LDKNetAddress_IPv4_meth = NULL;
3934 static jclass LDKNetAddress_IPv6_class = NULL;
3935 static jmethodID LDKNetAddress_IPv6_meth = NULL;
3936 static jclass LDKNetAddress_OnionV2_class = NULL;
3937 static jmethodID LDKNetAddress_OnionV2_meth = NULL;
3938 static jclass LDKNetAddress_OnionV3_class = NULL;
3939 static jmethodID LDKNetAddress_OnionV3_meth = NULL;
3940 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKNetAddress_init (JNIEnv *env, jclass clz) {
3941         LDKNetAddress_IPv4_class =
3942                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv4;"));
3943         CHECK(LDKNetAddress_IPv4_class != NULL);
3944         LDKNetAddress_IPv4_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv4_class, "<init>", "([BS)V");
3945         CHECK(LDKNetAddress_IPv4_meth != NULL);
3946         LDKNetAddress_IPv6_class =
3947                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$IPv6;"));
3948         CHECK(LDKNetAddress_IPv6_class != NULL);
3949         LDKNetAddress_IPv6_meth = (*env)->GetMethodID(env, LDKNetAddress_IPv6_class, "<init>", "([BS)V");
3950         CHECK(LDKNetAddress_IPv6_meth != NULL);
3951         LDKNetAddress_OnionV2_class =
3952                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV2;"));
3953         CHECK(LDKNetAddress_OnionV2_class != NULL);
3954         LDKNetAddress_OnionV2_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV2_class, "<init>", "([BS)V");
3955         CHECK(LDKNetAddress_OnionV2_meth != NULL);
3956         LDKNetAddress_OnionV3_class =
3957                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKNetAddress$OnionV3;"));
3958         CHECK(LDKNetAddress_OnionV3_class != NULL);
3959         LDKNetAddress_OnionV3_meth = (*env)->GetMethodID(env, LDKNetAddress_OnionV3_class, "<init>", "([BSBS)V");
3960         CHECK(LDKNetAddress_OnionV3_meth != NULL);
3961 }
3962 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKNetAddress_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
3963         LDKNetAddress *obj = (LDKNetAddress*)(ptr & ~1);
3964         switch(obj->tag) {
3965                 case LDKNetAddress_IPv4: {
3966                         int8_tArray addr_arr = (*env)->NewByteArray(env, 4);
3967                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 4, obj->i_pv4.addr.data);
3968                         return (*env)->NewObject(env, LDKNetAddress_IPv4_class, LDKNetAddress_IPv4_meth, addr_arr, obj->i_pv4.port);
3969                 }
3970                 case LDKNetAddress_IPv6: {
3971                         int8_tArray addr_arr = (*env)->NewByteArray(env, 16);
3972                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 16, obj->i_pv6.addr.data);
3973                         return (*env)->NewObject(env, LDKNetAddress_IPv6_class, LDKNetAddress_IPv6_meth, addr_arr, obj->i_pv6.port);
3974                 }
3975                 case LDKNetAddress_OnionV2: {
3976                         int8_tArray addr_arr = (*env)->NewByteArray(env, 10);
3977                         (*env)->SetByteArrayRegion(env, addr_arr, 0, 10, obj->onion_v2.addr.data);
3978                         return (*env)->NewObject(env, LDKNetAddress_OnionV2_class, LDKNetAddress_OnionV2_meth, addr_arr, obj->onion_v2.port);
3979                 }
3980                 case LDKNetAddress_OnionV3: {
3981                         int8_tArray ed25519_pubkey_arr = (*env)->NewByteArray(env, 32);
3982                         (*env)->SetByteArrayRegion(env, ed25519_pubkey_arr, 0, 32, obj->onion_v3.ed25519_pubkey.data);
3983                         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);
3984                 }
3985                 default: abort();
3986         }
3987 }
3988 static inline LDKCVec_NetAddressZ CVec_NetAddressZ_clone(const LDKCVec_NetAddressZ *orig) {
3989         LDKCVec_NetAddressZ ret = { .data = MALLOC(sizeof(LDKNetAddress) * orig->datalen, "LDKCVec_NetAddressZ clone bytes"), .datalen = orig->datalen };
3990         for (size_t i = 0; i < ret.datalen; i++) {
3991                 ret.data[i] = NetAddress_clone(&orig->data[i]);
3992         }
3993         return ret;
3994 }
3995 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_a(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
3996         return ThirtyTwoBytes_clone(&tuple->a);
3997 }
3998 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
3999         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
4000         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4001         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_a(tuple_conv).data);
4002         return ret_arr;
4003 }
4004
4005 static inline struct LDKThirtyTwoBytes C2Tuple_PaymentHashPaymentSecretZ_get_b(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR tuple){
4006         return ThirtyTwoBytes_clone(&tuple->b);
4007 }
4008 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4009         LDKC2Tuple_PaymentHashPaymentSecretZ* tuple_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(tuple & ~1);
4010         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4011         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_PaymentHashPaymentSecretZ_get_b(tuple_conv).data);
4012         return ret_arr;
4013 }
4014
4015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4016         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
4017         CHECK(val->result_ok);
4018         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
4019         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
4020         return res_arr;
4021 }
4022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentSecretAPIErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4023         LDKCResult_PaymentSecretAPIErrorZ *val = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
4024         CHECK(!val->result_ok);
4025         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
4026         return err_ref;
4027 }
4028 static inline LDKCVec_ChannelMonitorZ CVec_ChannelMonitorZ_clone(const LDKCVec_ChannelMonitorZ *orig) {
4029         LDKCVec_ChannelMonitorZ ret = { .data = MALLOC(sizeof(LDKChannelMonitor) * orig->datalen, "LDKCVec_ChannelMonitorZ clone bytes"), .datalen = orig->datalen };
4030         for (size_t i = 0; i < ret.datalen; i++) {
4031                 ret.data[i] = ChannelMonitor_clone(&orig->data[i]);
4032         }
4033         return ret;
4034 }
4035 typedef struct LDKWatch_JCalls {
4036         atomic_size_t refcnt;
4037         JavaVM *vm;
4038         jweak o;
4039         jmethodID watch_channel_meth;
4040         jmethodID update_channel_meth;
4041         jmethodID release_pending_monitor_events_meth;
4042 } LDKWatch_JCalls;
4043 static void LDKWatch_JCalls_free(void* this_arg) {
4044         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4045         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4046                 JNIEnv *env;
4047                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4048                 if (get_jenv_res == JNI_EDETACHED) {
4049                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4050                 } else {
4051                         DO_ASSERT(get_jenv_res == JNI_OK);
4052                 }
4053                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4054                 if (get_jenv_res == JNI_EDETACHED) {
4055                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4056                 }
4057                 FREE(j_calls);
4058         }
4059 }
4060 LDKCResult_NoneChannelMonitorUpdateErrZ watch_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitor monitor) {
4061         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4062         JNIEnv *env;
4063         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4064         if (get_jenv_res == JNI_EDETACHED) {
4065                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4066         } else {
4067                 DO_ASSERT(get_jenv_res == JNI_OK);
4068         }
4069         LDKOutPoint funding_txo_var = funding_txo;
4070         uint64_t funding_txo_ref = 0;
4071         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4072         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4073         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4074         funding_txo_ref = (uint64_t)funding_txo_var.inner;
4075         if (funding_txo_var.is_owned) {
4076                 funding_txo_ref |= 1;
4077         }
4078         LDKChannelMonitor monitor_var = monitor;
4079         uint64_t monitor_ref = 0;
4080         CHECK((((uint64_t)monitor_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4081         CHECK((((uint64_t)&monitor_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4082         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_var);
4083         monitor_ref = (uint64_t)monitor_var.inner;
4084         if (monitor_var.is_owned) {
4085                 monitor_ref |= 1;
4086         }
4087         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4088         CHECK(obj != NULL);
4089         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->watch_channel_meth, funding_txo_ref, monitor_ref);
4090         if ((*env)->ExceptionCheck(env)) {
4091                 (*env)->ExceptionDescribe(env);
4092                 (*env)->FatalError(env, "A call to watch_channel in LDKWatch from rust threw an exception.");
4093         }
4094         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4095         CHECK_ACCESS(ret_ptr);
4096         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4097         FREE((void*)ret);
4098         if (get_jenv_res == JNI_EDETACHED) {
4099                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4100         }
4101         return ret_conv;
4102 }
4103 LDKCResult_NoneChannelMonitorUpdateErrZ update_channel_LDKWatch_jcall(const void* this_arg, LDKOutPoint funding_txo, LDKChannelMonitorUpdate update) {
4104         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4105         JNIEnv *env;
4106         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4107         if (get_jenv_res == JNI_EDETACHED) {
4108                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4109         } else {
4110                 DO_ASSERT(get_jenv_res == JNI_OK);
4111         }
4112         LDKOutPoint funding_txo_var = funding_txo;
4113         uint64_t funding_txo_ref = 0;
4114         CHECK((((uint64_t)funding_txo_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4115         CHECK((((uint64_t)&funding_txo_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4116         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_var);
4117         funding_txo_ref = (uint64_t)funding_txo_var.inner;
4118         if (funding_txo_var.is_owned) {
4119                 funding_txo_ref |= 1;
4120         }
4121         LDKChannelMonitorUpdate update_var = update;
4122         uint64_t update_ref = 0;
4123         CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4124         CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4125         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
4126         update_ref = (uint64_t)update_var.inner;
4127         if (update_var.is_owned) {
4128                 update_ref |= 1;
4129         }
4130         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4131         CHECK(obj != NULL);
4132         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_channel_meth, funding_txo_ref, update_ref);
4133         if ((*env)->ExceptionCheck(env)) {
4134                 (*env)->ExceptionDescribe(env);
4135                 (*env)->FatalError(env, "A call to update_channel in LDKWatch from rust threw an exception.");
4136         }
4137         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4138         CHECK_ACCESS(ret_ptr);
4139         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
4140         FREE((void*)ret);
4141         if (get_jenv_res == JNI_EDETACHED) {
4142                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4143         }
4144         return ret_conv;
4145 }
4146 LDKCVec_MonitorEventZ release_pending_monitor_events_LDKWatch_jcall(const void* this_arg) {
4147         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) this_arg;
4148         JNIEnv *env;
4149         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4150         if (get_jenv_res == JNI_EDETACHED) {
4151                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4152         } else {
4153                 DO_ASSERT(get_jenv_res == JNI_OK);
4154         }
4155         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4156         CHECK(obj != NULL);
4157         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->release_pending_monitor_events_meth);
4158         if ((*env)->ExceptionCheck(env)) {
4159                 (*env)->ExceptionDescribe(env);
4160                 (*env)->FatalError(env, "A call to release_pending_monitor_events in LDKWatch from rust threw an exception.");
4161         }
4162         LDKCVec_MonitorEventZ ret_constr;
4163         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
4164         if (ret_constr.datalen > 0)
4165                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
4166         else
4167                 ret_constr.data = NULL;
4168         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
4169         for (size_t o = 0; o < ret_constr.datalen; o++) {
4170                 int64_t ret_conv_14 = ret_vals[o];
4171                 void* ret_conv_14_ptr = (void*)(((uint64_t)ret_conv_14) & ~1);
4172                 CHECK_ACCESS(ret_conv_14_ptr);
4173                 LDKMonitorEvent ret_conv_14_conv = *(LDKMonitorEvent*)(ret_conv_14_ptr);
4174                 FREE((void*)ret_conv_14);
4175                 ret_constr.data[o] = ret_conv_14_conv;
4176         }
4177         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
4178         if (get_jenv_res == JNI_EDETACHED) {
4179                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4180         }
4181         return ret_constr;
4182 }
4183 static void LDKWatch_JCalls_cloned(LDKWatch* new_obj) {
4184         LDKWatch_JCalls *j_calls = (LDKWatch_JCalls*) new_obj->this_arg;
4185         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4186 }
4187 static inline LDKWatch LDKWatch_init (JNIEnv *env, jclass clz, jobject o) {
4188         jclass c = (*env)->GetObjectClass(env, o);
4189         CHECK(c != NULL);
4190         LDKWatch_JCalls *calls = MALLOC(sizeof(LDKWatch_JCalls), "LDKWatch_JCalls");
4191         atomic_init(&calls->refcnt, 1);
4192         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4193         calls->o = (*env)->NewWeakGlobalRef(env, o);
4194         calls->watch_channel_meth = (*env)->GetMethodID(env, c, "watch_channel", "(JJ)J");
4195         CHECK(calls->watch_channel_meth != NULL);
4196         calls->update_channel_meth = (*env)->GetMethodID(env, c, "update_channel", "(JJ)J");
4197         CHECK(calls->update_channel_meth != NULL);
4198         calls->release_pending_monitor_events_meth = (*env)->GetMethodID(env, c, "release_pending_monitor_events", "()[J");
4199         CHECK(calls->release_pending_monitor_events_meth != NULL);
4200
4201         LDKWatch ret = {
4202                 .this_arg = (void*) calls,
4203                 .watch_channel = watch_channel_LDKWatch_jcall,
4204                 .update_channel = update_channel_LDKWatch_jcall,
4205                 .release_pending_monitor_events = release_pending_monitor_events_LDKWatch_jcall,
4206                 .free = LDKWatch_JCalls_free,
4207         };
4208         return ret;
4209 }
4210 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKWatch_1new(JNIEnv *env, jclass clz, jobject o) {
4211         LDKWatch *res_ptr = MALLOC(sizeof(LDKWatch), "LDKWatch");
4212         *res_ptr = LDKWatch_init(env, clz, o);
4213         return (uint64_t)res_ptr;
4214 }
4215 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) {
4216         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4217         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4218         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4219         LDKOutPoint funding_txo_conv;
4220         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4221         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4222         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4223         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4224         LDKChannelMonitor monitor_conv;
4225         monitor_conv.inner = (void*)(monitor & (~1));
4226         monitor_conv.is_owned = (monitor & 1) || (monitor == 0);
4227         CHECK_INNER_FIELD_ACCESS_OR_NULL(monitor_conv);
4228         monitor_conv = ChannelMonitor_clone(&monitor_conv);
4229         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4230         *ret_conv = (this_arg_conv->watch_channel)(this_arg_conv->this_arg, funding_txo_conv, monitor_conv);
4231         return (uint64_t)ret_conv;
4232 }
4233
4234 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) {
4235         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4236         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4237         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4238         LDKOutPoint funding_txo_conv;
4239         funding_txo_conv.inner = (void*)(funding_txo & (~1));
4240         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
4241         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
4242         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
4243         LDKChannelMonitorUpdate update_conv;
4244         update_conv.inner = (void*)(update & (~1));
4245         update_conv.is_owned = (update & 1) || (update == 0);
4246         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
4247         update_conv = ChannelMonitorUpdate_clone(&update_conv);
4248         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
4249         *ret_conv = (this_arg_conv->update_channel)(this_arg_conv->this_arg, funding_txo_conv, update_conv);
4250         return (uint64_t)ret_conv;
4251 }
4252
4253 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Watch_1release_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
4254         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4255         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4256         LDKWatch* this_arg_conv = (LDKWatch*)this_arg_ptr;
4257         LDKCVec_MonitorEventZ ret_var = (this_arg_conv->release_pending_monitor_events)(this_arg_conv->this_arg);
4258         int64_tArray ret_arr = NULL;
4259         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
4260         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
4261         for (size_t o = 0; o < ret_var.datalen; o++) {
4262                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
4263                 *ret_conv_14_copy = ret_var.data[o];
4264                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
4265                 ret_arr_ptr[o] = ret_conv_14_ref;
4266         }
4267         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
4268         FREE(ret_var.data);
4269         return ret_arr;
4270 }
4271
4272 typedef struct LDKBroadcasterInterface_JCalls {
4273         atomic_size_t refcnt;
4274         JavaVM *vm;
4275         jweak o;
4276         jmethodID broadcast_transaction_meth;
4277 } LDKBroadcasterInterface_JCalls;
4278 static void LDKBroadcasterInterface_JCalls_free(void* this_arg) {
4279         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4280         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4281                 JNIEnv *env;
4282                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4283                 if (get_jenv_res == JNI_EDETACHED) {
4284                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4285                 } else {
4286                         DO_ASSERT(get_jenv_res == JNI_OK);
4287                 }
4288                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4289                 if (get_jenv_res == JNI_EDETACHED) {
4290                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4291                 }
4292                 FREE(j_calls);
4293         }
4294 }
4295 void broadcast_transaction_LDKBroadcasterInterface_jcall(const void* this_arg, LDKTransaction tx) {
4296         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) this_arg;
4297         JNIEnv *env;
4298         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4299         if (get_jenv_res == JNI_EDETACHED) {
4300                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4301         } else {
4302                 DO_ASSERT(get_jenv_res == JNI_OK);
4303         }
4304         LDKTransaction tx_var = tx;
4305         int8_tArray tx_arr = (*env)->NewByteArray(env, tx_var.datalen);
4306         (*env)->SetByteArrayRegion(env, tx_arr, 0, tx_var.datalen, tx_var.data);
4307         Transaction_free(tx_var);
4308         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4309         CHECK(obj != NULL);
4310         (*env)->CallVoidMethod(env, obj, j_calls->broadcast_transaction_meth, tx_arr);
4311         if ((*env)->ExceptionCheck(env)) {
4312                 (*env)->ExceptionDescribe(env);
4313                 (*env)->FatalError(env, "A call to broadcast_transaction in LDKBroadcasterInterface from rust threw an exception.");
4314         }
4315         if (get_jenv_res == JNI_EDETACHED) {
4316                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4317         }
4318 }
4319 static void LDKBroadcasterInterface_JCalls_cloned(LDKBroadcasterInterface* new_obj) {
4320         LDKBroadcasterInterface_JCalls *j_calls = (LDKBroadcasterInterface_JCalls*) new_obj->this_arg;
4321         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4322 }
4323 static inline LDKBroadcasterInterface LDKBroadcasterInterface_init (JNIEnv *env, jclass clz, jobject o) {
4324         jclass c = (*env)->GetObjectClass(env, o);
4325         CHECK(c != NULL);
4326         LDKBroadcasterInterface_JCalls *calls = MALLOC(sizeof(LDKBroadcasterInterface_JCalls), "LDKBroadcasterInterface_JCalls");
4327         atomic_init(&calls->refcnt, 1);
4328         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4329         calls->o = (*env)->NewWeakGlobalRef(env, o);
4330         calls->broadcast_transaction_meth = (*env)->GetMethodID(env, c, "broadcast_transaction", "([B)V");
4331         CHECK(calls->broadcast_transaction_meth != NULL);
4332
4333         LDKBroadcasterInterface ret = {
4334                 .this_arg = (void*) calls,
4335                 .broadcast_transaction = broadcast_transaction_LDKBroadcasterInterface_jcall,
4336                 .free = LDKBroadcasterInterface_JCalls_free,
4337         };
4338         return ret;
4339 }
4340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKBroadcasterInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4341         LDKBroadcasterInterface *res_ptr = MALLOC(sizeof(LDKBroadcasterInterface), "LDKBroadcasterInterface");
4342         *res_ptr = LDKBroadcasterInterface_init(env, clz, o);
4343         return (uint64_t)res_ptr;
4344 }
4345 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1broadcast_1transaction(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray tx) {
4346         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4347         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4348         LDKBroadcasterInterface* this_arg_conv = (LDKBroadcasterInterface*)this_arg_ptr;
4349         LDKTransaction tx_ref;
4350         tx_ref.datalen = (*env)->GetArrayLength(env, tx);
4351         tx_ref.data = MALLOC(tx_ref.datalen, "LDKTransaction Bytes");
4352         (*env)->GetByteArrayRegion(env, tx, 0, tx_ref.datalen, tx_ref.data);
4353         tx_ref.data_is_owned = true;
4354         (this_arg_conv->broadcast_transaction)(this_arg_conv->this_arg, tx_ref);
4355 }
4356
4357 typedef struct LDKKeysInterface_JCalls {
4358         atomic_size_t refcnt;
4359         JavaVM *vm;
4360         jweak o;
4361         jmethodID get_node_secret_meth;
4362         jmethodID get_destination_script_meth;
4363         jmethodID get_shutdown_scriptpubkey_meth;
4364         jmethodID get_channel_signer_meth;
4365         jmethodID get_secure_random_bytes_meth;
4366         jmethodID read_chan_signer_meth;
4367         jmethodID sign_invoice_meth;
4368 } LDKKeysInterface_JCalls;
4369 static void LDKKeysInterface_JCalls_free(void* this_arg) {
4370         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4371         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4372                 JNIEnv *env;
4373                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4374                 if (get_jenv_res == JNI_EDETACHED) {
4375                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4376                 } else {
4377                         DO_ASSERT(get_jenv_res == JNI_OK);
4378                 }
4379                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4380                 if (get_jenv_res == JNI_EDETACHED) {
4381                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4382                 }
4383                 FREE(j_calls);
4384         }
4385 }
4386 LDKSecretKey get_node_secret_LDKKeysInterface_jcall(const void* this_arg) {
4387         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4388         JNIEnv *env;
4389         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4390         if (get_jenv_res == JNI_EDETACHED) {
4391                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4392         } else {
4393                 DO_ASSERT(get_jenv_res == JNI_OK);
4394         }
4395         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4396         CHECK(obj != NULL);
4397         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_node_secret_meth);
4398         if ((*env)->ExceptionCheck(env)) {
4399                 (*env)->ExceptionDescribe(env);
4400                 (*env)->FatalError(env, "A call to get_node_secret in LDKKeysInterface from rust threw an exception.");
4401         }
4402         LDKSecretKey ret_ref;
4403         CHECK((*env)->GetArrayLength(env, ret) == 32);
4404         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.bytes);
4405         if (get_jenv_res == JNI_EDETACHED) {
4406                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4407         }
4408         return ret_ref;
4409 }
4410 LDKCVec_u8Z get_destination_script_LDKKeysInterface_jcall(const void* this_arg) {
4411         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4412         JNIEnv *env;
4413         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4414         if (get_jenv_res == JNI_EDETACHED) {
4415                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4416         } else {
4417                 DO_ASSERT(get_jenv_res == JNI_OK);
4418         }
4419         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4420         CHECK(obj != NULL);
4421         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_destination_script_meth);
4422         if ((*env)->ExceptionCheck(env)) {
4423                 (*env)->ExceptionDescribe(env);
4424                 (*env)->FatalError(env, "A call to get_destination_script in LDKKeysInterface from rust threw an exception.");
4425         }
4426         LDKCVec_u8Z ret_ref;
4427         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
4428         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
4429         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
4430         if (get_jenv_res == JNI_EDETACHED) {
4431                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4432         }
4433         return ret_ref;
4434 }
4435 LDKShutdownScript get_shutdown_scriptpubkey_LDKKeysInterface_jcall(const void* this_arg) {
4436         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4437         JNIEnv *env;
4438         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4439         if (get_jenv_res == JNI_EDETACHED) {
4440                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4441         } else {
4442                 DO_ASSERT(get_jenv_res == JNI_OK);
4443         }
4444         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4445         CHECK(obj != NULL);
4446         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_shutdown_scriptpubkey_meth);
4447         if ((*env)->ExceptionCheck(env)) {
4448                 (*env)->ExceptionDescribe(env);
4449                 (*env)->FatalError(env, "A call to get_shutdown_scriptpubkey in LDKKeysInterface from rust threw an exception.");
4450         }
4451         LDKShutdownScript ret_conv;
4452         ret_conv.inner = (void*)(ret & (~1));
4453         ret_conv.is_owned = (ret & 1) || (ret == 0);
4454         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv);
4455         if (get_jenv_res == JNI_EDETACHED) {
4456                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4457         }
4458         return ret_conv;
4459 }
4460 LDKSign get_channel_signer_LDKKeysInterface_jcall(const void* this_arg, bool inbound, uint64_t channel_value_satoshis) {
4461         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4462         JNIEnv *env;
4463         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4464         if (get_jenv_res == JNI_EDETACHED) {
4465                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4466         } else {
4467                 DO_ASSERT(get_jenv_res == JNI_OK);
4468         }
4469         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4470         CHECK(obj != NULL);
4471         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_channel_signer_meth, inbound, channel_value_satoshis);
4472         if ((*env)->ExceptionCheck(env)) {
4473                 (*env)->ExceptionDescribe(env);
4474                 (*env)->FatalError(env, "A call to get_channel_signer in LDKKeysInterface from rust threw an exception.");
4475         }
4476         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4477         CHECK_ACCESS(ret_ptr);
4478         LDKSign ret_conv = *(LDKSign*)(ret_ptr);
4479         FREE((void*)ret);
4480         if (get_jenv_res == JNI_EDETACHED) {
4481                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4482         }
4483         return ret_conv;
4484 }
4485 LDKThirtyTwoBytes get_secure_random_bytes_LDKKeysInterface_jcall(const void* this_arg) {
4486         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4487         JNIEnv *env;
4488         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4489         if (get_jenv_res == JNI_EDETACHED) {
4490                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4491         } else {
4492                 DO_ASSERT(get_jenv_res == JNI_OK);
4493         }
4494         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4495         CHECK(obj != NULL);
4496         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_secure_random_bytes_meth);
4497         if ((*env)->ExceptionCheck(env)) {
4498                 (*env)->ExceptionDescribe(env);
4499                 (*env)->FatalError(env, "A call to get_secure_random_bytes in LDKKeysInterface from rust threw an exception.");
4500         }
4501         LDKThirtyTwoBytes ret_ref;
4502         CHECK((*env)->GetArrayLength(env, ret) == 32);
4503         (*env)->GetByteArrayRegion(env, ret, 0, 32, ret_ref.data);
4504         if (get_jenv_res == JNI_EDETACHED) {
4505                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4506         }
4507         return ret_ref;
4508 }
4509 LDKCResult_SignDecodeErrorZ read_chan_signer_LDKKeysInterface_jcall(const void* this_arg, LDKu8slice reader) {
4510         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4511         JNIEnv *env;
4512         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4513         if (get_jenv_res == JNI_EDETACHED) {
4514                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4515         } else {
4516                 DO_ASSERT(get_jenv_res == JNI_OK);
4517         }
4518         LDKu8slice reader_var = reader;
4519         int8_tArray reader_arr = (*env)->NewByteArray(env, reader_var.datalen);
4520         (*env)->SetByteArrayRegion(env, reader_arr, 0, reader_var.datalen, reader_var.data);
4521         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4522         CHECK(obj != NULL);
4523         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_chan_signer_meth, reader_arr);
4524         if ((*env)->ExceptionCheck(env)) {
4525                 (*env)->ExceptionDescribe(env);
4526                 (*env)->FatalError(env, "A call to read_chan_signer in LDKKeysInterface from rust threw an exception.");
4527         }
4528         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4529         CHECK_ACCESS(ret_ptr);
4530         LDKCResult_SignDecodeErrorZ ret_conv = *(LDKCResult_SignDecodeErrorZ*)(ret_ptr);
4531         FREE((void*)ret);
4532         if (get_jenv_res == JNI_EDETACHED) {
4533                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4534         }
4535         return ret_conv;
4536 }
4537 LDKCResult_RecoverableSignatureNoneZ sign_invoice_LDKKeysInterface_jcall(const void* this_arg, LDKCVec_u8Z invoice_preimage) {
4538         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) this_arg;
4539         JNIEnv *env;
4540         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4541         if (get_jenv_res == JNI_EDETACHED) {
4542                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4543         } else {
4544                 DO_ASSERT(get_jenv_res == JNI_OK);
4545         }
4546         LDKCVec_u8Z invoice_preimage_var = invoice_preimage;
4547         int8_tArray invoice_preimage_arr = (*env)->NewByteArray(env, invoice_preimage_var.datalen);
4548         (*env)->SetByteArrayRegion(env, invoice_preimage_arr, 0, invoice_preimage_var.datalen, invoice_preimage_var.data);
4549         CVec_u8Z_free(invoice_preimage_var);
4550         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4551         CHECK(obj != NULL);
4552         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->sign_invoice_meth, invoice_preimage_arr);
4553         if ((*env)->ExceptionCheck(env)) {
4554                 (*env)->ExceptionDescribe(env);
4555                 (*env)->FatalError(env, "A call to sign_invoice in LDKKeysInterface from rust threw an exception.");
4556         }
4557         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
4558         CHECK_ACCESS(ret_ptr);
4559         LDKCResult_RecoverableSignatureNoneZ ret_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(ret_ptr);
4560         FREE((void*)ret);
4561         if (get_jenv_res == JNI_EDETACHED) {
4562                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4563         }
4564         return ret_conv;
4565 }
4566 static void LDKKeysInterface_JCalls_cloned(LDKKeysInterface* new_obj) {
4567         LDKKeysInterface_JCalls *j_calls = (LDKKeysInterface_JCalls*) new_obj->this_arg;
4568         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4569 }
4570 static inline LDKKeysInterface LDKKeysInterface_init (JNIEnv *env, jclass clz, jobject o) {
4571         jclass c = (*env)->GetObjectClass(env, o);
4572         CHECK(c != NULL);
4573         LDKKeysInterface_JCalls *calls = MALLOC(sizeof(LDKKeysInterface_JCalls), "LDKKeysInterface_JCalls");
4574         atomic_init(&calls->refcnt, 1);
4575         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4576         calls->o = (*env)->NewWeakGlobalRef(env, o);
4577         calls->get_node_secret_meth = (*env)->GetMethodID(env, c, "get_node_secret", "()[B");
4578         CHECK(calls->get_node_secret_meth != NULL);
4579         calls->get_destination_script_meth = (*env)->GetMethodID(env, c, "get_destination_script", "()[B");
4580         CHECK(calls->get_destination_script_meth != NULL);
4581         calls->get_shutdown_scriptpubkey_meth = (*env)->GetMethodID(env, c, "get_shutdown_scriptpubkey", "()J");
4582         CHECK(calls->get_shutdown_scriptpubkey_meth != NULL);
4583         calls->get_channel_signer_meth = (*env)->GetMethodID(env, c, "get_channel_signer", "(ZJ)J");
4584         CHECK(calls->get_channel_signer_meth != NULL);
4585         calls->get_secure_random_bytes_meth = (*env)->GetMethodID(env, c, "get_secure_random_bytes", "()[B");
4586         CHECK(calls->get_secure_random_bytes_meth != NULL);
4587         calls->read_chan_signer_meth = (*env)->GetMethodID(env, c, "read_chan_signer", "([B)J");
4588         CHECK(calls->read_chan_signer_meth != NULL);
4589         calls->sign_invoice_meth = (*env)->GetMethodID(env, c, "sign_invoice", "([B)J");
4590         CHECK(calls->sign_invoice_meth != NULL);
4591
4592         LDKKeysInterface ret = {
4593                 .this_arg = (void*) calls,
4594                 .get_node_secret = get_node_secret_LDKKeysInterface_jcall,
4595                 .get_destination_script = get_destination_script_LDKKeysInterface_jcall,
4596                 .get_shutdown_scriptpubkey = get_shutdown_scriptpubkey_LDKKeysInterface_jcall,
4597                 .get_channel_signer = get_channel_signer_LDKKeysInterface_jcall,
4598                 .get_secure_random_bytes = get_secure_random_bytes_LDKKeysInterface_jcall,
4599                 .read_chan_signer = read_chan_signer_LDKKeysInterface_jcall,
4600                 .sign_invoice = sign_invoice_LDKKeysInterface_jcall,
4601                 .free = LDKKeysInterface_JCalls_free,
4602         };
4603         return ret;
4604 }
4605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKKeysInterface_1new(JNIEnv *env, jclass clz, jobject o) {
4606         LDKKeysInterface *res_ptr = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
4607         *res_ptr = LDKKeysInterface_init(env, clz, o);
4608         return (uint64_t)res_ptr;
4609 }
4610 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1node_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
4611         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4612         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4613         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4614         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4615         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_node_secret)(this_arg_conv->this_arg).bytes);
4616         return ret_arr;
4617 }
4618
4619 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1destination_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
4620         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4621         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4622         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4623         LDKCVec_u8Z ret_var = (this_arg_conv->get_destination_script)(this_arg_conv->this_arg);
4624         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
4625         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
4626         CVec_u8Z_free(ret_var);
4627         return ret_arr;
4628 }
4629
4630 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1shutdown_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
4631         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4632         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4633         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4634         LDKShutdownScript ret_var = (this_arg_conv->get_shutdown_scriptpubkey)(this_arg_conv->this_arg);
4635         uint64_t ret_ref = 0;
4636         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4637         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4638         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4639         ret_ref = (uint64_t)ret_var.inner;
4640         if (ret_var.is_owned) {
4641                 ret_ref |= 1;
4642         }
4643         return ret_ref;
4644 }
4645
4646 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) {
4647         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4648         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4649         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4650         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
4651         *ret_ret = (this_arg_conv->get_channel_signer)(this_arg_conv->this_arg, inbound, channel_value_satoshis);
4652         return (uint64_t)ret_ret;
4653 }
4654
4655 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_KeysInterface_1get_1secure_1random_1bytes(JNIEnv *env, jclass clz, int64_t this_arg) {
4656         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4657         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4658         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4659         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4660         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, (this_arg_conv->get_secure_random_bytes)(this_arg_conv->this_arg).data);
4661         return ret_arr;
4662 }
4663
4664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1read_1chan_1signer(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray reader) {
4665         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4666         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4667         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4668         LDKu8slice reader_ref;
4669         reader_ref.datalen = (*env)->GetArrayLength(env, reader);
4670         reader_ref.data = (*env)->GetByteArrayElements (env, reader, NULL);
4671         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
4672         *ret_conv = (this_arg_conv->read_chan_signer)(this_arg_conv->this_arg, reader_ref);
4673         (*env)->ReleaseByteArrayElements(env, reader, (int8_t*)reader_ref.data, 0);
4674         return (uint64_t)ret_conv;
4675 }
4676
4677 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysInterface_1sign_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray invoice_preimage) {
4678         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4679         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4680         LDKKeysInterface* this_arg_conv = (LDKKeysInterface*)this_arg_ptr;
4681         LDKCVec_u8Z invoice_preimage_ref;
4682         invoice_preimage_ref.datalen = (*env)->GetArrayLength(env, invoice_preimage);
4683         invoice_preimage_ref.data = MALLOC(invoice_preimage_ref.datalen, "LDKCVec_u8Z Bytes");
4684         (*env)->GetByteArrayRegion(env, invoice_preimage, 0, invoice_preimage_ref.datalen, invoice_preimage_ref.data);
4685         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
4686         *ret_conv = (this_arg_conv->sign_invoice)(this_arg_conv->this_arg, invoice_preimage_ref);
4687         return (uint64_t)ret_conv;
4688 }
4689
4690 typedef struct LDKFeeEstimator_JCalls {
4691         atomic_size_t refcnt;
4692         JavaVM *vm;
4693         jweak o;
4694         jmethodID get_est_sat_per_1000_weight_meth;
4695 } LDKFeeEstimator_JCalls;
4696 static void LDKFeeEstimator_JCalls_free(void* this_arg) {
4697         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4698         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4699                 JNIEnv *env;
4700                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4701                 if (get_jenv_res == JNI_EDETACHED) {
4702                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4703                 } else {
4704                         DO_ASSERT(get_jenv_res == JNI_OK);
4705                 }
4706                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4707                 if (get_jenv_res == JNI_EDETACHED) {
4708                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4709                 }
4710                 FREE(j_calls);
4711         }
4712 }
4713 uint32_t get_est_sat_per_1000_weight_LDKFeeEstimator_jcall(const void* this_arg, LDKConfirmationTarget confirmation_target) {
4714         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) this_arg;
4715         JNIEnv *env;
4716         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4717         if (get_jenv_res == JNI_EDETACHED) {
4718                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4719         } else {
4720                 DO_ASSERT(get_jenv_res == JNI_OK);
4721         }
4722         jclass confirmation_target_conv = LDKConfirmationTarget_to_java(env, confirmation_target);
4723         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4724         CHECK(obj != NULL);
4725         int32_t ret = (*env)->CallIntMethod(env, obj, j_calls->get_est_sat_per_1000_weight_meth, confirmation_target_conv);
4726         if ((*env)->ExceptionCheck(env)) {
4727                 (*env)->ExceptionDescribe(env);
4728                 (*env)->FatalError(env, "A call to get_est_sat_per_1000_weight in LDKFeeEstimator from rust threw an exception.");
4729         }
4730         if (get_jenv_res == JNI_EDETACHED) {
4731                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4732         }
4733         return ret;
4734 }
4735 static void LDKFeeEstimator_JCalls_cloned(LDKFeeEstimator* new_obj) {
4736         LDKFeeEstimator_JCalls *j_calls = (LDKFeeEstimator_JCalls*) new_obj->this_arg;
4737         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4738 }
4739 static inline LDKFeeEstimator LDKFeeEstimator_init (JNIEnv *env, jclass clz, jobject o) {
4740         jclass c = (*env)->GetObjectClass(env, o);
4741         CHECK(c != NULL);
4742         LDKFeeEstimator_JCalls *calls = MALLOC(sizeof(LDKFeeEstimator_JCalls), "LDKFeeEstimator_JCalls");
4743         atomic_init(&calls->refcnt, 1);
4744         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4745         calls->o = (*env)->NewWeakGlobalRef(env, o);
4746         calls->get_est_sat_per_1000_weight_meth = (*env)->GetMethodID(env, c, "get_est_sat_per_1000_weight", "(Lorg/ldk/enums/ConfirmationTarget;)I");
4747         CHECK(calls->get_est_sat_per_1000_weight_meth != NULL);
4748
4749         LDKFeeEstimator ret = {
4750                 .this_arg = (void*) calls,
4751                 .get_est_sat_per_1000_weight = get_est_sat_per_1000_weight_LDKFeeEstimator_jcall,
4752                 .free = LDKFeeEstimator_JCalls_free,
4753         };
4754         return ret;
4755 }
4756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFeeEstimator_1new(JNIEnv *env, jclass clz, jobject o) {
4757         LDKFeeEstimator *res_ptr = MALLOC(sizeof(LDKFeeEstimator), "LDKFeeEstimator");
4758         *res_ptr = LDKFeeEstimator_init(env, clz, o);
4759         return (uint64_t)res_ptr;
4760 }
4761 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) {
4762         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
4763         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
4764         LDKFeeEstimator* this_arg_conv = (LDKFeeEstimator*)this_arg_ptr;
4765         LDKConfirmationTarget confirmation_target_conv = LDKConfirmationTarget_from_java(env, confirmation_target);
4766         int32_t ret_val = (this_arg_conv->get_est_sat_per_1000_weight)(this_arg_conv->this_arg, confirmation_target_conv);
4767         return ret_val;
4768 }
4769
4770 typedef struct LDKLogger_JCalls {
4771         atomic_size_t refcnt;
4772         JavaVM *vm;
4773         jweak o;
4774         jmethodID log_meth;
4775 } LDKLogger_JCalls;
4776 static void LDKLogger_JCalls_free(void* this_arg) {
4777         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4778         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4779                 JNIEnv *env;
4780                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4781                 if (get_jenv_res == JNI_EDETACHED) {
4782                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4783                 } else {
4784                         DO_ASSERT(get_jenv_res == JNI_OK);
4785                 }
4786                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4787                 if (get_jenv_res == JNI_EDETACHED) {
4788                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4789                 }
4790                 FREE(j_calls);
4791         }
4792 }
4793 void log_LDKLogger_jcall(const void* this_arg, const LDKRecord * record) {
4794         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) this_arg;
4795         JNIEnv *env;
4796         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4797         if (get_jenv_res == JNI_EDETACHED) {
4798                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4799         } else {
4800                 DO_ASSERT(get_jenv_res == JNI_OK);
4801         }
4802         LDKRecord record_var = *record;
4803         uint64_t record_ref = 0;
4804         record_var = Record_clone(record);
4805         CHECK((((uint64_t)record_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4806         CHECK((((uint64_t)&record_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4807         CHECK_INNER_FIELD_ACCESS_OR_NULL(record_var);
4808         record_ref = (uint64_t)record_var.inner;
4809         if (record_var.is_owned) {
4810                 record_ref |= 1;
4811         }
4812         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4813         CHECK(obj != NULL);
4814         (*env)->CallVoidMethod(env, obj, j_calls->log_meth, record_ref);
4815         if ((*env)->ExceptionCheck(env)) {
4816                 (*env)->ExceptionDescribe(env);
4817                 (*env)->FatalError(env, "A call to log in LDKLogger from rust threw an exception.");
4818         }
4819         if (get_jenv_res == JNI_EDETACHED) {
4820                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4821         }
4822 }
4823 static void LDKLogger_JCalls_cloned(LDKLogger* new_obj) {
4824         LDKLogger_JCalls *j_calls = (LDKLogger_JCalls*) new_obj->this_arg;
4825         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
4826 }
4827 static inline LDKLogger LDKLogger_init (JNIEnv *env, jclass clz, jobject o) {
4828         jclass c = (*env)->GetObjectClass(env, o);
4829         CHECK(c != NULL);
4830         LDKLogger_JCalls *calls = MALLOC(sizeof(LDKLogger_JCalls), "LDKLogger_JCalls");
4831         atomic_init(&calls->refcnt, 1);
4832         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
4833         calls->o = (*env)->NewWeakGlobalRef(env, o);
4834         calls->log_meth = (*env)->GetMethodID(env, c, "log", "(J)V");
4835         CHECK(calls->log_meth != NULL);
4836
4837         LDKLogger ret = {
4838                 .this_arg = (void*) calls,
4839                 .log = log_LDKLogger_jcall,
4840                 .free = LDKLogger_JCalls_free,
4841         };
4842         return ret;
4843 }
4844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKLogger_1new(JNIEnv *env, jclass clz, jobject o) {
4845         LDKLogger *res_ptr = MALLOC(sizeof(LDKLogger), "LDKLogger");
4846         *res_ptr = LDKLogger_init(env, clz, o);
4847         return (uint64_t)res_ptr;
4848 }
4849 static inline struct LDKThirtyTwoBytes C2Tuple_BlockHashChannelManagerZ_get_a(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4850         return ThirtyTwoBytes_clone(&tuple->a);
4851 }
4852 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
4853         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4854         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
4855         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_BlockHashChannelManagerZ_get_a(tuple_conv).data);
4856         return ret_arr;
4857 }
4858
4859 static inline struct LDKChannelManager *C2Tuple_BlockHashChannelManagerZ_get_b(LDKC2Tuple_BlockHashChannelManagerZ *NONNULL_PTR tuple){
4860         return &tuple->b;
4861 }
4862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
4863         LDKC2Tuple_BlockHashChannelManagerZ* tuple_conv = (LDKC2Tuple_BlockHashChannelManagerZ*)(tuple & ~1);
4864         LDKChannelManager ret_var = *C2Tuple_BlockHashChannelManagerZ_get_b(tuple_conv);
4865         uint64_t ret_ref = 0;
4866         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4867         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4868         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
4869         ret_ref = (uint64_t)ret_var.inner & ~1;
4870         return ret_ref;
4871 }
4872
4873 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4874         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4875         CHECK(val->result_ok);
4876         LDKC2Tuple_BlockHashChannelManagerZ* res_conv = &(*val->contents.result);
4877         // Warning: we really need to clone here, but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
4878         return ((uint64_t)res_conv) | 1;
4879 }
4880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4881         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(arg & ~1);
4882         CHECK(!val->result_ok);
4883         LDKDecodeError err_var = (*val->contents.err);
4884         uint64_t err_ref = 0;
4885         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4886         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4887         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4888         err_ref = (uint64_t)err_var.inner & ~1;
4889         return err_ref;
4890 }
4891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4892         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4893         CHECK(val->result_ok);
4894         LDKChannelConfig res_var = (*val->contents.result);
4895         uint64_t res_ref = 0;
4896         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4897         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4898         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4899         res_ref = (uint64_t)res_var.inner & ~1;
4900         return res_ref;
4901 }
4902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelConfigDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4903         LDKCResult_ChannelConfigDecodeErrorZ *val = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
4904         CHECK(!val->result_ok);
4905         LDKDecodeError err_var = (*val->contents.err);
4906         uint64_t err_ref = 0;
4907         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4908         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4909         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4910         err_ref = (uint64_t)err_var.inner & ~1;
4911         return err_ref;
4912 }
4913 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
4914         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4915         CHECK(val->result_ok);
4916         LDKOutPoint res_var = (*val->contents.result);
4917         uint64_t res_ref = 0;
4918         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4919         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4920         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
4921         res_ref = (uint64_t)res_var.inner & ~1;
4922         return res_ref;
4923 }
4924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OutPointDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
4925         LDKCResult_OutPointDecodeErrorZ *val = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
4926         CHECK(!val->result_ok);
4927         LDKDecodeError err_var = (*val->contents.err);
4928         uint64_t err_ref = 0;
4929         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
4930         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
4931         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
4932         err_ref = (uint64_t)err_var.inner & ~1;
4933         return err_ref;
4934 }
4935 typedef struct LDKType_JCalls {
4936         atomic_size_t refcnt;
4937         JavaVM *vm;
4938         jweak o;
4939         jmethodID type_id_meth;
4940         jmethodID debug_str_meth;
4941         jmethodID write_meth;
4942 } LDKType_JCalls;
4943 static void LDKType_JCalls_free(void* this_arg) {
4944         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4945         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
4946                 JNIEnv *env;
4947                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4948                 if (get_jenv_res == JNI_EDETACHED) {
4949                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4950                 } else {
4951                         DO_ASSERT(get_jenv_res == JNI_OK);
4952                 }
4953                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
4954                 if (get_jenv_res == JNI_EDETACHED) {
4955                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4956                 }
4957                 FREE(j_calls);
4958         }
4959 }
4960 uint16_t type_id_LDKType_jcall(const void* this_arg) {
4961         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4962         JNIEnv *env;
4963         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4964         if (get_jenv_res == JNI_EDETACHED) {
4965                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4966         } else {
4967                 DO_ASSERT(get_jenv_res == JNI_OK);
4968         }
4969         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4970         CHECK(obj != NULL);
4971         int16_t ret = (*env)->CallShortMethod(env, obj, j_calls->type_id_meth);
4972         if ((*env)->ExceptionCheck(env)) {
4973                 (*env)->ExceptionDescribe(env);
4974                 (*env)->FatalError(env, "A call to type_id in LDKType from rust threw an exception.");
4975         }
4976         if (get_jenv_res == JNI_EDETACHED) {
4977                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
4978         }
4979         return ret;
4980 }
4981 LDKStr debug_str_LDKType_jcall(const void* this_arg) {
4982         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
4983         JNIEnv *env;
4984         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
4985         if (get_jenv_res == JNI_EDETACHED) {
4986                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
4987         } else {
4988                 DO_ASSERT(get_jenv_res == JNI_OK);
4989         }
4990         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
4991         CHECK(obj != NULL);
4992         jstring ret = (*env)->CallObjectMethod(env, obj, j_calls->debug_str_meth);
4993         if ((*env)->ExceptionCheck(env)) {
4994                 (*env)->ExceptionDescribe(env);
4995                 (*env)->FatalError(env, "A call to debug_str in LDKType from rust threw an exception.");
4996         }
4997         LDKStr ret_conv = java_to_owned_str(env, ret);
4998         if (get_jenv_res == JNI_EDETACHED) {
4999                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5000         }
5001         return ret_conv;
5002 }
5003 LDKCVec_u8Z write_LDKType_jcall(const void* this_arg) {
5004         LDKType_JCalls *j_calls = (LDKType_JCalls*) this_arg;
5005         JNIEnv *env;
5006         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5007         if (get_jenv_res == JNI_EDETACHED) {
5008                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5009         } else {
5010                 DO_ASSERT(get_jenv_res == JNI_OK);
5011         }
5012         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
5013         CHECK(obj != NULL);
5014         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
5015         if ((*env)->ExceptionCheck(env)) {
5016                 (*env)->ExceptionDescribe(env);
5017                 (*env)->FatalError(env, "A call to write in LDKType from rust threw an exception.");
5018         }
5019         LDKCVec_u8Z ret_ref;
5020         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
5021         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
5022         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
5023         if (get_jenv_res == JNI_EDETACHED) {
5024                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5025         }
5026         return ret_ref;
5027 }
5028 static void LDKType_JCalls_cloned(LDKType* new_obj) {
5029         LDKType_JCalls *j_calls = (LDKType_JCalls*) new_obj->this_arg;
5030         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
5031 }
5032 static inline LDKType LDKType_init (JNIEnv *env, jclass clz, jobject o) {
5033         jclass c = (*env)->GetObjectClass(env, o);
5034         CHECK(c != NULL);
5035         LDKType_JCalls *calls = MALLOC(sizeof(LDKType_JCalls), "LDKType_JCalls");
5036         atomic_init(&calls->refcnt, 1);
5037         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
5038         calls->o = (*env)->NewWeakGlobalRef(env, o);
5039         calls->type_id_meth = (*env)->GetMethodID(env, c, "type_id", "()S");
5040         CHECK(calls->type_id_meth != NULL);
5041         calls->debug_str_meth = (*env)->GetMethodID(env, c, "debug_str", "()Ljava/lang/String;");
5042         CHECK(calls->debug_str_meth != NULL);
5043         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
5044         CHECK(calls->write_meth != NULL);
5045
5046         LDKType ret = {
5047                 .this_arg = (void*) calls,
5048                 .type_id = type_id_LDKType_jcall,
5049                 .debug_str = debug_str_LDKType_jcall,
5050                 .write = write_LDKType_jcall,
5051                 .cloned = LDKType_JCalls_cloned,
5052                 .free = LDKType_JCalls_free,
5053         };
5054         return ret;
5055 }
5056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKType_1new(JNIEnv *env, jclass clz, jobject o) {
5057         LDKType *res_ptr = MALLOC(sizeof(LDKType), "LDKType");
5058         *res_ptr = LDKType_init(env, clz, o);
5059         return (uint64_t)res_ptr;
5060 }
5061 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Type_1type_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
5062         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5063         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5064         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5065         int16_t ret_val = (this_arg_conv->type_id)(this_arg_conv->this_arg);
5066         return ret_val;
5067 }
5068
5069 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Type_1debug_1str(JNIEnv *env, jclass clz, int64_t this_arg) {
5070         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5071         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5072         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5073         LDKStr ret_str = (this_arg_conv->debug_str)(this_arg_conv->this_arg);
5074         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
5075         Str_free(ret_str);
5076         return ret_conv;
5077 }
5078
5079 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Type_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
5080         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
5081         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
5082         LDKType* this_arg_conv = (LDKType*)this_arg_ptr;
5083         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
5084         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5085         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5086         CVec_u8Z_free(ret_var);
5087         return ret_arr;
5088 }
5089
5090 static jclass LDKCOption_TypeZ_Some_class = NULL;
5091 static jmethodID LDKCOption_TypeZ_Some_meth = NULL;
5092 static jclass LDKCOption_TypeZ_None_class = NULL;
5093 static jmethodID LDKCOption_TypeZ_None_meth = NULL;
5094 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1TypeZ_init (JNIEnv *env, jclass clz) {
5095         LDKCOption_TypeZ_Some_class =
5096                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$Some;"));
5097         CHECK(LDKCOption_TypeZ_Some_class != NULL);
5098         LDKCOption_TypeZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_Some_class, "<init>", "(J)V");
5099         CHECK(LDKCOption_TypeZ_Some_meth != NULL);
5100         LDKCOption_TypeZ_None_class =
5101                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_TypeZ$None;"));
5102         CHECK(LDKCOption_TypeZ_None_class != NULL);
5103         LDKCOption_TypeZ_None_meth = (*env)->GetMethodID(env, LDKCOption_TypeZ_None_class, "<init>", "()V");
5104         CHECK(LDKCOption_TypeZ_None_meth != NULL);
5105 }
5106 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1TypeZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5107         LDKCOption_TypeZ *obj = (LDKCOption_TypeZ*)(ptr & ~1);
5108         switch(obj->tag) {
5109                 case LDKCOption_TypeZ_Some: {
5110                         LDKType* some_ret = MALLOC(sizeof(LDKType), "LDKType");
5111                         *some_ret = Type_clone(&obj->some);
5112                         return (*env)->NewObject(env, LDKCOption_TypeZ_Some_class, LDKCOption_TypeZ_Some_meth, (uint64_t)some_ret);
5113                 }
5114                 case LDKCOption_TypeZ_None: {
5115                         return (*env)->NewObject(env, LDKCOption_TypeZ_None_class, LDKCOption_TypeZ_None_meth);
5116                 }
5117                 default: abort();
5118         }
5119 }
5120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5121         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
5122         CHECK(val->result_ok);
5123         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5124         return res_ref;
5125 }
5126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1TypeZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5127         LDKCResult_COption_TypeZDecodeErrorZ *val = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
5128         CHECK(!val->result_ok);
5129         LDKDecodeError err_var = (*val->contents.err);
5130         uint64_t err_ref = 0;
5131         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5132         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5133         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5134         err_ref = (uint64_t)err_var.inner & ~1;
5135         return err_ref;
5136 }
5137 static jclass LDKPaymentError_Invoice_class = NULL;
5138 static jmethodID LDKPaymentError_Invoice_meth = NULL;
5139 static jclass LDKPaymentError_Routing_class = NULL;
5140 static jmethodID LDKPaymentError_Routing_meth = NULL;
5141 static jclass LDKPaymentError_Sending_class = NULL;
5142 static jmethodID LDKPaymentError_Sending_meth = NULL;
5143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKPaymentError_init (JNIEnv *env, jclass clz) {
5144         LDKPaymentError_Invoice_class =
5145                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Invoice;"));
5146         CHECK(LDKPaymentError_Invoice_class != NULL);
5147         LDKPaymentError_Invoice_meth = (*env)->GetMethodID(env, LDKPaymentError_Invoice_class, "<init>", "(Ljava/lang/String;)V");
5148         CHECK(LDKPaymentError_Invoice_meth != NULL);
5149         LDKPaymentError_Routing_class =
5150                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Routing;"));
5151         CHECK(LDKPaymentError_Routing_class != NULL);
5152         LDKPaymentError_Routing_meth = (*env)->GetMethodID(env, LDKPaymentError_Routing_class, "<init>", "(J)V");
5153         CHECK(LDKPaymentError_Routing_meth != NULL);
5154         LDKPaymentError_Sending_class =
5155                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKPaymentError$Sending;"));
5156         CHECK(LDKPaymentError_Sending_class != NULL);
5157         LDKPaymentError_Sending_meth = (*env)->GetMethodID(env, LDKPaymentError_Sending_class, "<init>", "(J)V");
5158         CHECK(LDKPaymentError_Sending_meth != NULL);
5159 }
5160 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKPaymentError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5161         LDKPaymentError *obj = (LDKPaymentError*)(ptr & ~1);
5162         switch(obj->tag) {
5163                 case LDKPaymentError_Invoice: {
5164                         LDKStr invoice_str = obj->invoice;
5165                         jstring invoice_conv = str_ref_to_java(env, invoice_str.chars, invoice_str.len);
5166                         return (*env)->NewObject(env, LDKPaymentError_Invoice_class, LDKPaymentError_Invoice_meth, invoice_conv);
5167                 }
5168                 case LDKPaymentError_Routing: {
5169                         LDKLightningError routing_var = obj->routing;
5170                         uint64_t routing_ref = 0;
5171                         CHECK((((uint64_t)routing_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5172                         CHECK((((uint64_t)&routing_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5173                         CHECK_INNER_FIELD_ACCESS_OR_NULL(routing_var);
5174                         routing_ref = (uint64_t)routing_var.inner & ~1;
5175                         return (*env)->NewObject(env, LDKPaymentError_Routing_class, LDKPaymentError_Routing_meth, routing_ref);
5176                 }
5177                 case LDKPaymentError_Sending: {
5178                         uint64_t sending_ref = ((uint64_t)&obj->sending) | 1;
5179                         return (*env)->NewObject(env, LDKPaymentError_Sending_class, LDKPaymentError_Sending_meth, sending_ref);
5180                 }
5181                 default: abort();
5182         }
5183 }
5184 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5185         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
5186         CHECK(val->result_ok);
5187         int8_tArray res_arr = (*env)->NewByteArray(env, 32);
5188         (*env)->SetByteArrayRegion(env, res_arr, 0, 32, (*val->contents.result).data);
5189         return res_arr;
5190 }
5191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PaymentIdPaymentErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5192         LDKCResult_PaymentIdPaymentErrorZ *val = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
5193         CHECK(!val->result_ok);
5194         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
5195         return err_ref;
5196 }
5197 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5198         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
5199         CHECK(val->result_ok);
5200         jclass res_conv = LDKSiPrefix_to_java(env, (*val->contents.result));
5201         return res_conv;
5202 }
5203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SiPrefixNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5204         LDKCResult_SiPrefixNoneZ *val = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
5205         CHECK(!val->result_ok);
5206         return *val->contents.err;
5207 }
5208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5209         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
5210         CHECK(val->result_ok);
5211         LDKInvoice res_var = (*val->contents.result);
5212         uint64_t res_ref = 0;
5213         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5214         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5215         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5216         res_ref = (uint64_t)res_var.inner & ~1;
5217         return res_ref;
5218 }
5219 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5220         LDKCResult_InvoiceNoneZ *val = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
5221         CHECK(!val->result_ok);
5222         return *val->contents.err;
5223 }
5224 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5225         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
5226         CHECK(val->result_ok);
5227         LDKSignedRawInvoice res_var = (*val->contents.result);
5228         uint64_t res_ref = 0;
5229         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5230         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5231         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5232         res_ref = (uint64_t)res_var.inner & ~1;
5233         return res_ref;
5234 }
5235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1SignedRawInvoiceNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5236         LDKCResult_SignedRawInvoiceNoneZ *val = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
5237         CHECK(!val->result_ok);
5238         return *val->contents.err;
5239 }
5240 static inline struct LDKRawInvoice C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5241         return RawInvoice_clone(&tuple->a);
5242 }
5243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5244         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5245         LDKRawInvoice ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_a(tuple_conv);
5246         uint64_t ret_ref = 0;
5247         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5248         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5249         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5250         ret_ref = (uint64_t)ret_var.inner;
5251         if (ret_var.is_owned) {
5252                 ret_ref |= 1;
5253         }
5254         return ret_ref;
5255 }
5256
5257 static inline struct LDKThirtyTwoBytes C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5258         return ThirtyTwoBytes_clone(&tuple->b);
5259 }
5260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5261         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5262         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5263         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_b(tuple_conv).data);
5264         return ret_arr;
5265 }
5266
5267 static inline struct LDKInvoiceSignature C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR tuple){
5268         return InvoiceSignature_clone(&tuple->c);
5269 }
5270 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5271         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* tuple_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(tuple & ~1);
5272         LDKInvoiceSignature ret_var = C3Tuple_RawInvoice_u832InvoiceSignatureZ_get_c(tuple_conv);
5273         uint64_t ret_ref = 0;
5274         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5275         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5276         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5277         ret_ref = (uint64_t)ret_var.inner;
5278         if (ret_var.is_owned) {
5279                 ret_ref |= 1;
5280         }
5281         return ret_ref;
5282 }
5283
5284 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5285         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
5286         CHECK(val->result_ok);
5287         LDKPayeePubKey res_var = (*val->contents.result);
5288         uint64_t res_ref = 0;
5289         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5290         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5291         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5292         res_ref = (uint64_t)res_var.inner & ~1;
5293         return res_ref;
5294 }
5295 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PayeePubKeyErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5296         LDKCResult_PayeePubKeyErrorZ *val = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
5297         CHECK(!val->result_ok);
5298         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5299         return err_conv;
5300 }
5301 static inline LDKCVec_PrivateRouteZ CVec_PrivateRouteZ_clone(const LDKCVec_PrivateRouteZ *orig) {
5302         LDKCVec_PrivateRouteZ ret = { .data = MALLOC(sizeof(LDKPrivateRoute) * orig->datalen, "LDKCVec_PrivateRouteZ clone bytes"), .datalen = orig->datalen };
5303         for (size_t i = 0; i < ret.datalen; i++) {
5304                 ret.data[i] = PrivateRoute_clone(&orig->data[i]);
5305         }
5306         return ret;
5307 }
5308 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5309         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
5310         CHECK(val->result_ok);
5311         LDKPositiveTimestamp res_var = (*val->contents.result);
5312         uint64_t res_ref = 0;
5313         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5314         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5315         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5316         res_ref = (uint64_t)res_var.inner & ~1;
5317         return res_ref;
5318 }
5319 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PositiveTimestampCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5320         LDKCResult_PositiveTimestampCreationErrorZ *val = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
5321         CHECK(!val->result_ok);
5322         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5323         return err_conv;
5324 }
5325 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5326         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
5327         CHECK(val->result_ok);
5328         return *val->contents.result;
5329 }
5330 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5331         LDKCResult_NoneSemanticErrorZ *val = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
5332         CHECK(!val->result_ok);
5333         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
5334         return err_conv;
5335 }
5336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5337         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
5338         CHECK(val->result_ok);
5339         LDKInvoice res_var = (*val->contents.result);
5340         uint64_t res_ref = 0;
5341         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5342         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5343         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5344         res_ref = (uint64_t)res_var.inner & ~1;
5345         return res_ref;
5346 }
5347 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSemanticErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5348         LDKCResult_InvoiceSemanticErrorZ *val = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
5349         CHECK(!val->result_ok);
5350         jclass err_conv = LDKSemanticError_to_java(env, (*val->contents.err));
5351         return err_conv;
5352 }
5353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5354         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5355         CHECK(val->result_ok);
5356         LDKDescription res_var = (*val->contents.result);
5357         uint64_t res_ref = 0;
5358         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5359         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5360         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5361         res_ref = (uint64_t)res_var.inner & ~1;
5362         return res_ref;
5363 }
5364 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DescriptionCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5365         LDKCResult_DescriptionCreationErrorZ *val = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
5366         CHECK(!val->result_ok);
5367         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5368         return err_conv;
5369 }
5370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5371         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5372         CHECK(val->result_ok);
5373         LDKExpiryTime res_var = (*val->contents.result);
5374         uint64_t res_ref = 0;
5375         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5376         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5377         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5378         res_ref = (uint64_t)res_var.inner & ~1;
5379         return res_ref;
5380 }
5381 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ExpiryTimeCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5382         LDKCResult_ExpiryTimeCreationErrorZ *val = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
5383         CHECK(!val->result_ok);
5384         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5385         return err_conv;
5386 }
5387 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5388         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5389         CHECK(val->result_ok);
5390         LDKPrivateRoute res_var = (*val->contents.result);
5391         uint64_t res_ref = 0;
5392         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5393         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5394         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5395         res_ref = (uint64_t)res_var.inner & ~1;
5396         return res_ref;
5397 }
5398 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PrivateRouteCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5399         LDKCResult_PrivateRouteCreationErrorZ *val = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
5400         CHECK(!val->result_ok);
5401         jclass err_conv = LDKCreationError_to_java(env, (*val->contents.err));
5402         return err_conv;
5403 }
5404 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5405         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5406         CHECK(val->result_ok);
5407         LDKStr res_str = (*val->contents.result);
5408         jstring res_conv = str_ref_to_java(env, res_str.chars, res_str.len);
5409         return res_conv;
5410 }
5411 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_LDKCResult_1StringErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5412         LDKCResult_StringErrorZ *val = (LDKCResult_StringErrorZ*)(arg & ~1);
5413         CHECK(!val->result_ok);
5414         jclass err_conv = LDKSecp256k1Error_to_java(env, (*val->contents.err));
5415         return err_conv;
5416 }
5417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5418         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5419         CHECK(val->result_ok);
5420         LDKChannelMonitorUpdate res_var = (*val->contents.result);
5421         uint64_t res_ref = 0;
5422         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5423         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5424         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5425         res_ref = (uint64_t)res_var.inner & ~1;
5426         return res_ref;
5427 }
5428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelMonitorUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5429         LDKCResult_ChannelMonitorUpdateDecodeErrorZ *val = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
5430         CHECK(!val->result_ok);
5431         LDKDecodeError err_var = (*val->contents.err);
5432         uint64_t err_ref = 0;
5433         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5434         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5435         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5436         err_ref = (uint64_t)err_var.inner & ~1;
5437         return err_ref;
5438 }
5439 static jclass LDKCOption_MonitorEventZ_Some_class = NULL;
5440 static jmethodID LDKCOption_MonitorEventZ_Some_meth = NULL;
5441 static jclass LDKCOption_MonitorEventZ_None_class = NULL;
5442 static jmethodID LDKCOption_MonitorEventZ_None_meth = NULL;
5443 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1MonitorEventZ_init (JNIEnv *env, jclass clz) {
5444         LDKCOption_MonitorEventZ_Some_class =
5445                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_MonitorEventZ$Some;"));
5446         CHECK(LDKCOption_MonitorEventZ_Some_class != NULL);
5447         LDKCOption_MonitorEventZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_Some_class, "<init>", "(J)V");
5448         CHECK(LDKCOption_MonitorEventZ_Some_meth != NULL);
5449         LDKCOption_MonitorEventZ_None_class =
5450                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_MonitorEventZ$None;"));
5451         CHECK(LDKCOption_MonitorEventZ_None_class != NULL);
5452         LDKCOption_MonitorEventZ_None_meth = (*env)->GetMethodID(env, LDKCOption_MonitorEventZ_None_class, "<init>", "()V");
5453         CHECK(LDKCOption_MonitorEventZ_None_meth != NULL);
5454 }
5455 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1MonitorEventZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5456         LDKCOption_MonitorEventZ *obj = (LDKCOption_MonitorEventZ*)(ptr & ~1);
5457         switch(obj->tag) {
5458                 case LDKCOption_MonitorEventZ_Some: {
5459                         uint64_t some_ref = ((uint64_t)&obj->some) | 1;
5460                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_Some_class, LDKCOption_MonitorEventZ_Some_meth, some_ref);
5461                 }
5462                 case LDKCOption_MonitorEventZ_None: {
5463                         return (*env)->NewObject(env, LDKCOption_MonitorEventZ_None_class, LDKCOption_MonitorEventZ_None_meth);
5464                 }
5465                 default: abort();
5466         }
5467 }
5468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1MonitorEventZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5469         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
5470         CHECK(val->result_ok);
5471         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5472         return res_ref;
5473 }
5474 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1MonitorEventZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5475         LDKCResult_COption_MonitorEventZDecodeErrorZ *val = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
5476         CHECK(!val->result_ok);
5477         LDKDecodeError err_var = (*val->contents.err);
5478         uint64_t err_ref = 0;
5479         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5480         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5481         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5482         err_ref = (uint64_t)err_var.inner & ~1;
5483         return err_ref;
5484 }
5485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5486         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5487         CHECK(val->result_ok);
5488         LDKHTLCUpdate res_var = (*val->contents.result);
5489         uint64_t res_ref = 0;
5490         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5491         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5492         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5493         res_ref = (uint64_t)res_var.inner & ~1;
5494         return res_ref;
5495 }
5496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1HTLCUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5497         LDKCResult_HTLCUpdateDecodeErrorZ *val = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
5498         CHECK(!val->result_ok);
5499         LDKDecodeError err_var = (*val->contents.err);
5500         uint64_t err_ref = 0;
5501         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5502         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5503         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5504         err_ref = (uint64_t)err_var.inner & ~1;
5505         return err_ref;
5506 }
5507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5508         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5509         CHECK(val->result_ok);
5510         return *val->contents.result;
5511 }
5512 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneMonitorUpdateErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5513         LDKCResult_NoneMonitorUpdateErrorZ *val = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
5514         CHECK(!val->result_ok);
5515         LDKMonitorUpdateError err_var = (*val->contents.err);
5516         uint64_t err_ref = 0;
5517         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5518         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5519         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5520         err_ref = (uint64_t)err_var.inner & ~1;
5521         return err_ref;
5522 }
5523 static inline struct LDKOutPoint C2Tuple_OutPointScriptZ_get_a(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5524         return OutPoint_clone(&tuple->a);
5525 }
5526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5527         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5528         LDKOutPoint ret_var = C2Tuple_OutPointScriptZ_get_a(tuple_conv);
5529         uint64_t ret_ref = 0;
5530         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5531         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5532         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5533         ret_ref = (uint64_t)ret_var.inner;
5534         if (ret_var.is_owned) {
5535                 ret_ref |= 1;
5536         }
5537         return ret_ref;
5538 }
5539
5540 static inline struct LDKCVec_u8Z C2Tuple_OutPointScriptZ_get_b(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR tuple){
5541         return CVec_u8Z_clone(&tuple->b);
5542 }
5543 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5544         LDKC2Tuple_OutPointScriptZ* tuple_conv = (LDKC2Tuple_OutPointScriptZ*)(tuple & ~1);
5545         LDKCVec_u8Z ret_var = C2Tuple_OutPointScriptZ_get_b(tuple_conv);
5546         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5547         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5548         CVec_u8Z_free(ret_var);
5549         return ret_arr;
5550 }
5551
5552 static inline uint32_t C2Tuple_u32ScriptZ_get_a(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5553         return tuple->a;
5554 }
5555 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5556         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5557         int32_t ret_val = C2Tuple_u32ScriptZ_get_a(tuple_conv);
5558         return ret_val;
5559 }
5560
5561 static inline struct LDKCVec_u8Z C2Tuple_u32ScriptZ_get_b(LDKC2Tuple_u32ScriptZ *NONNULL_PTR tuple){
5562         return CVec_u8Z_clone(&tuple->b);
5563 }
5564 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5565         LDKC2Tuple_u32ScriptZ* tuple_conv = (LDKC2Tuple_u32ScriptZ*)(tuple & ~1);
5566         LDKCVec_u8Z ret_var = C2Tuple_u32ScriptZ_get_b(tuple_conv);
5567         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
5568         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
5569         CVec_u8Z_free(ret_var);
5570         return ret_arr;
5571 }
5572
5573 static inline LDKCVec_C2Tuple_u32ScriptZZ CVec_C2Tuple_u32ScriptZZ_clone(const LDKCVec_C2Tuple_u32ScriptZZ *orig) {
5574         LDKCVec_C2Tuple_u32ScriptZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ) * orig->datalen, "LDKCVec_C2Tuple_u32ScriptZZ clone bytes"), .datalen = orig->datalen };
5575         for (size_t i = 0; i < ret.datalen; i++) {
5576                 ret.data[i] = C2Tuple_u32ScriptZ_clone(&orig->data[i]);
5577         }
5578         return ret;
5579 }
5580 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5581         return ThirtyTwoBytes_clone(&tuple->a);
5582 }
5583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5584         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5585         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5586         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_a(tuple_conv).data);
5587         return ret_arr;
5588 }
5589
5590 static inline struct LDKCVec_C2Tuple_u32ScriptZZ C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR tuple){
5591         return CVec_C2Tuple_u32ScriptZZ_clone(&tuple->b);
5592 }
5593 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5594         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(tuple & ~1);
5595         LDKCVec_C2Tuple_u32ScriptZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_get_b(tuple_conv);
5596         int64_tArray ret_arr = NULL;
5597         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5598         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5599         for (size_t v = 0; v < ret_var.datalen; v++) {
5600                 LDKC2Tuple_u32ScriptZ* ret_conv_21_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
5601                 *ret_conv_21_conv = ret_var.data[v];
5602                 ret_arr_ptr[v] = ((uint64_t)ret_conv_21_conv);
5603         }
5604         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5605         FREE(ret_var.data);
5606         return ret_arr;
5607 }
5608
5609 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ *orig) {
5610         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 };
5611         for (size_t i = 0; i < ret.datalen; i++) {
5612                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(&orig->data[i]);
5613         }
5614         return ret;
5615 }
5616 static inline LDKCVec_EventZ CVec_EventZ_clone(const LDKCVec_EventZ *orig) {
5617         LDKCVec_EventZ ret = { .data = MALLOC(sizeof(LDKEvent) * orig->datalen, "LDKCVec_EventZ clone bytes"), .datalen = orig->datalen };
5618         for (size_t i = 0; i < ret.datalen; i++) {
5619                 ret.data[i] = Event_clone(&orig->data[i]);
5620         }
5621         return ret;
5622 }
5623 static inline uint32_t C2Tuple_u32TxOutZ_get_a(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5624         return tuple->a;
5625 }
5626 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5627         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5628         int32_t ret_val = C2Tuple_u32TxOutZ_get_a(tuple_conv);
5629         return ret_val;
5630 }
5631
5632 static inline struct LDKTxOut C2Tuple_u32TxOutZ_get_b(LDKC2Tuple_u32TxOutZ *NONNULL_PTR tuple){
5633         return TxOut_clone(&tuple->b);
5634 }
5635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5636         LDKC2Tuple_u32TxOutZ* tuple_conv = (LDKC2Tuple_u32TxOutZ*)(tuple & ~1);
5637         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
5638         *ret_ref = C2Tuple_u32TxOutZ_get_b(tuple_conv);
5639         return (uint64_t)ret_ref;
5640 }
5641
5642 static inline LDKCVec_C2Tuple_u32TxOutZZ CVec_C2Tuple_u32TxOutZZ_clone(const LDKCVec_C2Tuple_u32TxOutZZ *orig) {
5643         LDKCVec_C2Tuple_u32TxOutZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ) * orig->datalen, "LDKCVec_C2Tuple_u32TxOutZZ clone bytes"), .datalen = orig->datalen };
5644         for (size_t i = 0; i < ret.datalen; i++) {
5645                 ret.data[i] = C2Tuple_u32TxOutZ_clone(&orig->data[i]);
5646         }
5647         return ret;
5648 }
5649 static inline struct LDKThirtyTwoBytes C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5650         return ThirtyTwoBytes_clone(&tuple->a);
5651 }
5652 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5653         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5654         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
5655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_a(tuple_conv).data);
5656         return ret_arr;
5657 }
5658
5659 static inline struct LDKCVec_C2Tuple_u32TxOutZZ C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR tuple){
5660         return CVec_C2Tuple_u32TxOutZZ_clone(&tuple->b);
5661 }
5662 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5663         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* tuple_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(tuple & ~1);
5664         LDKCVec_C2Tuple_u32TxOutZZ ret_var = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_get_b(tuple_conv);
5665         int64_tArray ret_arr = NULL;
5666         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
5667         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
5668         for (size_t u = 0; u < ret_var.datalen; u++) {
5669                 LDKC2Tuple_u32TxOutZ* ret_conv_20_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
5670                 *ret_conv_20_conv = ret_var.data[u];
5671                 ret_arr_ptr[u] = ((uint64_t)ret_conv_20_conv);
5672         }
5673         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
5674         FREE(ret_var.data);
5675         return ret_arr;
5676 }
5677
5678 static inline LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_clone(const LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ *orig) {
5679         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 };
5680         for (size_t i = 0; i < ret.datalen; i++) {
5681                 ret.data[i] = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(&orig->data[i]);
5682         }
5683         return ret;
5684 }
5685 static jclass LDKBalance_ClaimableOnChannelClose_class = NULL;
5686 static jmethodID LDKBalance_ClaimableOnChannelClose_meth = NULL;
5687 static jclass LDKBalance_ClaimableAwaitingConfirmations_class = NULL;
5688 static jmethodID LDKBalance_ClaimableAwaitingConfirmations_meth = NULL;
5689 static jclass LDKBalance_ContentiousClaimable_class = NULL;
5690 static jmethodID LDKBalance_ContentiousClaimable_meth = NULL;
5691 static jclass LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class = NULL;
5692 static jmethodID LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = NULL;
5693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKBalance_init (JNIEnv *env, jclass clz) {
5694         LDKBalance_ClaimableOnChannelClose_class =
5695                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableOnChannelClose;"));
5696         CHECK(LDKBalance_ClaimableOnChannelClose_class != NULL);
5697         LDKBalance_ClaimableOnChannelClose_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableOnChannelClose_class, "<init>", "(J)V");
5698         CHECK(LDKBalance_ClaimableOnChannelClose_meth != NULL);
5699         LDKBalance_ClaimableAwaitingConfirmations_class =
5700                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ClaimableAwaitingConfirmations;"));
5701         CHECK(LDKBalance_ClaimableAwaitingConfirmations_class != NULL);
5702         LDKBalance_ClaimableAwaitingConfirmations_meth = (*env)->GetMethodID(env, LDKBalance_ClaimableAwaitingConfirmations_class, "<init>", "(JI)V");
5703         CHECK(LDKBalance_ClaimableAwaitingConfirmations_meth != NULL);
5704         LDKBalance_ContentiousClaimable_class =
5705                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$ContentiousClaimable;"));
5706         CHECK(LDKBalance_ContentiousClaimable_class != NULL);
5707         LDKBalance_ContentiousClaimable_meth = (*env)->GetMethodID(env, LDKBalance_ContentiousClaimable_class, "<init>", "(JI)V");
5708         CHECK(LDKBalance_ContentiousClaimable_meth != NULL);
5709         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class =
5710                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKBalance$MaybeClaimableHTLCAwaitingTimeout;"));
5711         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class != NULL);
5712         LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth = (*env)->GetMethodID(env, LDKBalance_MaybeClaimableHTLCAwaitingTimeout_class, "<init>", "(JI)V");
5713         CHECK(LDKBalance_MaybeClaimableHTLCAwaitingTimeout_meth != NULL);
5714 }
5715 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKBalance_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
5716         LDKBalance *obj = (LDKBalance*)(ptr & ~1);
5717         switch(obj->tag) {
5718                 case LDKBalance_ClaimableOnChannelClose: {
5719                         return (*env)->NewObject(env, LDKBalance_ClaimableOnChannelClose_class, LDKBalance_ClaimableOnChannelClose_meth, obj->claimable_on_channel_close.claimable_amount_satoshis);
5720                 }
5721                 case LDKBalance_ClaimableAwaitingConfirmations: {
5722                         return (*env)->NewObject(env, LDKBalance_ClaimableAwaitingConfirmations_class, LDKBalance_ClaimableAwaitingConfirmations_meth, obj->claimable_awaiting_confirmations.claimable_amount_satoshis, obj->claimable_awaiting_confirmations.confirmation_height);
5723                 }
5724                 case LDKBalance_ContentiousClaimable: {
5725                         return (*env)->NewObject(env, LDKBalance_ContentiousClaimable_class, LDKBalance_ContentiousClaimable_meth, obj->contentious_claimable.claimable_amount_satoshis, obj->contentious_claimable.timeout_height);
5726                 }
5727                 case LDKBalance_MaybeClaimableHTLCAwaitingTimeout: {
5728                         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);
5729                 }
5730                 default: abort();
5731         }
5732 }
5733 static inline LDKCVec_BalanceZ CVec_BalanceZ_clone(const LDKCVec_BalanceZ *orig) {
5734         LDKCVec_BalanceZ ret = { .data = MALLOC(sizeof(LDKBalance) * orig->datalen, "LDKCVec_BalanceZ clone bytes"), .datalen = orig->datalen };
5735         for (size_t i = 0; i < ret.datalen; i++) {
5736                 ret.data[i] = Balance_clone(&orig->data[i]);
5737         }
5738         return ret;
5739 }
5740 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5741         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5742         CHECK(val->result_ok);
5743         LDKC2Tuple_BlockHashChannelMonitorZ* res_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
5744         *res_conv = (*val->contents.result);
5745         *res_conv = C2Tuple_BlockHashChannelMonitorZ_clone(res_conv);
5746         return ((uint64_t)res_conv);
5747 }
5748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5749         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *val = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
5750         CHECK(!val->result_ok);
5751         LDKDecodeError err_var = (*val->contents.err);
5752         uint64_t err_ref = 0;
5753         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5754         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5755         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5756         err_ref = (uint64_t)err_var.inner & ~1;
5757         return err_ref;
5758 }
5759 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5760         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5761         CHECK(val->result_ok);
5762         return *val->contents.result;
5763 }
5764 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NoneLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5765         LDKCResult_NoneLightningErrorZ *val = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
5766         CHECK(!val->result_ok);
5767         LDKLightningError err_var = (*val->contents.err);
5768         uint64_t err_ref = 0;
5769         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5770         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5771         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5772         err_ref = (uint64_t)err_var.inner & ~1;
5773         return err_ref;
5774 }
5775 static inline struct LDKPublicKey C2Tuple_PublicKeyTypeZ_get_a(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5776         return tuple->a;
5777 }
5778 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5779         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5780         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
5781         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, C2Tuple_PublicKeyTypeZ_get_a(tuple_conv).compressed_form);
5782         return ret_arr;
5783 }
5784
5785 static inline struct LDKType C2Tuple_PublicKeyTypeZ_get_b(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR tuple){
5786         return Type_clone(&tuple->b);
5787 }
5788 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5789         LDKC2Tuple_PublicKeyTypeZ* tuple_conv = (LDKC2Tuple_PublicKeyTypeZ*)(tuple & ~1);
5790         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
5791         *ret_ret = C2Tuple_PublicKeyTypeZ_get_b(tuple_conv);
5792         return (uint64_t)ret_ret;
5793 }
5794
5795 static inline LDKCVec_C2Tuple_PublicKeyTypeZZ CVec_C2Tuple_PublicKeyTypeZZ_clone(const LDKCVec_C2Tuple_PublicKeyTypeZZ *orig) {
5796         LDKCVec_C2Tuple_PublicKeyTypeZZ ret = { .data = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ) * orig->datalen, "LDKCVec_C2Tuple_PublicKeyTypeZZ clone bytes"), .datalen = orig->datalen };
5797         for (size_t i = 0; i < ret.datalen; i++) {
5798                 ret.data[i] = C2Tuple_PublicKeyTypeZ_clone(&orig->data[i]);
5799         }
5800         return ret;
5801 }
5802 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5803         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5804         CHECK(val->result_ok);
5805         return *val->contents.result;
5806 }
5807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolLightningErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5808         LDKCResult_boolLightningErrorZ *val = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
5809         CHECK(!val->result_ok);
5810         LDKLightningError err_var = (*val->contents.err);
5811         uint64_t err_ref = 0;
5812         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5813         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5814         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5815         err_ref = (uint64_t)err_var.inner & ~1;
5816         return err_ref;
5817 }
5818 static inline struct LDKChannelAnnouncement C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5819         return ChannelAnnouncement_clone(&tuple->a);
5820 }
5821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1a(JNIEnv *env, jclass clz, int64_t tuple) {
5822         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5823         LDKChannelAnnouncement ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_a(tuple_conv);
5824         uint64_t ret_ref = 0;
5825         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5826         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5827         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5828         ret_ref = (uint64_t)ret_var.inner;
5829         if (ret_var.is_owned) {
5830                 ret_ref |= 1;
5831         }
5832         return ret_ref;
5833 }
5834
5835 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5836         return ChannelUpdate_clone(&tuple->b);
5837 }
5838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1b(JNIEnv *env, jclass clz, int64_t tuple) {
5839         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5840         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_b(tuple_conv);
5841         uint64_t ret_ref = 0;
5842         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5843         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5844         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5845         ret_ref = (uint64_t)ret_var.inner;
5846         if (ret_var.is_owned) {
5847                 ret_ref |= 1;
5848         }
5849         return ret_ref;
5850 }
5851
5852 static inline struct LDKChannelUpdate C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR tuple){
5853         return ChannelUpdate_clone(&tuple->c);
5854 }
5855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1get_1c(JNIEnv *env, jclass clz, int64_t tuple) {
5856         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* tuple_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(tuple & ~1);
5857         LDKChannelUpdate ret_var = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_get_c(tuple_conv);
5858         uint64_t ret_ref = 0;
5859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
5862         ret_ref = (uint64_t)ret_var.inner;
5863         if (ret_var.is_owned) {
5864                 ret_ref |= 1;
5865         }
5866         return ret_ref;
5867 }
5868
5869 static inline LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_clone(const LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ *orig) {
5870         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret = { .data = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ) * orig->datalen, "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ clone bytes"), .datalen = orig->datalen };
5871         for (size_t i = 0; i < ret.datalen; i++) {
5872                 ret.data[i] = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(&orig->data[i]);
5873         }
5874         return ret;
5875 }
5876 static inline LDKCVec_NodeAnnouncementZ CVec_NodeAnnouncementZ_clone(const LDKCVec_NodeAnnouncementZ *orig) {
5877         LDKCVec_NodeAnnouncementZ ret = { .data = MALLOC(sizeof(LDKNodeAnnouncement) * orig->datalen, "LDKCVec_NodeAnnouncementZ clone bytes"), .datalen = orig->datalen };
5878         for (size_t i = 0; i < ret.datalen; i++) {
5879                 ret.data[i] = NodeAnnouncement_clone(&orig->data[i]);
5880         }
5881         return ret;
5882 }
5883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5884         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5885         CHECK(val->result_ok);
5886         LDKCVec_u8Z res_var = (*val->contents.result);
5887         int8_tArray res_arr = (*env)->NewByteArray(env, res_var.datalen);
5888         (*env)->SetByteArrayRegion(env, res_arr, 0, res_var.datalen, res_var.data);
5889         return res_arr;
5890 }
5891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CVec_1u8ZPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5892         LDKCResult_CVec_u8ZPeerHandleErrorZ *val = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
5893         CHECK(!val->result_ok);
5894         LDKPeerHandleError err_var = (*val->contents.err);
5895         uint64_t err_ref = 0;
5896         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5897         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5898         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5899         err_ref = (uint64_t)err_var.inner & ~1;
5900         return err_ref;
5901 }
5902 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5903         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5904         CHECK(val->result_ok);
5905         return *val->contents.result;
5906 }
5907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NonePeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5908         LDKCResult_NonePeerHandleErrorZ *val = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
5909         CHECK(!val->result_ok);
5910         LDKPeerHandleError err_var = (*val->contents.err);
5911         uint64_t err_ref = 0;
5912         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5913         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5914         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5915         err_ref = (uint64_t)err_var.inner & ~1;
5916         return err_ref;
5917 }
5918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5919         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5920         CHECK(val->result_ok);
5921         return *val->contents.result;
5922 }
5923 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1boolPeerHandleErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5924         LDKCResult_boolPeerHandleErrorZ *val = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
5925         CHECK(!val->result_ok);
5926         LDKPeerHandleError err_var = (*val->contents.err);
5927         uint64_t err_ref = 0;
5928         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5929         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5930         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5931         err_ref = (uint64_t)err_var.inner & ~1;
5932         return err_ref;
5933 }
5934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5935         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
5936         CHECK(val->result_ok);
5937         LDKNodeId res_var = (*val->contents.result);
5938         uint64_t res_ref = 0;
5939         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5940         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5941         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
5942         res_ref = (uint64_t)res_var.inner & ~1;
5943         return res_ref;
5944 }
5945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeIdDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5946         LDKCResult_NodeIdDecodeErrorZ *val = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
5947         CHECK(!val->result_ok);
5948         LDKDecodeError err_var = (*val->contents.err);
5949         uint64_t err_ref = 0;
5950         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5951         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5952         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5953         err_ref = (uint64_t)err_var.inner & ~1;
5954         return err_ref;
5955 }
5956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
5957         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
5958         CHECK(val->result_ok);
5959         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
5960         return res_ref;
5961 }
5962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1COption_1NetworkUpdateZDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
5963         LDKCResult_COption_NetworkUpdateZDecodeErrorZ *val = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
5964         CHECK(!val->result_ok);
5965         LDKDecodeError err_var = (*val->contents.err);
5966         uint64_t err_ref = 0;
5967         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
5968         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
5969         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
5970         err_ref = (uint64_t)err_var.inner & ~1;
5971         return err_ref;
5972 }
5973 typedef struct LDKAccess_JCalls {
5974         atomic_size_t refcnt;
5975         JavaVM *vm;
5976         jweak o;
5977         jmethodID get_utxo_meth;
5978 } LDKAccess_JCalls;
5979 static void LDKAccess_JCalls_free(void* this_arg) {
5980         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5981         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
5982                 JNIEnv *env;
5983                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
5984                 if (get_jenv_res == JNI_EDETACHED) {
5985                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
5986                 } else {
5987                         DO_ASSERT(get_jenv_res == JNI_OK);
5988                 }
5989                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
5990                 if (get_jenv_res == JNI_EDETACHED) {
5991                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
5992                 }
5993                 FREE(j_calls);
5994         }
5995 }
5996 LDKCResult_TxOutAccessErrorZ get_utxo_LDKAccess_jcall(const void* this_arg, const uint8_t (* genesis_hash)[32], uint64_t short_channel_id) {
5997         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) this_arg;
5998         JNIEnv *env;
5999         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
6000         if (get_jenv_res == JNI_EDETACHED) {
6001                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
6002         } else {
6003                 DO_ASSERT(get_jenv_res == JNI_OK);
6004         }
6005         int8_tArray genesis_hash_arr = (*env)->NewByteArray(env, 32);
6006         (*env)->SetByteArrayRegion(env, genesis_hash_arr, 0, 32, *genesis_hash);
6007         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
6008         CHECK(obj != NULL);
6009         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->get_utxo_meth, genesis_hash_arr, short_channel_id);
6010         if ((*env)->ExceptionCheck(env)) {
6011                 (*env)->ExceptionDescribe(env);
6012                 (*env)->FatalError(env, "A call to get_utxo in LDKAccess from rust threw an exception.");
6013         }
6014         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
6015         CHECK_ACCESS(ret_ptr);
6016         LDKCResult_TxOutAccessErrorZ ret_conv = *(LDKCResult_TxOutAccessErrorZ*)(ret_ptr);
6017         FREE((void*)ret);
6018         if (get_jenv_res == JNI_EDETACHED) {
6019                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
6020         }
6021         return ret_conv;
6022 }
6023 static void LDKAccess_JCalls_cloned(LDKAccess* new_obj) {
6024         LDKAccess_JCalls *j_calls = (LDKAccess_JCalls*) new_obj->this_arg;
6025         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
6026 }
6027 static inline LDKAccess LDKAccess_init (JNIEnv *env, jclass clz, jobject o) {
6028         jclass c = (*env)->GetObjectClass(env, o);
6029         CHECK(c != NULL);
6030         LDKAccess_JCalls *calls = MALLOC(sizeof(LDKAccess_JCalls), "LDKAccess_JCalls");
6031         atomic_init(&calls->refcnt, 1);
6032         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
6033         calls->o = (*env)->NewWeakGlobalRef(env, o);
6034         calls->get_utxo_meth = (*env)->GetMethodID(env, c, "get_utxo", "([BJ)J");
6035         CHECK(calls->get_utxo_meth != NULL);
6036
6037         LDKAccess ret = {
6038                 .this_arg = (void*) calls,
6039                 .get_utxo = get_utxo_LDKAccess_jcall,
6040                 .free = LDKAccess_JCalls_free,
6041         };
6042         return ret;
6043 }
6044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKAccess_1new(JNIEnv *env, jclass clz, jobject o) {
6045         LDKAccess *res_ptr = MALLOC(sizeof(LDKAccess), "LDKAccess");
6046         *res_ptr = LDKAccess_init(env, clz, o);
6047         return (uint64_t)res_ptr;
6048 }
6049 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) {
6050         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
6051         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
6052         LDKAccess* this_arg_conv = (LDKAccess*)this_arg_ptr;
6053         unsigned char genesis_hash_arr[32];
6054         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
6055         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_arr);
6056         unsigned char (*genesis_hash_ref)[32] = &genesis_hash_arr;
6057         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
6058         *ret_conv = (this_arg_conv->get_utxo)(this_arg_conv->this_arg, genesis_hash_ref, short_channel_id);
6059         return (uint64_t)ret_conv;
6060 }
6061
6062 static jclass LDKCOption_AccessZ_Some_class = NULL;
6063 static jmethodID LDKCOption_AccessZ_Some_meth = NULL;
6064 static jclass LDKCOption_AccessZ_None_class = NULL;
6065 static jmethodID LDKCOption_AccessZ_None_meth = NULL;
6066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1AccessZ_init (JNIEnv *env, jclass clz) {
6067         LDKCOption_AccessZ_Some_class =
6068                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$Some;"));
6069         CHECK(LDKCOption_AccessZ_Some_class != NULL);
6070         LDKCOption_AccessZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_Some_class, "<init>", "(J)V");
6071         CHECK(LDKCOption_AccessZ_Some_meth != NULL);
6072         LDKCOption_AccessZ_None_class =
6073                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_AccessZ$None;"));
6074         CHECK(LDKCOption_AccessZ_None_class != NULL);
6075         LDKCOption_AccessZ_None_meth = (*env)->GetMethodID(env, LDKCOption_AccessZ_None_class, "<init>", "()V");
6076         CHECK(LDKCOption_AccessZ_None_meth != NULL);
6077 }
6078 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1AccessZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6079         LDKCOption_AccessZ *obj = (LDKCOption_AccessZ*)(ptr & ~1);
6080         switch(obj->tag) {
6081                 case LDKCOption_AccessZ_Some: {
6082                         LDKAccess* some_ret = MALLOC(sizeof(LDKAccess), "LDKAccess");
6083                         *some_ret = obj->some;
6084                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
6085                         if ((*some_ret).free == LDKAccess_JCalls_free) {
6086                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
6087                                 LDKAccess_JCalls_cloned(&(*some_ret));
6088                         }
6089                         return (*env)->NewObject(env, LDKCOption_AccessZ_Some_class, LDKCOption_AccessZ_Some_meth, (uint64_t)some_ret);
6090                 }
6091                 case LDKCOption_AccessZ_None: {
6092                         return (*env)->NewObject(env, LDKCOption_AccessZ_None_class, LDKCOption_AccessZ_None_meth);
6093                 }
6094                 default: abort();
6095         }
6096 }
6097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6098         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6099         CHECK(val->result_ok);
6100         LDKDirectionalChannelInfo res_var = (*val->contents.result);
6101         uint64_t res_ref = 0;
6102         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6103         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6104         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6105         res_ref = (uint64_t)res_var.inner & ~1;
6106         return res_ref;
6107 }
6108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1DirectionalChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6109         LDKCResult_DirectionalChannelInfoDecodeErrorZ *val = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
6110         CHECK(!val->result_ok);
6111         LDKDecodeError err_var = (*val->contents.err);
6112         uint64_t err_ref = 0;
6113         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6114         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6115         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6116         err_ref = (uint64_t)err_var.inner & ~1;
6117         return err_ref;
6118 }
6119 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6120         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6121         CHECK(val->result_ok);
6122         LDKChannelInfo res_var = (*val->contents.result);
6123         uint64_t res_ref = 0;
6124         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6125         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6126         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6127         res_ref = (uint64_t)res_var.inner & ~1;
6128         return res_ref;
6129 }
6130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6131         LDKCResult_ChannelInfoDecodeErrorZ *val = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
6132         CHECK(!val->result_ok);
6133         LDKDecodeError err_var = (*val->contents.err);
6134         uint64_t err_ref = 0;
6135         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6136         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6137         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6138         err_ref = (uint64_t)err_var.inner & ~1;
6139         return err_ref;
6140 }
6141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6142         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6143         CHECK(val->result_ok);
6144         LDKRoutingFees res_var = (*val->contents.result);
6145         uint64_t res_ref = 0;
6146         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6147         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6148         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6149         res_ref = (uint64_t)res_var.inner & ~1;
6150         return res_ref;
6151 }
6152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RoutingFeesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6153         LDKCResult_RoutingFeesDecodeErrorZ *val = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
6154         CHECK(!val->result_ok);
6155         LDKDecodeError err_var = (*val->contents.err);
6156         uint64_t err_ref = 0;
6157         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6158         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6159         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6160         err_ref = (uint64_t)err_var.inner & ~1;
6161         return err_ref;
6162 }
6163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6164         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6165         CHECK(val->result_ok);
6166         LDKNodeAnnouncementInfo res_var = (*val->contents.result);
6167         uint64_t res_ref = 0;
6168         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6169         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6170         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6171         res_ref = (uint64_t)res_var.inner & ~1;
6172         return res_ref;
6173 }
6174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6175         LDKCResult_NodeAnnouncementInfoDecodeErrorZ *val = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
6176         CHECK(!val->result_ok);
6177         LDKDecodeError err_var = (*val->contents.err);
6178         uint64_t err_ref = 0;
6179         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6180         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6181         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6182         err_ref = (uint64_t)err_var.inner & ~1;
6183         return err_ref;
6184 }
6185 static inline LDKCVec_u64Z CVec_u64Z_clone(const LDKCVec_u64Z *orig) {
6186         LDKCVec_u64Z ret = { .data = MALLOC(sizeof(int64_t) * orig->datalen, "LDKCVec_u64Z clone bytes"), .datalen = orig->datalen };
6187         memcpy(ret.data, orig->data, sizeof(int64_t) * ret.datalen);
6188         return ret;
6189 }
6190 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6191         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6192         CHECK(val->result_ok);
6193         LDKNodeInfo res_var = (*val->contents.result);
6194         uint64_t res_ref = 0;
6195         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6196         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6197         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6198         res_ref = (uint64_t)res_var.inner & ~1;
6199         return res_ref;
6200 }
6201 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeInfoDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6202         LDKCResult_NodeInfoDecodeErrorZ *val = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
6203         CHECK(!val->result_ok);
6204         LDKDecodeError err_var = (*val->contents.err);
6205         uint64_t err_ref = 0;
6206         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6207         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6208         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6209         err_ref = (uint64_t)err_var.inner & ~1;
6210         return err_ref;
6211 }
6212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6213         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6214         CHECK(val->result_ok);
6215         LDKNetworkGraph res_var = (*val->contents.result);
6216         uint64_t res_ref = 0;
6217         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6218         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6219         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6220         res_ref = (uint64_t)res_var.inner & ~1;
6221         return res_ref;
6222 }
6223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetworkGraphDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6224         LDKCResult_NetworkGraphDecodeErrorZ *val = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
6225         CHECK(!val->result_ok);
6226         LDKDecodeError err_var = (*val->contents.err);
6227         uint64_t err_ref = 0;
6228         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6229         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6230         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6231         err_ref = (uint64_t)err_var.inner & ~1;
6232         return err_ref;
6233 }
6234 static jclass LDKCOption_CVec_NetAddressZZ_Some_class = NULL;
6235 static jmethodID LDKCOption_CVec_NetAddressZZ_Some_meth = NULL;
6236 static jclass LDKCOption_CVec_NetAddressZZ_None_class = NULL;
6237 static jmethodID LDKCOption_CVec_NetAddressZZ_None_meth = NULL;
6238 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1CVec_1NetAddressZZ_init (JNIEnv *env, jclass clz) {
6239         LDKCOption_CVec_NetAddressZZ_Some_class =
6240                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$Some;"));
6241         CHECK(LDKCOption_CVec_NetAddressZZ_Some_class != NULL);
6242         LDKCOption_CVec_NetAddressZZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_Some_class, "<init>", "([J)V");
6243         CHECK(LDKCOption_CVec_NetAddressZZ_Some_meth != NULL);
6244         LDKCOption_CVec_NetAddressZZ_None_class =
6245                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_CVec_NetAddressZZ$None;"));
6246         CHECK(LDKCOption_CVec_NetAddressZZ_None_class != NULL);
6247         LDKCOption_CVec_NetAddressZZ_None_meth = (*env)->GetMethodID(env, LDKCOption_CVec_NetAddressZZ_None_class, "<init>", "()V");
6248         CHECK(LDKCOption_CVec_NetAddressZZ_None_meth != NULL);
6249 }
6250 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1CVec_1NetAddressZZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
6251         LDKCOption_CVec_NetAddressZZ *obj = (LDKCOption_CVec_NetAddressZZ*)(ptr & ~1);
6252         switch(obj->tag) {
6253                 case LDKCOption_CVec_NetAddressZZ_Some: {
6254                         LDKCVec_NetAddressZ some_var = obj->some;
6255                         int64_tArray some_arr = NULL;
6256                         some_arr = (*env)->NewLongArray(env, some_var.datalen);
6257                         int64_t *some_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, some_arr, NULL);
6258                         for (size_t m = 0; m < some_var.datalen; m++) {
6259                                 uint64_t some_conv_12_ref = ((uint64_t)&some_var.data[m]) | 1;
6260                                 some_arr_ptr[m] = some_conv_12_ref;
6261                         }
6262                         (*env)->ReleasePrimitiveArrayCritical(env, some_arr, some_arr_ptr, 0);
6263                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_Some_class, LDKCOption_CVec_NetAddressZZ_Some_meth, some_arr);
6264                 }
6265                 case LDKCOption_CVec_NetAddressZZ_None: {
6266                         return (*env)->NewObject(env, LDKCOption_CVec_NetAddressZZ_None_class, LDKCOption_CVec_NetAddressZZ_None_meth);
6267                 }
6268                 default: abort();
6269         }
6270 }
6271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6272         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6273         CHECK(val->result_ok);
6274         uint64_t res_ref = ((uint64_t)&(*val->contents.result)) | 1;
6275         return res_ref;
6276 }
6277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NetAddressDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6278         LDKCResult_NetAddressDecodeErrorZ *val = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
6279         CHECK(!val->result_ok);
6280         LDKDecodeError err_var = (*val->contents.err);
6281         uint64_t err_ref = 0;
6282         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6283         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6284         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6285         err_ref = (uint64_t)err_var.inner & ~1;
6286         return err_ref;
6287 }
6288 static inline LDKCVec_UpdateAddHTLCZ CVec_UpdateAddHTLCZ_clone(const LDKCVec_UpdateAddHTLCZ *orig) {
6289         LDKCVec_UpdateAddHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateAddHTLC) * orig->datalen, "LDKCVec_UpdateAddHTLCZ clone bytes"), .datalen = orig->datalen };
6290         for (size_t i = 0; i < ret.datalen; i++) {
6291                 ret.data[i] = UpdateAddHTLC_clone(&orig->data[i]);
6292         }
6293         return ret;
6294 }
6295 static inline LDKCVec_UpdateFulfillHTLCZ CVec_UpdateFulfillHTLCZ_clone(const LDKCVec_UpdateFulfillHTLCZ *orig) {
6296         LDKCVec_UpdateFulfillHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFulfillHTLC) * orig->datalen, "LDKCVec_UpdateFulfillHTLCZ clone bytes"), .datalen = orig->datalen };
6297         for (size_t i = 0; i < ret.datalen; i++) {
6298                 ret.data[i] = UpdateFulfillHTLC_clone(&orig->data[i]);
6299         }
6300         return ret;
6301 }
6302 static inline LDKCVec_UpdateFailHTLCZ CVec_UpdateFailHTLCZ_clone(const LDKCVec_UpdateFailHTLCZ *orig) {
6303         LDKCVec_UpdateFailHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailHTLC) * orig->datalen, "LDKCVec_UpdateFailHTLCZ clone bytes"), .datalen = orig->datalen };
6304         for (size_t i = 0; i < ret.datalen; i++) {
6305                 ret.data[i] = UpdateFailHTLC_clone(&orig->data[i]);
6306         }
6307         return ret;
6308 }
6309 static inline LDKCVec_UpdateFailMalformedHTLCZ CVec_UpdateFailMalformedHTLCZ_clone(const LDKCVec_UpdateFailMalformedHTLCZ *orig) {
6310         LDKCVec_UpdateFailMalformedHTLCZ ret = { .data = MALLOC(sizeof(LDKUpdateFailMalformedHTLC) * orig->datalen, "LDKCVec_UpdateFailMalformedHTLCZ clone bytes"), .datalen = orig->datalen };
6311         for (size_t i = 0; i < ret.datalen; i++) {
6312                 ret.data[i] = UpdateFailMalformedHTLC_clone(&orig->data[i]);
6313         }
6314         return ret;
6315 }
6316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6317         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6318         CHECK(val->result_ok);
6319         LDKAcceptChannel res_var = (*val->contents.result);
6320         uint64_t res_ref = 0;
6321         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6322         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6323         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6324         res_ref = (uint64_t)res_var.inner & ~1;
6325         return res_ref;
6326 }
6327 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AcceptChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6328         LDKCResult_AcceptChannelDecodeErrorZ *val = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
6329         CHECK(!val->result_ok);
6330         LDKDecodeError err_var = (*val->contents.err);
6331         uint64_t err_ref = 0;
6332         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6333         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6334         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6335         err_ref = (uint64_t)err_var.inner & ~1;
6336         return err_ref;
6337 }
6338 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6339         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6340         CHECK(val->result_ok);
6341         LDKAnnouncementSignatures res_var = (*val->contents.result);
6342         uint64_t res_ref = 0;
6343         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6344         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6345         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6346         res_ref = (uint64_t)res_var.inner & ~1;
6347         return res_ref;
6348 }
6349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1AnnouncementSignaturesDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6350         LDKCResult_AnnouncementSignaturesDecodeErrorZ *val = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
6351         CHECK(!val->result_ok);
6352         LDKDecodeError err_var = (*val->contents.err);
6353         uint64_t err_ref = 0;
6354         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6355         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6356         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6357         err_ref = (uint64_t)err_var.inner & ~1;
6358         return err_ref;
6359 }
6360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6361         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6362         CHECK(val->result_ok);
6363         LDKChannelReestablish res_var = (*val->contents.result);
6364         uint64_t res_ref = 0;
6365         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6366         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6367         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6368         res_ref = (uint64_t)res_var.inner & ~1;
6369         return res_ref;
6370 }
6371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelReestablishDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6372         LDKCResult_ChannelReestablishDecodeErrorZ *val = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
6373         CHECK(!val->result_ok);
6374         LDKDecodeError err_var = (*val->contents.err);
6375         uint64_t err_ref = 0;
6376         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6377         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6378         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6379         err_ref = (uint64_t)err_var.inner & ~1;
6380         return err_ref;
6381 }
6382 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6383         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6384         CHECK(val->result_ok);
6385         LDKClosingSigned res_var = (*val->contents.result);
6386         uint64_t res_ref = 0;
6387         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6388         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6389         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6390         res_ref = (uint64_t)res_var.inner & ~1;
6391         return res_ref;
6392 }
6393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6394         LDKCResult_ClosingSignedDecodeErrorZ *val = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
6395         CHECK(!val->result_ok);
6396         LDKDecodeError err_var = (*val->contents.err);
6397         uint64_t err_ref = 0;
6398         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6399         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6400         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6401         err_ref = (uint64_t)err_var.inner & ~1;
6402         return err_ref;
6403 }
6404 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6405         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6406         CHECK(val->result_ok);
6407         LDKClosingSignedFeeRange res_var = (*val->contents.result);
6408         uint64_t res_ref = 0;
6409         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6410         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6411         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6412         res_ref = (uint64_t)res_var.inner & ~1;
6413         return res_ref;
6414 }
6415 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ClosingSignedFeeRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6416         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *val = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
6417         CHECK(!val->result_ok);
6418         LDKDecodeError err_var = (*val->contents.err);
6419         uint64_t err_ref = 0;
6420         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6421         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6422         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6423         err_ref = (uint64_t)err_var.inner & ~1;
6424         return err_ref;
6425 }
6426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6427         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6428         CHECK(val->result_ok);
6429         LDKCommitmentSigned res_var = (*val->contents.result);
6430         uint64_t res_ref = 0;
6431         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6432         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6433         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6434         res_ref = (uint64_t)res_var.inner & ~1;
6435         return res_ref;
6436 }
6437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1CommitmentSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6438         LDKCResult_CommitmentSignedDecodeErrorZ *val = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
6439         CHECK(!val->result_ok);
6440         LDKDecodeError err_var = (*val->contents.err);
6441         uint64_t err_ref = 0;
6442         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6443         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6444         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6445         err_ref = (uint64_t)err_var.inner & ~1;
6446         return err_ref;
6447 }
6448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6449         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6450         CHECK(val->result_ok);
6451         LDKFundingCreated res_var = (*val->contents.result);
6452         uint64_t res_ref = 0;
6453         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6454         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6455         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6456         res_ref = (uint64_t)res_var.inner & ~1;
6457         return res_ref;
6458 }
6459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingCreatedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6460         LDKCResult_FundingCreatedDecodeErrorZ *val = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
6461         CHECK(!val->result_ok);
6462         LDKDecodeError err_var = (*val->contents.err);
6463         uint64_t err_ref = 0;
6464         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6465         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6466         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6467         err_ref = (uint64_t)err_var.inner & ~1;
6468         return err_ref;
6469 }
6470 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6471         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6472         CHECK(val->result_ok);
6473         LDKFundingSigned res_var = (*val->contents.result);
6474         uint64_t res_ref = 0;
6475         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6476         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6477         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6478         res_ref = (uint64_t)res_var.inner & ~1;
6479         return res_ref;
6480 }
6481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingSignedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6482         LDKCResult_FundingSignedDecodeErrorZ *val = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
6483         CHECK(!val->result_ok);
6484         LDKDecodeError err_var = (*val->contents.err);
6485         uint64_t err_ref = 0;
6486         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6487         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6488         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6489         err_ref = (uint64_t)err_var.inner & ~1;
6490         return err_ref;
6491 }
6492 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6493         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6494         CHECK(val->result_ok);
6495         LDKFundingLocked res_var = (*val->contents.result);
6496         uint64_t res_ref = 0;
6497         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6498         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6499         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6500         res_ref = (uint64_t)res_var.inner & ~1;
6501         return res_ref;
6502 }
6503 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1FundingLockedDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6504         LDKCResult_FundingLockedDecodeErrorZ *val = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
6505         CHECK(!val->result_ok);
6506         LDKDecodeError err_var = (*val->contents.err);
6507         uint64_t err_ref = 0;
6508         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6509         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6510         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6511         err_ref = (uint64_t)err_var.inner & ~1;
6512         return err_ref;
6513 }
6514 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6515         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6516         CHECK(val->result_ok);
6517         LDKInit res_var = (*val->contents.result);
6518         uint64_t res_ref = 0;
6519         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6520         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6521         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6522         res_ref = (uint64_t)res_var.inner & ~1;
6523         return res_ref;
6524 }
6525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InitDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6526         LDKCResult_InitDecodeErrorZ *val = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
6527         CHECK(!val->result_ok);
6528         LDKDecodeError err_var = (*val->contents.err);
6529         uint64_t err_ref = 0;
6530         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6531         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6532         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6533         err_ref = (uint64_t)err_var.inner & ~1;
6534         return err_ref;
6535 }
6536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6537         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6538         CHECK(val->result_ok);
6539         LDKOpenChannel res_var = (*val->contents.result);
6540         uint64_t res_ref = 0;
6541         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6542         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6543         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6544         res_ref = (uint64_t)res_var.inner & ~1;
6545         return res_ref;
6546 }
6547 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1OpenChannelDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6548         LDKCResult_OpenChannelDecodeErrorZ *val = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
6549         CHECK(!val->result_ok);
6550         LDKDecodeError err_var = (*val->contents.err);
6551         uint64_t err_ref = 0;
6552         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6553         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6554         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6555         err_ref = (uint64_t)err_var.inner & ~1;
6556         return err_ref;
6557 }
6558 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6559         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6560         CHECK(val->result_ok);
6561         LDKRevokeAndACK res_var = (*val->contents.result);
6562         uint64_t res_ref = 0;
6563         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6564         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6565         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6566         res_ref = (uint64_t)res_var.inner & ~1;
6567         return res_ref;
6568 }
6569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1RevokeAndACKDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6570         LDKCResult_RevokeAndACKDecodeErrorZ *val = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
6571         CHECK(!val->result_ok);
6572         LDKDecodeError err_var = (*val->contents.err);
6573         uint64_t err_ref = 0;
6574         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6575         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6576         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6577         err_ref = (uint64_t)err_var.inner & ~1;
6578         return err_ref;
6579 }
6580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6581         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6582         CHECK(val->result_ok);
6583         LDKShutdown res_var = (*val->contents.result);
6584         uint64_t res_ref = 0;
6585         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6586         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6587         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6588         res_ref = (uint64_t)res_var.inner & ~1;
6589         return res_ref;
6590 }
6591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ShutdownDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6592         LDKCResult_ShutdownDecodeErrorZ *val = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
6593         CHECK(!val->result_ok);
6594         LDKDecodeError err_var = (*val->contents.err);
6595         uint64_t err_ref = 0;
6596         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6597         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6598         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6599         err_ref = (uint64_t)err_var.inner & ~1;
6600         return err_ref;
6601 }
6602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6603         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6604         CHECK(val->result_ok);
6605         LDKUpdateFailHTLC res_var = (*val->contents.result);
6606         uint64_t res_ref = 0;
6607         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6608         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6609         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6610         res_ref = (uint64_t)res_var.inner & ~1;
6611         return res_ref;
6612 }
6613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6614         LDKCResult_UpdateFailHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
6615         CHECK(!val->result_ok);
6616         LDKDecodeError err_var = (*val->contents.err);
6617         uint64_t err_ref = 0;
6618         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6619         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6620         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6621         err_ref = (uint64_t)err_var.inner & ~1;
6622         return err_ref;
6623 }
6624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6625         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6626         CHECK(val->result_ok);
6627         LDKUpdateFailMalformedHTLC res_var = (*val->contents.result);
6628         uint64_t res_ref = 0;
6629         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6630         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6631         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6632         res_ref = (uint64_t)res_var.inner & ~1;
6633         return res_ref;
6634 }
6635 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFailMalformedHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6636         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *val = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
6637         CHECK(!val->result_ok);
6638         LDKDecodeError err_var = (*val->contents.err);
6639         uint64_t err_ref = 0;
6640         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6641         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6642         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6643         err_ref = (uint64_t)err_var.inner & ~1;
6644         return err_ref;
6645 }
6646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6647         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6648         CHECK(val->result_ok);
6649         LDKUpdateFee res_var = (*val->contents.result);
6650         uint64_t res_ref = 0;
6651         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6652         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6653         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6654         res_ref = (uint64_t)res_var.inner & ~1;
6655         return res_ref;
6656 }
6657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFeeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6658         LDKCResult_UpdateFeeDecodeErrorZ *val = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
6659         CHECK(!val->result_ok);
6660         LDKDecodeError err_var = (*val->contents.err);
6661         uint64_t err_ref = 0;
6662         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6663         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6664         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6665         err_ref = (uint64_t)err_var.inner & ~1;
6666         return err_ref;
6667 }
6668 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6669         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6670         CHECK(val->result_ok);
6671         LDKUpdateFulfillHTLC res_var = (*val->contents.result);
6672         uint64_t res_ref = 0;
6673         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6674         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6675         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6676         res_ref = (uint64_t)res_var.inner & ~1;
6677         return res_ref;
6678 }
6679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateFulfillHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6680         LDKCResult_UpdateFulfillHTLCDecodeErrorZ *val = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
6681         CHECK(!val->result_ok);
6682         LDKDecodeError err_var = (*val->contents.err);
6683         uint64_t err_ref = 0;
6684         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6685         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6686         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6687         err_ref = (uint64_t)err_var.inner & ~1;
6688         return err_ref;
6689 }
6690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6691         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6692         CHECK(val->result_ok);
6693         LDKUpdateAddHTLC res_var = (*val->contents.result);
6694         uint64_t res_ref = 0;
6695         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6696         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6697         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6698         res_ref = (uint64_t)res_var.inner & ~1;
6699         return res_ref;
6700 }
6701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UpdateAddHTLCDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6702         LDKCResult_UpdateAddHTLCDecodeErrorZ *val = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
6703         CHECK(!val->result_ok);
6704         LDKDecodeError err_var = (*val->contents.err);
6705         uint64_t err_ref = 0;
6706         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6707         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6708         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6709         err_ref = (uint64_t)err_var.inner & ~1;
6710         return err_ref;
6711 }
6712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6713         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6714         CHECK(val->result_ok);
6715         LDKPing res_var = (*val->contents.result);
6716         uint64_t res_ref = 0;
6717         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6718         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6719         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6720         res_ref = (uint64_t)res_var.inner & ~1;
6721         return res_ref;
6722 }
6723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PingDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6724         LDKCResult_PingDecodeErrorZ *val = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
6725         CHECK(!val->result_ok);
6726         LDKDecodeError err_var = (*val->contents.err);
6727         uint64_t err_ref = 0;
6728         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6729         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6730         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6731         err_ref = (uint64_t)err_var.inner & ~1;
6732         return err_ref;
6733 }
6734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6735         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6736         CHECK(val->result_ok);
6737         LDKPong res_var = (*val->contents.result);
6738         uint64_t res_ref = 0;
6739         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6740         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6741         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6742         res_ref = (uint64_t)res_var.inner & ~1;
6743         return res_ref;
6744 }
6745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1PongDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6746         LDKCResult_PongDecodeErrorZ *val = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
6747         CHECK(!val->result_ok);
6748         LDKDecodeError err_var = (*val->contents.err);
6749         uint64_t err_ref = 0;
6750         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6751         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6752         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6753         err_ref = (uint64_t)err_var.inner & ~1;
6754         return err_ref;
6755 }
6756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6757         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6758         CHECK(val->result_ok);
6759         LDKUnsignedChannelAnnouncement res_var = (*val->contents.result);
6760         uint64_t res_ref = 0;
6761         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6762         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6763         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6764         res_ref = (uint64_t)res_var.inner & ~1;
6765         return res_ref;
6766 }
6767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6768         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6769         CHECK(!val->result_ok);
6770         LDKDecodeError err_var = (*val->contents.err);
6771         uint64_t err_ref = 0;
6772         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6773         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6774         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6775         err_ref = (uint64_t)err_var.inner & ~1;
6776         return err_ref;
6777 }
6778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6779         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6780         CHECK(val->result_ok);
6781         LDKChannelAnnouncement res_var = (*val->contents.result);
6782         uint64_t res_ref = 0;
6783         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6784         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6785         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6786         res_ref = (uint64_t)res_var.inner & ~1;
6787         return res_ref;
6788 }
6789 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6790         LDKCResult_ChannelAnnouncementDecodeErrorZ *val = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
6791         CHECK(!val->result_ok);
6792         LDKDecodeError err_var = (*val->contents.err);
6793         uint64_t err_ref = 0;
6794         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6795         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6796         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6797         err_ref = (uint64_t)err_var.inner & ~1;
6798         return err_ref;
6799 }
6800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6801         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6802         CHECK(val->result_ok);
6803         LDKUnsignedChannelUpdate res_var = (*val->contents.result);
6804         uint64_t res_ref = 0;
6805         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6806         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6807         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6808         res_ref = (uint64_t)res_var.inner & ~1;
6809         return res_ref;
6810 }
6811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6812         LDKCResult_UnsignedChannelUpdateDecodeErrorZ *val = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
6813         CHECK(!val->result_ok);
6814         LDKDecodeError err_var = (*val->contents.err);
6815         uint64_t err_ref = 0;
6816         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6817         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6818         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6819         err_ref = (uint64_t)err_var.inner & ~1;
6820         return err_ref;
6821 }
6822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6823         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6824         CHECK(val->result_ok);
6825         LDKChannelUpdate res_var = (*val->contents.result);
6826         uint64_t res_ref = 0;
6827         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6828         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6829         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6830         res_ref = (uint64_t)res_var.inner & ~1;
6831         return res_ref;
6832 }
6833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ChannelUpdateDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6834         LDKCResult_ChannelUpdateDecodeErrorZ *val = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
6835         CHECK(!val->result_ok);
6836         LDKDecodeError err_var = (*val->contents.err);
6837         uint64_t err_ref = 0;
6838         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6839         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6840         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6841         err_ref = (uint64_t)err_var.inner & ~1;
6842         return err_ref;
6843 }
6844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6845         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6846         CHECK(val->result_ok);
6847         LDKErrorMessage res_var = (*val->contents.result);
6848         uint64_t res_ref = 0;
6849         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6850         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6851         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6852         res_ref = (uint64_t)res_var.inner & ~1;
6853         return res_ref;
6854 }
6855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ErrorMessageDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6856         LDKCResult_ErrorMessageDecodeErrorZ *val = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
6857         CHECK(!val->result_ok);
6858         LDKDecodeError err_var = (*val->contents.err);
6859         uint64_t err_ref = 0;
6860         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6861         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6862         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6863         err_ref = (uint64_t)err_var.inner & ~1;
6864         return err_ref;
6865 }
6866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6867         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6868         CHECK(val->result_ok);
6869         LDKUnsignedNodeAnnouncement res_var = (*val->contents.result);
6870         uint64_t res_ref = 0;
6871         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6872         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6873         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6874         res_ref = (uint64_t)res_var.inner & ~1;
6875         return res_ref;
6876 }
6877 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1UnsignedNodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6878         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *val = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
6879         CHECK(!val->result_ok);
6880         LDKDecodeError err_var = (*val->contents.err);
6881         uint64_t err_ref = 0;
6882         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6883         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6884         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6885         err_ref = (uint64_t)err_var.inner & ~1;
6886         return err_ref;
6887 }
6888 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6889         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6890         CHECK(val->result_ok);
6891         LDKNodeAnnouncement res_var = (*val->contents.result);
6892         uint64_t res_ref = 0;
6893         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6894         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6895         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6896         res_ref = (uint64_t)res_var.inner & ~1;
6897         return res_ref;
6898 }
6899 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1NodeAnnouncementDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6900         LDKCResult_NodeAnnouncementDecodeErrorZ *val = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
6901         CHECK(!val->result_ok);
6902         LDKDecodeError err_var = (*val->contents.err);
6903         uint64_t err_ref = 0;
6904         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6905         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6906         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6907         err_ref = (uint64_t)err_var.inner & ~1;
6908         return err_ref;
6909 }
6910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6911         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6912         CHECK(val->result_ok);
6913         LDKQueryShortChannelIds res_var = (*val->contents.result);
6914         uint64_t res_ref = 0;
6915         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6916         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6917         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6918         res_ref = (uint64_t)res_var.inner & ~1;
6919         return res_ref;
6920 }
6921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryShortChannelIdsDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6922         LDKCResult_QueryShortChannelIdsDecodeErrorZ *val = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
6923         CHECK(!val->result_ok);
6924         LDKDecodeError err_var = (*val->contents.err);
6925         uint64_t err_ref = 0;
6926         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6927         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6928         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6929         err_ref = (uint64_t)err_var.inner & ~1;
6930         return err_ref;
6931 }
6932 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6933         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6934         CHECK(val->result_ok);
6935         LDKReplyShortChannelIdsEnd res_var = (*val->contents.result);
6936         uint64_t res_ref = 0;
6937         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6938         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6939         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6940         res_ref = (uint64_t)res_var.inner & ~1;
6941         return res_ref;
6942 }
6943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyShortChannelIdsEndDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6944         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *val = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
6945         CHECK(!val->result_ok);
6946         LDKDecodeError err_var = (*val->contents.err);
6947         uint64_t err_ref = 0;
6948         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6949         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6950         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6951         err_ref = (uint64_t)err_var.inner & ~1;
6952         return err_ref;
6953 }
6954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6955         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6956         CHECK(val->result_ok);
6957         LDKQueryChannelRange res_var = (*val->contents.result);
6958         uint64_t res_ref = 0;
6959         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6960         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6961         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6962         res_ref = (uint64_t)res_var.inner & ~1;
6963         return res_ref;
6964 }
6965 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1QueryChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6966         LDKCResult_QueryChannelRangeDecodeErrorZ *val = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
6967         CHECK(!val->result_ok);
6968         LDKDecodeError err_var = (*val->contents.err);
6969         uint64_t err_ref = 0;
6970         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6971         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6972         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6973         err_ref = (uint64_t)err_var.inner & ~1;
6974         return err_ref;
6975 }
6976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6977         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6978         CHECK(val->result_ok);
6979         LDKReplyChannelRange res_var = (*val->contents.result);
6980         uint64_t res_ref = 0;
6981         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6982         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6983         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
6984         res_ref = (uint64_t)res_var.inner & ~1;
6985         return res_ref;
6986 }
6987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1ReplyChannelRangeDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
6988         LDKCResult_ReplyChannelRangeDecodeErrorZ *val = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
6989         CHECK(!val->result_ok);
6990         LDKDecodeError err_var = (*val->contents.err);
6991         uint64_t err_ref = 0;
6992         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
6993         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
6994         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
6995         err_ref = (uint64_t)err_var.inner & ~1;
6996         return err_ref;
6997 }
6998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
6999         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7000         CHECK(val->result_ok);
7001         LDKGossipTimestampFilter res_var = (*val->contents.result);
7002         uint64_t res_ref = 0;
7003         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7004         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7005         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7006         res_ref = (uint64_t)res_var.inner & ~1;
7007         return res_ref;
7008 }
7009 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1GossipTimestampFilterDecodeErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7010         LDKCResult_GossipTimestampFilterDecodeErrorZ *val = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
7011         CHECK(!val->result_ok);
7012         LDKDecodeError err_var = (*val->contents.err);
7013         uint64_t err_ref = 0;
7014         CHECK((((uint64_t)err_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7015         CHECK((((uint64_t)&err_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7016         CHECK_INNER_FIELD_ACCESS_OR_NULL(err_var);
7017         err_ref = (uint64_t)err_var.inner & ~1;
7018         return err_ref;
7019 }
7020 static jclass LDKSignOrCreationError_SignError_class = NULL;
7021 static jmethodID LDKSignOrCreationError_SignError_meth = NULL;
7022 static jclass LDKSignOrCreationError_CreationError_class = NULL;
7023 static jmethodID LDKSignOrCreationError_CreationError_meth = NULL;
7024 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKSignOrCreationError_init (JNIEnv *env, jclass clz) {
7025         LDKSignOrCreationError_SignError_class =
7026                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$SignError;"));
7027         CHECK(LDKSignOrCreationError_SignError_class != NULL);
7028         LDKSignOrCreationError_SignError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_SignError_class, "<init>", "()V");
7029         CHECK(LDKSignOrCreationError_SignError_meth != NULL);
7030         LDKSignOrCreationError_CreationError_class =
7031                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKSignOrCreationError$CreationError;"));
7032         CHECK(LDKSignOrCreationError_CreationError_class != NULL);
7033         LDKSignOrCreationError_CreationError_meth = (*env)->GetMethodID(env, LDKSignOrCreationError_CreationError_class, "<init>", "(Lorg/ldk/enums/CreationError;)V");
7034         CHECK(LDKSignOrCreationError_CreationError_meth != NULL);
7035 }
7036 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKSignOrCreationError_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7037         LDKSignOrCreationError *obj = (LDKSignOrCreationError*)(ptr & ~1);
7038         switch(obj->tag) {
7039                 case LDKSignOrCreationError_SignError: {
7040                         return (*env)->NewObject(env, LDKSignOrCreationError_SignError_class, LDKSignOrCreationError_SignError_meth);
7041                 }
7042                 case LDKSignOrCreationError_CreationError: {
7043                         jclass creation_error_conv = LDKCreationError_to_java(env, obj->creation_error);
7044                         return (*env)->NewObject(env, LDKSignOrCreationError_CreationError_class, LDKSignOrCreationError_CreationError_meth, creation_error_conv);
7045                 }
7046                 default: abort();
7047         }
7048 }
7049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7050         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7051         CHECK(val->result_ok);
7052         LDKInvoice res_var = (*val->contents.result);
7053         uint64_t res_ref = 0;
7054         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7055         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7056         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7057         res_ref = (uint64_t)res_var.inner & ~1;
7058         return res_ref;
7059 }
7060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1InvoiceSignOrCreationErrorZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7061         LDKCResult_InvoiceSignOrCreationErrorZ *val = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
7062         CHECK(!val->result_ok);
7063         uint64_t err_ref = ((uint64_t)&(*val->contents.err)) | 1;
7064         return err_ref;
7065 }
7066 typedef struct LDKFilter_JCalls {
7067         atomic_size_t refcnt;
7068         JavaVM *vm;
7069         jweak o;
7070         jmethodID register_tx_meth;
7071         jmethodID register_output_meth;
7072 } LDKFilter_JCalls;
7073 static void LDKFilter_JCalls_free(void* this_arg) {
7074         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7075         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7076                 JNIEnv *env;
7077                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7078                 if (get_jenv_res == JNI_EDETACHED) {
7079                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7080                 } else {
7081                         DO_ASSERT(get_jenv_res == JNI_OK);
7082                 }
7083                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7084                 if (get_jenv_res == JNI_EDETACHED) {
7085                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7086                 }
7087                 FREE(j_calls);
7088         }
7089 }
7090 void register_tx_LDKFilter_jcall(const void* this_arg, const uint8_t (* txid)[32], LDKu8slice script_pubkey) {
7091         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7092         JNIEnv *env;
7093         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7094         if (get_jenv_res == JNI_EDETACHED) {
7095                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7096         } else {
7097                 DO_ASSERT(get_jenv_res == JNI_OK);
7098         }
7099         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7100         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7101         LDKu8slice script_pubkey_var = script_pubkey;
7102         int8_tArray script_pubkey_arr = (*env)->NewByteArray(env, script_pubkey_var.datalen);
7103         (*env)->SetByteArrayRegion(env, script_pubkey_arr, 0, script_pubkey_var.datalen, script_pubkey_var.data);
7104         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7105         CHECK(obj != NULL);
7106         (*env)->CallVoidMethod(env, obj, j_calls->register_tx_meth, txid_arr, script_pubkey_arr);
7107         if ((*env)->ExceptionCheck(env)) {
7108                 (*env)->ExceptionDescribe(env);
7109                 (*env)->FatalError(env, "A call to register_tx in LDKFilter from rust threw an exception.");
7110         }
7111         if (get_jenv_res == JNI_EDETACHED) {
7112                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7113         }
7114 }
7115 LDKCOption_C2Tuple_usizeTransactionZZ register_output_LDKFilter_jcall(const void* this_arg, LDKWatchedOutput output) {
7116         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) this_arg;
7117         JNIEnv *env;
7118         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7119         if (get_jenv_res == JNI_EDETACHED) {
7120                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7121         } else {
7122                 DO_ASSERT(get_jenv_res == JNI_OK);
7123         }
7124         LDKWatchedOutput output_var = output;
7125         uint64_t output_ref = 0;
7126         CHECK((((uint64_t)output_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7127         CHECK((((uint64_t)&output_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7128         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_var);
7129         output_ref = (uint64_t)output_var.inner;
7130         if (output_var.is_owned) {
7131                 output_ref |= 1;
7132         }
7133         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7134         CHECK(obj != NULL);
7135         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->register_output_meth, output_ref);
7136         if ((*env)->ExceptionCheck(env)) {
7137                 (*env)->ExceptionDescribe(env);
7138                 (*env)->FatalError(env, "A call to register_output in LDKFilter from rust threw an exception.");
7139         }
7140         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7141         CHECK_ACCESS(ret_ptr);
7142         LDKCOption_C2Tuple_usizeTransactionZZ ret_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(ret_ptr);
7143         FREE((void*)ret);
7144         if (get_jenv_res == JNI_EDETACHED) {
7145                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7146         }
7147         return ret_conv;
7148 }
7149 static void LDKFilter_JCalls_cloned(LDKFilter* new_obj) {
7150         LDKFilter_JCalls *j_calls = (LDKFilter_JCalls*) new_obj->this_arg;
7151         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7152 }
7153 static inline LDKFilter LDKFilter_init (JNIEnv *env, jclass clz, jobject o) {
7154         jclass c = (*env)->GetObjectClass(env, o);
7155         CHECK(c != NULL);
7156         LDKFilter_JCalls *calls = MALLOC(sizeof(LDKFilter_JCalls), "LDKFilter_JCalls");
7157         atomic_init(&calls->refcnt, 1);
7158         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7159         calls->o = (*env)->NewWeakGlobalRef(env, o);
7160         calls->register_tx_meth = (*env)->GetMethodID(env, c, "register_tx", "([B[B)V");
7161         CHECK(calls->register_tx_meth != NULL);
7162         calls->register_output_meth = (*env)->GetMethodID(env, c, "register_output", "(J)J");
7163         CHECK(calls->register_output_meth != NULL);
7164
7165         LDKFilter ret = {
7166                 .this_arg = (void*) calls,
7167                 .register_tx = register_tx_LDKFilter_jcall,
7168                 .register_output = register_output_LDKFilter_jcall,
7169                 .free = LDKFilter_JCalls_free,
7170         };
7171         return ret;
7172 }
7173 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKFilter_1new(JNIEnv *env, jclass clz, jobject o) {
7174         LDKFilter *res_ptr = MALLOC(sizeof(LDKFilter), "LDKFilter");
7175         *res_ptr = LDKFilter_init(env, clz, o);
7176         return (uint64_t)res_ptr;
7177 }
7178 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) {
7179         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7180         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7181         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7182         unsigned char txid_arr[32];
7183         CHECK((*env)->GetArrayLength(env, txid) == 32);
7184         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7185         unsigned char (*txid_ref)[32] = &txid_arr;
7186         LDKu8slice script_pubkey_ref;
7187         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
7188         script_pubkey_ref.data = (*env)->GetByteArrayElements (env, script_pubkey, NULL);
7189         (this_arg_conv->register_tx)(this_arg_conv->this_arg, txid_ref, script_pubkey_ref);
7190         (*env)->ReleaseByteArrayElements(env, script_pubkey, (int8_t*)script_pubkey_ref.data, 0);
7191 }
7192
7193 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Filter_1register_1output(JNIEnv *env, jclass clz, int64_t this_arg, int64_t output) {
7194         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7195         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7196         LDKFilter* this_arg_conv = (LDKFilter*)this_arg_ptr;
7197         LDKWatchedOutput output_conv;
7198         output_conv.inner = (void*)(output & (~1));
7199         output_conv.is_owned = (output & 1) || (output == 0);
7200         CHECK_INNER_FIELD_ACCESS_OR_NULL(output_conv);
7201         output_conv = WatchedOutput_clone(&output_conv);
7202         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
7203         *ret_copy = (this_arg_conv->register_output)(this_arg_conv->this_arg, output_conv);
7204         uint64_t ret_ref = (uint64_t)ret_copy;
7205         return ret_ref;
7206 }
7207
7208 static jclass LDKCOption_FilterZ_Some_class = NULL;
7209 static jmethodID LDKCOption_FilterZ_Some_meth = NULL;
7210 static jclass LDKCOption_FilterZ_None_class = NULL;
7211 static jmethodID LDKCOption_FilterZ_None_meth = NULL;
7212 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKCOption_1FilterZ_init (JNIEnv *env, jclass clz) {
7213         LDKCOption_FilterZ_Some_class =
7214                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$Some;"));
7215         CHECK(LDKCOption_FilterZ_Some_class != NULL);
7216         LDKCOption_FilterZ_Some_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_Some_class, "<init>", "(J)V");
7217         CHECK(LDKCOption_FilterZ_Some_meth != NULL);
7218         LDKCOption_FilterZ_None_class =
7219                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKCOption_FilterZ$None;"));
7220         CHECK(LDKCOption_FilterZ_None_class != NULL);
7221         LDKCOption_FilterZ_None_meth = (*env)->GetMethodID(env, LDKCOption_FilterZ_None_class, "<init>", "()V");
7222         CHECK(LDKCOption_FilterZ_None_meth != NULL);
7223 }
7224 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKCOption_1FilterZ_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
7225         LDKCOption_FilterZ *obj = (LDKCOption_FilterZ*)(ptr & ~1);
7226         switch(obj->tag) {
7227                 case LDKCOption_FilterZ_Some: {
7228                         LDKFilter* some_ret = MALLOC(sizeof(LDKFilter), "LDKFilter");
7229                         *some_ret = obj->some;
7230                         // Warning: We likely need to clone here, but no clone is available, so we just do it for Java instances
7231                         if ((*some_ret).free == LDKFilter_JCalls_free) {
7232                                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7233                                 LDKFilter_JCalls_cloned(&(*some_ret));
7234                         }
7235                         return (*env)->NewObject(env, LDKCOption_FilterZ_Some_class, LDKCOption_FilterZ_Some_meth, (uint64_t)some_ret);
7236                 }
7237                 case LDKCOption_FilterZ_None: {
7238                         return (*env)->NewObject(env, LDKCOption_FilterZ_None_class, LDKCOption_FilterZ_None_meth);
7239                 }
7240                 default: abort();
7241         }
7242 }
7243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1ok(JNIEnv *env, jclass clz, int64_t arg) {
7244         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7245         CHECK(val->result_ok);
7246         LDKLockedChannelMonitor res_var = (*val->contents.result);
7247         uint64_t res_ref = 0;
7248         CHECK((((uint64_t)res_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7249         CHECK((((uint64_t)&res_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7250         CHECK_INNER_FIELD_ACCESS_OR_NULL(res_var);
7251         res_ref = (uint64_t)res_var.inner & ~1;
7252         return res_ref;
7253 }
7254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LDKCResult_1LockedChannelMonitorNoneZ_1get_1err(JNIEnv *env, jclass clz, int64_t arg) {
7255         LDKCResult_LockedChannelMonitorNoneZ *val = (LDKCResult_LockedChannelMonitorNoneZ*)(arg & ~1);
7256         CHECK(!val->result_ok);
7257         return *val->contents.err;
7258 }
7259 static inline LDKCVec_OutPointZ CVec_OutPointZ_clone(const LDKCVec_OutPointZ *orig) {
7260         LDKCVec_OutPointZ ret = { .data = MALLOC(sizeof(LDKOutPoint) * orig->datalen, "LDKCVec_OutPointZ clone bytes"), .datalen = orig->datalen };
7261         for (size_t i = 0; i < ret.datalen; i++) {
7262                 ret.data[i] = OutPoint_clone(&orig->data[i]);
7263         }
7264         return ret;
7265 }
7266 typedef struct LDKMessageSendEventsProvider_JCalls {
7267         atomic_size_t refcnt;
7268         JavaVM *vm;
7269         jweak o;
7270         jmethodID get_and_clear_pending_msg_events_meth;
7271 } LDKMessageSendEventsProvider_JCalls;
7272 static void LDKMessageSendEventsProvider_JCalls_free(void* this_arg) {
7273         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7274         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7275                 JNIEnv *env;
7276                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7277                 if (get_jenv_res == JNI_EDETACHED) {
7278                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7279                 } else {
7280                         DO_ASSERT(get_jenv_res == JNI_OK);
7281                 }
7282                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7283                 if (get_jenv_res == JNI_EDETACHED) {
7284                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7285                 }
7286                 FREE(j_calls);
7287         }
7288 }
7289 LDKCVec_MessageSendEventZ get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall(const void* this_arg) {
7290         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) this_arg;
7291         JNIEnv *env;
7292         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7293         if (get_jenv_res == JNI_EDETACHED) {
7294                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7295         } else {
7296                 DO_ASSERT(get_jenv_res == JNI_OK);
7297         }
7298         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7299         CHECK(obj != NULL);
7300         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_events_meth);
7301         if ((*env)->ExceptionCheck(env)) {
7302                 (*env)->ExceptionDescribe(env);
7303                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg_events in LDKMessageSendEventsProvider from rust threw an exception.");
7304         }
7305         LDKCVec_MessageSendEventZ ret_constr;
7306         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7307         if (ret_constr.datalen > 0)
7308                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
7309         else
7310                 ret_constr.data = NULL;
7311         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
7312         for (size_t s = 0; s < ret_constr.datalen; s++) {
7313                 int64_t ret_conv_18 = ret_vals[s];
7314                 void* ret_conv_18_ptr = (void*)(((uint64_t)ret_conv_18) & ~1);
7315                 CHECK_ACCESS(ret_conv_18_ptr);
7316                 LDKMessageSendEvent ret_conv_18_conv = *(LDKMessageSendEvent*)(ret_conv_18_ptr);
7317                 FREE((void*)ret_conv_18);
7318                 ret_constr.data[s] = ret_conv_18_conv;
7319         }
7320         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
7321         if (get_jenv_res == JNI_EDETACHED) {
7322                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7323         }
7324         return ret_constr;
7325 }
7326 static void LDKMessageSendEventsProvider_JCalls_cloned(LDKMessageSendEventsProvider* new_obj) {
7327         LDKMessageSendEventsProvider_JCalls *j_calls = (LDKMessageSendEventsProvider_JCalls*) new_obj->this_arg;
7328         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7329 }
7330 static inline LDKMessageSendEventsProvider LDKMessageSendEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7331         jclass c = (*env)->GetObjectClass(env, o);
7332         CHECK(c != NULL);
7333         LDKMessageSendEventsProvider_JCalls *calls = MALLOC(sizeof(LDKMessageSendEventsProvider_JCalls), "LDKMessageSendEventsProvider_JCalls");
7334         atomic_init(&calls->refcnt, 1);
7335         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7336         calls->o = (*env)->NewWeakGlobalRef(env, o);
7337         calls->get_and_clear_pending_msg_events_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg_events", "()[J");
7338         CHECK(calls->get_and_clear_pending_msg_events_meth != NULL);
7339
7340         LDKMessageSendEventsProvider ret = {
7341                 .this_arg = (void*) calls,
7342                 .get_and_clear_pending_msg_events = get_and_clear_pending_msg_events_LDKMessageSendEventsProvider_jcall,
7343                 .free = LDKMessageSendEventsProvider_JCalls_free,
7344         };
7345         return ret;
7346 }
7347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKMessageSendEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7348         LDKMessageSendEventsProvider *res_ptr = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
7349         *res_ptr = LDKMessageSendEventsProvider_init(env, clz, o);
7350         return (uint64_t)res_ptr;
7351 }
7352 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1get_1and_1clear_1pending_1msg_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
7353         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7354         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7355         LDKMessageSendEventsProvider* this_arg_conv = (LDKMessageSendEventsProvider*)this_arg_ptr;
7356         LDKCVec_MessageSendEventZ ret_var = (this_arg_conv->get_and_clear_pending_msg_events)(this_arg_conv->this_arg);
7357         int64_tArray ret_arr = NULL;
7358         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
7359         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
7360         for (size_t s = 0; s < ret_var.datalen; s++) {
7361                 LDKMessageSendEvent *ret_conv_18_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
7362                 *ret_conv_18_copy = ret_var.data[s];
7363                 uint64_t ret_conv_18_ref = (uint64_t)ret_conv_18_copy;
7364                 ret_arr_ptr[s] = ret_conv_18_ref;
7365         }
7366         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
7367         FREE(ret_var.data);
7368         return ret_arr;
7369 }
7370
7371 typedef struct LDKEventHandler_JCalls {
7372         atomic_size_t refcnt;
7373         JavaVM *vm;
7374         jweak o;
7375         jmethodID handle_event_meth;
7376 } LDKEventHandler_JCalls;
7377 static void LDKEventHandler_JCalls_free(void* this_arg) {
7378         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7379         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7380                 JNIEnv *env;
7381                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7382                 if (get_jenv_res == JNI_EDETACHED) {
7383                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7384                 } else {
7385                         DO_ASSERT(get_jenv_res == JNI_OK);
7386                 }
7387                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7388                 if (get_jenv_res == JNI_EDETACHED) {
7389                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7390                 }
7391                 FREE(j_calls);
7392         }
7393 }
7394 void handle_event_LDKEventHandler_jcall(const void* this_arg, const LDKEvent * event) {
7395         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) this_arg;
7396         JNIEnv *env;
7397         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7398         if (get_jenv_res == JNI_EDETACHED) {
7399                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7400         } else {
7401                 DO_ASSERT(get_jenv_res == JNI_OK);
7402         }
7403         LDKEvent *ret_event = MALLOC(sizeof(LDKEvent), "LDKEvent ret conversion");
7404         *ret_event = Event_clone(event);
7405         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7406         CHECK(obj != NULL);
7407         (*env)->CallVoidMethod(env, obj, j_calls->handle_event_meth, (uint64_t)ret_event);
7408         if ((*env)->ExceptionCheck(env)) {
7409                 (*env)->ExceptionDescribe(env);
7410                 (*env)->FatalError(env, "A call to handle_event in LDKEventHandler from rust threw an exception.");
7411         }
7412         if (get_jenv_res == JNI_EDETACHED) {
7413                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7414         }
7415 }
7416 static void LDKEventHandler_JCalls_cloned(LDKEventHandler* new_obj) {
7417         LDKEventHandler_JCalls *j_calls = (LDKEventHandler_JCalls*) new_obj->this_arg;
7418         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7419 }
7420 static inline LDKEventHandler LDKEventHandler_init (JNIEnv *env, jclass clz, jobject o) {
7421         jclass c = (*env)->GetObjectClass(env, o);
7422         CHECK(c != NULL);
7423         LDKEventHandler_JCalls *calls = MALLOC(sizeof(LDKEventHandler_JCalls), "LDKEventHandler_JCalls");
7424         atomic_init(&calls->refcnt, 1);
7425         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7426         calls->o = (*env)->NewWeakGlobalRef(env, o);
7427         calls->handle_event_meth = (*env)->GetMethodID(env, c, "handle_event", "(J)V");
7428         CHECK(calls->handle_event_meth != NULL);
7429
7430         LDKEventHandler ret = {
7431                 .this_arg = (void*) calls,
7432                 .handle_event = handle_event_LDKEventHandler_jcall,
7433                 .free = LDKEventHandler_JCalls_free,
7434         };
7435         return ret;
7436 }
7437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventHandler_1new(JNIEnv *env, jclass clz, jobject o) {
7438         LDKEventHandler *res_ptr = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7439         *res_ptr = LDKEventHandler_init(env, clz, o);
7440         return (uint64_t)res_ptr;
7441 }
7442 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1handle_1event(JNIEnv *env, jclass clz, int64_t this_arg, int64_t event) {
7443         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7444         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7445         LDKEventHandler* this_arg_conv = (LDKEventHandler*)this_arg_ptr;
7446         LDKEvent* event_conv = (LDKEvent*)event;
7447         (this_arg_conv->handle_event)(this_arg_conv->this_arg, event_conv);
7448 }
7449
7450 typedef struct LDKEventsProvider_JCalls {
7451         atomic_size_t refcnt;
7452         JavaVM *vm;
7453         jweak o;
7454         jmethodID process_pending_events_meth;
7455 } LDKEventsProvider_JCalls;
7456 static void LDKEventsProvider_JCalls_free(void* this_arg) {
7457         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7458         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7459                 JNIEnv *env;
7460                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7461                 if (get_jenv_res == JNI_EDETACHED) {
7462                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7463                 } else {
7464                         DO_ASSERT(get_jenv_res == JNI_OK);
7465                 }
7466                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7467                 if (get_jenv_res == JNI_EDETACHED) {
7468                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7469                 }
7470                 FREE(j_calls);
7471         }
7472 }
7473 void process_pending_events_LDKEventsProvider_jcall(const void* this_arg, LDKEventHandler handler) {
7474         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) this_arg;
7475         JNIEnv *env;
7476         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7477         if (get_jenv_res == JNI_EDETACHED) {
7478                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7479         } else {
7480                 DO_ASSERT(get_jenv_res == JNI_OK);
7481         }
7482         LDKEventHandler* handler_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
7483         *handler_ret = handler;
7484         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7485         CHECK(obj != NULL);
7486         (*env)->CallVoidMethod(env, obj, j_calls->process_pending_events_meth, (uint64_t)handler_ret);
7487         if ((*env)->ExceptionCheck(env)) {
7488                 (*env)->ExceptionDescribe(env);
7489                 (*env)->FatalError(env, "A call to process_pending_events in LDKEventsProvider from rust threw an exception.");
7490         }
7491         if (get_jenv_res == JNI_EDETACHED) {
7492                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7493         }
7494 }
7495 static void LDKEventsProvider_JCalls_cloned(LDKEventsProvider* new_obj) {
7496         LDKEventsProvider_JCalls *j_calls = (LDKEventsProvider_JCalls*) new_obj->this_arg;
7497         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7498 }
7499 static inline LDKEventsProvider LDKEventsProvider_init (JNIEnv *env, jclass clz, jobject o) {
7500         jclass c = (*env)->GetObjectClass(env, o);
7501         CHECK(c != NULL);
7502         LDKEventsProvider_JCalls *calls = MALLOC(sizeof(LDKEventsProvider_JCalls), "LDKEventsProvider_JCalls");
7503         atomic_init(&calls->refcnt, 1);
7504         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7505         calls->o = (*env)->NewWeakGlobalRef(env, o);
7506         calls->process_pending_events_meth = (*env)->GetMethodID(env, c, "process_pending_events", "(J)V");
7507         CHECK(calls->process_pending_events_meth != NULL);
7508
7509         LDKEventsProvider ret = {
7510                 .this_arg = (void*) calls,
7511                 .process_pending_events = process_pending_events_LDKEventsProvider_jcall,
7512                 .free = LDKEventsProvider_JCalls_free,
7513         };
7514         return ret;
7515 }
7516 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKEventsProvider_1new(JNIEnv *env, jclass clz, jobject o) {
7517         LDKEventsProvider *res_ptr = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
7518         *res_ptr = LDKEventsProvider_init(env, clz, o);
7519         return (uint64_t)res_ptr;
7520 }
7521 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1process_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg, int64_t handler) {
7522         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7523         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7524         LDKEventsProvider* this_arg_conv = (LDKEventsProvider*)this_arg_ptr;
7525         void* handler_ptr = (void*)(((uint64_t)handler) & ~1);
7526         CHECK_ACCESS(handler_ptr);
7527         LDKEventHandler handler_conv = *(LDKEventHandler*)(handler_ptr);
7528         if (handler_conv.free == LDKEventHandler_JCalls_free) {
7529                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
7530                 LDKEventHandler_JCalls_cloned(&handler_conv);
7531         }
7532         (this_arg_conv->process_pending_events)(this_arg_conv->this_arg, handler_conv);
7533 }
7534
7535 typedef struct LDKListen_JCalls {
7536         atomic_size_t refcnt;
7537         JavaVM *vm;
7538         jweak o;
7539         jmethodID block_connected_meth;
7540         jmethodID block_disconnected_meth;
7541 } LDKListen_JCalls;
7542 static void LDKListen_JCalls_free(void* this_arg) {
7543         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7544         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7545                 JNIEnv *env;
7546                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7547                 if (get_jenv_res == JNI_EDETACHED) {
7548                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7549                 } else {
7550                         DO_ASSERT(get_jenv_res == JNI_OK);
7551                 }
7552                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7553                 if (get_jenv_res == JNI_EDETACHED) {
7554                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7555                 }
7556                 FREE(j_calls);
7557         }
7558 }
7559 void block_connected_LDKListen_jcall(const void* this_arg, LDKu8slice block, uint32_t height) {
7560         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7561         JNIEnv *env;
7562         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7563         if (get_jenv_res == JNI_EDETACHED) {
7564                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7565         } else {
7566                 DO_ASSERT(get_jenv_res == JNI_OK);
7567         }
7568         LDKu8slice block_var = block;
7569         int8_tArray block_arr = (*env)->NewByteArray(env, block_var.datalen);
7570         (*env)->SetByteArrayRegion(env, block_arr, 0, block_var.datalen, block_var.data);
7571         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7572         CHECK(obj != NULL);
7573         (*env)->CallVoidMethod(env, obj, j_calls->block_connected_meth, block_arr, height);
7574         if ((*env)->ExceptionCheck(env)) {
7575                 (*env)->ExceptionDescribe(env);
7576                 (*env)->FatalError(env, "A call to block_connected in LDKListen from rust threw an exception.");
7577         }
7578         if (get_jenv_res == JNI_EDETACHED) {
7579                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7580         }
7581 }
7582 void block_disconnected_LDKListen_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7583         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) this_arg;
7584         JNIEnv *env;
7585         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7586         if (get_jenv_res == JNI_EDETACHED) {
7587                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7588         } else {
7589                 DO_ASSERT(get_jenv_res == JNI_OK);
7590         }
7591         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7592         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7593         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7594         CHECK(obj != NULL);
7595         (*env)->CallVoidMethod(env, obj, j_calls->block_disconnected_meth, header_arr, height);
7596         if ((*env)->ExceptionCheck(env)) {
7597                 (*env)->ExceptionDescribe(env);
7598                 (*env)->FatalError(env, "A call to block_disconnected in LDKListen from rust threw an exception.");
7599         }
7600         if (get_jenv_res == JNI_EDETACHED) {
7601                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7602         }
7603 }
7604 static void LDKListen_JCalls_cloned(LDKListen* new_obj) {
7605         LDKListen_JCalls *j_calls = (LDKListen_JCalls*) new_obj->this_arg;
7606         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7607 }
7608 static inline LDKListen LDKListen_init (JNIEnv *env, jclass clz, jobject o) {
7609         jclass c = (*env)->GetObjectClass(env, o);
7610         CHECK(c != NULL);
7611         LDKListen_JCalls *calls = MALLOC(sizeof(LDKListen_JCalls), "LDKListen_JCalls");
7612         atomic_init(&calls->refcnt, 1);
7613         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7614         calls->o = (*env)->NewWeakGlobalRef(env, o);
7615         calls->block_connected_meth = (*env)->GetMethodID(env, c, "block_connected", "([BI)V");
7616         CHECK(calls->block_connected_meth != NULL);
7617         calls->block_disconnected_meth = (*env)->GetMethodID(env, c, "block_disconnected", "([BI)V");
7618         CHECK(calls->block_disconnected_meth != NULL);
7619
7620         LDKListen ret = {
7621                 .this_arg = (void*) calls,
7622                 .block_connected = block_connected_LDKListen_jcall,
7623                 .block_disconnected = block_disconnected_LDKListen_jcall,
7624                 .free = LDKListen_JCalls_free,
7625         };
7626         return ret;
7627 }
7628 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKListen_1new(JNIEnv *env, jclass clz, jobject o) {
7629         LDKListen *res_ptr = MALLOC(sizeof(LDKListen), "LDKListen");
7630         *res_ptr = LDKListen_init(env, clz, o);
7631         return (uint64_t)res_ptr;
7632 }
7633 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) {
7634         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7635         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7636         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7637         LDKu8slice block_ref;
7638         block_ref.datalen = (*env)->GetArrayLength(env, block);
7639         block_ref.data = (*env)->GetByteArrayElements (env, block, NULL);
7640         (this_arg_conv->block_connected)(this_arg_conv->this_arg, block_ref, height);
7641         (*env)->ReleaseByteArrayElements(env, block, (int8_t*)block_ref.data, 0);
7642 }
7643
7644 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) {
7645         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7646         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7647         LDKListen* this_arg_conv = (LDKListen*)this_arg_ptr;
7648         unsigned char header_arr[80];
7649         CHECK((*env)->GetArrayLength(env, header) == 80);
7650         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7651         unsigned char (*header_ref)[80] = &header_arr;
7652         (this_arg_conv->block_disconnected)(this_arg_conv->this_arg, header_ref, height);
7653 }
7654
7655 typedef struct LDKConfirm_JCalls {
7656         atomic_size_t refcnt;
7657         JavaVM *vm;
7658         jweak o;
7659         jmethodID transactions_confirmed_meth;
7660         jmethodID transaction_unconfirmed_meth;
7661         jmethodID best_block_updated_meth;
7662         jmethodID get_relevant_txids_meth;
7663 } LDKConfirm_JCalls;
7664 static void LDKConfirm_JCalls_free(void* this_arg) {
7665         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7666         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7667                 JNIEnv *env;
7668                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7669                 if (get_jenv_res == JNI_EDETACHED) {
7670                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7671                 } else {
7672                         DO_ASSERT(get_jenv_res == JNI_OK);
7673                 }
7674                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7675                 if (get_jenv_res == JNI_EDETACHED) {
7676                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7677                 }
7678                 FREE(j_calls);
7679         }
7680 }
7681 void transactions_confirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], LDKCVec_C2Tuple_usizeTransactionZZ txdata, uint32_t height) {
7682         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7683         JNIEnv *env;
7684         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7685         if (get_jenv_res == JNI_EDETACHED) {
7686                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7687         } else {
7688                 DO_ASSERT(get_jenv_res == JNI_OK);
7689         }
7690         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7691         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7692         LDKCVec_C2Tuple_usizeTransactionZZ txdata_var = txdata;
7693         int64_tArray txdata_arr = NULL;
7694         txdata_arr = (*env)->NewLongArray(env, txdata_var.datalen);
7695         int64_t *txdata_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, txdata_arr, NULL);
7696         for (size_t c = 0; c < txdata_var.datalen; c++) {
7697                 LDKC2Tuple_usizeTransactionZ* txdata_conv_28_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
7698                 *txdata_conv_28_conv = txdata_var.data[c];
7699                 txdata_arr_ptr[c] = ((uint64_t)txdata_conv_28_conv);
7700         }
7701         (*env)->ReleasePrimitiveArrayCritical(env, txdata_arr, txdata_arr_ptr, 0);
7702         FREE(txdata_var.data);
7703         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7704         CHECK(obj != NULL);
7705         (*env)->CallVoidMethod(env, obj, j_calls->transactions_confirmed_meth, header_arr, txdata_arr, height);
7706         if ((*env)->ExceptionCheck(env)) {
7707                 (*env)->ExceptionDescribe(env);
7708                 (*env)->FatalError(env, "A call to transactions_confirmed in LDKConfirm from rust threw an exception.");
7709         }
7710         if (get_jenv_res == JNI_EDETACHED) {
7711                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7712         }
7713 }
7714 void transaction_unconfirmed_LDKConfirm_jcall(const void* this_arg, const uint8_t (* txid)[32]) {
7715         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7716         JNIEnv *env;
7717         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7718         if (get_jenv_res == JNI_EDETACHED) {
7719                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7720         } else {
7721                 DO_ASSERT(get_jenv_res == JNI_OK);
7722         }
7723         int8_tArray txid_arr = (*env)->NewByteArray(env, 32);
7724         (*env)->SetByteArrayRegion(env, txid_arr, 0, 32, *txid);
7725         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7726         CHECK(obj != NULL);
7727         (*env)->CallVoidMethod(env, obj, j_calls->transaction_unconfirmed_meth, txid_arr);
7728         if ((*env)->ExceptionCheck(env)) {
7729                 (*env)->ExceptionDescribe(env);
7730                 (*env)->FatalError(env, "A call to transaction_unconfirmed in LDKConfirm from rust threw an exception.");
7731         }
7732         if (get_jenv_res == JNI_EDETACHED) {
7733                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7734         }
7735 }
7736 void best_block_updated_LDKConfirm_jcall(const void* this_arg, const uint8_t (* header)[80], uint32_t height) {
7737         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7738         JNIEnv *env;
7739         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7740         if (get_jenv_res == JNI_EDETACHED) {
7741                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7742         } else {
7743                 DO_ASSERT(get_jenv_res == JNI_OK);
7744         }
7745         int8_tArray header_arr = (*env)->NewByteArray(env, 80);
7746         (*env)->SetByteArrayRegion(env, header_arr, 0, 80, *header);
7747         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7748         CHECK(obj != NULL);
7749         (*env)->CallVoidMethod(env, obj, j_calls->best_block_updated_meth, header_arr, height);
7750         if ((*env)->ExceptionCheck(env)) {
7751                 (*env)->ExceptionDescribe(env);
7752                 (*env)->FatalError(env, "A call to best_block_updated in LDKConfirm from rust threw an exception.");
7753         }
7754         if (get_jenv_res == JNI_EDETACHED) {
7755                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7756         }
7757 }
7758 LDKCVec_TxidZ get_relevant_txids_LDKConfirm_jcall(const void* this_arg) {
7759         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) this_arg;
7760         JNIEnv *env;
7761         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7762         if (get_jenv_res == JNI_EDETACHED) {
7763                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7764         } else {
7765                 DO_ASSERT(get_jenv_res == JNI_OK);
7766         }
7767         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7768         CHECK(obj != NULL);
7769         jobjectArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_relevant_txids_meth);
7770         if ((*env)->ExceptionCheck(env)) {
7771                 (*env)->ExceptionDescribe(env);
7772                 (*env)->FatalError(env, "A call to get_relevant_txids in LDKConfirm from rust threw an exception.");
7773         }
7774         LDKCVec_TxidZ ret_constr;
7775         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
7776         if (ret_constr.datalen > 0)
7777                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
7778         else
7779                 ret_constr.data = NULL;
7780         for (size_t i = 0; i < ret_constr.datalen; i++) {
7781                 int8_tArray ret_conv_8 = (*env)->GetObjectArrayElement(env, ret, i);
7782                 LDKThirtyTwoBytes ret_conv_8_ref;
7783                 CHECK((*env)->GetArrayLength(env, ret_conv_8) == 32);
7784                 (*env)->GetByteArrayRegion(env, ret_conv_8, 0, 32, ret_conv_8_ref.data);
7785                 ret_constr.data[i] = ret_conv_8_ref;
7786         }
7787         if (get_jenv_res == JNI_EDETACHED) {
7788                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7789         }
7790         return ret_constr;
7791 }
7792 static void LDKConfirm_JCalls_cloned(LDKConfirm* new_obj) {
7793         LDKConfirm_JCalls *j_calls = (LDKConfirm_JCalls*) new_obj->this_arg;
7794         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
7795 }
7796 static inline LDKConfirm LDKConfirm_init (JNIEnv *env, jclass clz, jobject o) {
7797         jclass c = (*env)->GetObjectClass(env, o);
7798         CHECK(c != NULL);
7799         LDKConfirm_JCalls *calls = MALLOC(sizeof(LDKConfirm_JCalls), "LDKConfirm_JCalls");
7800         atomic_init(&calls->refcnt, 1);
7801         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
7802         calls->o = (*env)->NewWeakGlobalRef(env, o);
7803         calls->transactions_confirmed_meth = (*env)->GetMethodID(env, c, "transactions_confirmed", "([B[JI)V");
7804         CHECK(calls->transactions_confirmed_meth != NULL);
7805         calls->transaction_unconfirmed_meth = (*env)->GetMethodID(env, c, "transaction_unconfirmed", "([B)V");
7806         CHECK(calls->transaction_unconfirmed_meth != NULL);
7807         calls->best_block_updated_meth = (*env)->GetMethodID(env, c, "best_block_updated", "([BI)V");
7808         CHECK(calls->best_block_updated_meth != NULL);
7809         calls->get_relevant_txids_meth = (*env)->GetMethodID(env, c, "get_relevant_txids", "()[[B");
7810         CHECK(calls->get_relevant_txids_meth != NULL);
7811
7812         LDKConfirm ret = {
7813                 .this_arg = (void*) calls,
7814                 .transactions_confirmed = transactions_confirmed_LDKConfirm_jcall,
7815                 .transaction_unconfirmed = transaction_unconfirmed_LDKConfirm_jcall,
7816                 .best_block_updated = best_block_updated_LDKConfirm_jcall,
7817                 .get_relevant_txids = get_relevant_txids_LDKConfirm_jcall,
7818                 .free = LDKConfirm_JCalls_free,
7819         };
7820         return ret;
7821 }
7822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKConfirm_1new(JNIEnv *env, jclass clz, jobject o) {
7823         LDKConfirm *res_ptr = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
7824         *res_ptr = LDKConfirm_init(env, clz, o);
7825         return (uint64_t)res_ptr;
7826 }
7827 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) {
7828         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7829         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7830         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7831         unsigned char header_arr[80];
7832         CHECK((*env)->GetArrayLength(env, header) == 80);
7833         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7834         unsigned char (*header_ref)[80] = &header_arr;
7835         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
7836         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
7837         if (txdata_constr.datalen > 0)
7838                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
7839         else
7840                 txdata_constr.data = NULL;
7841         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
7842         for (size_t c = 0; c < txdata_constr.datalen; c++) {
7843                 int64_t txdata_conv_28 = txdata_vals[c];
7844                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
7845                 CHECK_ACCESS(txdata_conv_28_ptr);
7846                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
7847                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
7848                 txdata_constr.data[c] = txdata_conv_28_conv;
7849         }
7850         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
7851         (this_arg_conv->transactions_confirmed)(this_arg_conv->this_arg, header_ref, txdata_constr, height);
7852 }
7853
7854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1transaction_1unconfirmed(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray txid) {
7855         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7856         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7857         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7858         unsigned char txid_arr[32];
7859         CHECK((*env)->GetArrayLength(env, txid) == 32);
7860         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
7861         unsigned char (*txid_ref)[32] = &txid_arr;
7862         (this_arg_conv->transaction_unconfirmed)(this_arg_conv->this_arg, txid_ref);
7863 }
7864
7865 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) {
7866         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7867         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7868         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7869         unsigned char header_arr[80];
7870         CHECK((*env)->GetArrayLength(env, header) == 80);
7871         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
7872         unsigned char (*header_ref)[80] = &header_arr;
7873         (this_arg_conv->best_block_updated)(this_arg_conv->this_arg, header_ref, height);
7874 }
7875
7876 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Confirm_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
7877         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
7878         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
7879         LDKConfirm* this_arg_conv = (LDKConfirm*)this_arg_ptr;
7880         LDKCVec_TxidZ ret_var = (this_arg_conv->get_relevant_txids)(this_arg_conv->this_arg);
7881         jobjectArray ret_arr = NULL;
7882         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
7883         ;
7884         for (size_t i = 0; i < ret_var.datalen; i++) {
7885                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
7886                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
7887                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
7888         }
7889         
7890         FREE(ret_var.data);
7891         return ret_arr;
7892 }
7893
7894 typedef struct LDKPersist_JCalls {
7895         atomic_size_t refcnt;
7896         JavaVM *vm;
7897         jweak o;
7898         jmethodID persist_new_channel_meth;
7899         jmethodID update_persisted_channel_meth;
7900 } LDKPersist_JCalls;
7901 static void LDKPersist_JCalls_free(void* this_arg) {
7902         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7903         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
7904                 JNIEnv *env;
7905                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7906                 if (get_jenv_res == JNI_EDETACHED) {
7907                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7908                 } else {
7909                         DO_ASSERT(get_jenv_res == JNI_OK);
7910                 }
7911                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
7912                 if (get_jenv_res == JNI_EDETACHED) {
7913                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7914                 }
7915                 FREE(j_calls);
7916         }
7917 }
7918 LDKCResult_NoneChannelMonitorUpdateErrZ persist_new_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7919         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7920         JNIEnv *env;
7921         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7922         if (get_jenv_res == JNI_EDETACHED) {
7923                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7924         } else {
7925                 DO_ASSERT(get_jenv_res == JNI_OK);
7926         }
7927         LDKOutPoint channel_id_var = channel_id;
7928         uint64_t channel_id_ref = 0;
7929         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7930         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7931         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7932         channel_id_ref = (uint64_t)channel_id_var.inner;
7933         if (channel_id_var.is_owned) {
7934                 channel_id_ref |= 1;
7935         }
7936         LDKChannelMonitor data_var = *data;
7937         uint64_t data_ref = 0;
7938         data_var = ChannelMonitor_clone(data);
7939         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7940         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7941         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
7942         data_ref = (uint64_t)data_var.inner;
7943         if (data_var.is_owned) {
7944                 data_ref |= 1;
7945         }
7946         LDKMonitorUpdateId update_id_var = update_id;
7947         uint64_t update_id_ref = 0;
7948         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7949         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7950         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
7951         update_id_ref = (uint64_t)update_id_var.inner;
7952         if (update_id_var.is_owned) {
7953                 update_id_ref |= 1;
7954         }
7955         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
7956         CHECK(obj != NULL);
7957         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_new_channel_meth, channel_id_ref, data_ref, update_id_ref);
7958         if ((*env)->ExceptionCheck(env)) {
7959                 (*env)->ExceptionDescribe(env);
7960                 (*env)->FatalError(env, "A call to persist_new_channel in LDKPersist from rust threw an exception.");
7961         }
7962         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
7963         CHECK_ACCESS(ret_ptr);
7964         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
7965         FREE((void*)ret);
7966         if (get_jenv_res == JNI_EDETACHED) {
7967                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
7968         }
7969         return ret_conv;
7970 }
7971 LDKCResult_NoneChannelMonitorUpdateErrZ update_persisted_channel_LDKPersist_jcall(const void* this_arg, LDKOutPoint channel_id, const LDKChannelMonitorUpdate * update, const LDKChannelMonitor * data, LDKMonitorUpdateId update_id) {
7972         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) this_arg;
7973         JNIEnv *env;
7974         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
7975         if (get_jenv_res == JNI_EDETACHED) {
7976                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
7977         } else {
7978                 DO_ASSERT(get_jenv_res == JNI_OK);
7979         }
7980         LDKOutPoint channel_id_var = channel_id;
7981         uint64_t channel_id_ref = 0;
7982         CHECK((((uint64_t)channel_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7983         CHECK((((uint64_t)&channel_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7984         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_var);
7985         channel_id_ref = (uint64_t)channel_id_var.inner;
7986         if (channel_id_var.is_owned) {
7987                 channel_id_ref |= 1;
7988         }
7989         LDKChannelMonitorUpdate update_var = *update;
7990         uint64_t update_ref = 0;
7991         if ((uint64_t)update_var.inner > 4096) {
7992                 update_var = ChannelMonitorUpdate_clone(update);
7993                 CHECK((((uint64_t)update_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
7994                 CHECK((((uint64_t)&update_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
7995         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_var);
7996                 update_ref = (uint64_t)update_var.inner;
7997                 if (update_var.is_owned) {
7998                         update_ref |= 1;
7999                 }
8000         }
8001         LDKChannelMonitor data_var = *data;
8002         uint64_t data_ref = 0;
8003         data_var = ChannelMonitor_clone(data);
8004         CHECK((((uint64_t)data_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8005         CHECK((((uint64_t)&data_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8006         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_var);
8007         data_ref = (uint64_t)data_var.inner;
8008         if (data_var.is_owned) {
8009                 data_ref |= 1;
8010         }
8011         LDKMonitorUpdateId update_id_var = update_id;
8012         uint64_t update_id_ref = 0;
8013         CHECK((((uint64_t)update_id_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8014         CHECK((((uint64_t)&update_id_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8015         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_var);
8016         update_id_ref = (uint64_t)update_id_var.inner;
8017         if (update_id_var.is_owned) {
8018                 update_id_ref |= 1;
8019         }
8020         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8021         CHECK(obj != NULL);
8022         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->update_persisted_channel_meth, channel_id_ref, update_ref, data_ref, update_id_ref);
8023         if ((*env)->ExceptionCheck(env)) {
8024                 (*env)->ExceptionDescribe(env);
8025                 (*env)->FatalError(env, "A call to update_persisted_channel in LDKPersist from rust threw an exception.");
8026         }
8027         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
8028         CHECK_ACCESS(ret_ptr);
8029         LDKCResult_NoneChannelMonitorUpdateErrZ ret_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(ret_ptr);
8030         FREE((void*)ret);
8031         if (get_jenv_res == JNI_EDETACHED) {
8032                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8033         }
8034         return ret_conv;
8035 }
8036 static void LDKPersist_JCalls_cloned(LDKPersist* new_obj) {
8037         LDKPersist_JCalls *j_calls = (LDKPersist_JCalls*) new_obj->this_arg;
8038         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8039 }
8040 static inline LDKPersist LDKPersist_init (JNIEnv *env, jclass clz, jobject o) {
8041         jclass c = (*env)->GetObjectClass(env, o);
8042         CHECK(c != NULL);
8043         LDKPersist_JCalls *calls = MALLOC(sizeof(LDKPersist_JCalls), "LDKPersist_JCalls");
8044         atomic_init(&calls->refcnt, 1);
8045         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8046         calls->o = (*env)->NewWeakGlobalRef(env, o);
8047         calls->persist_new_channel_meth = (*env)->GetMethodID(env, c, "persist_new_channel", "(JJJ)J");
8048         CHECK(calls->persist_new_channel_meth != NULL);
8049         calls->update_persisted_channel_meth = (*env)->GetMethodID(env, c, "update_persisted_channel", "(JJJJ)J");
8050         CHECK(calls->update_persisted_channel_meth != NULL);
8051
8052         LDKPersist ret = {
8053                 .this_arg = (void*) calls,
8054                 .persist_new_channel = persist_new_channel_LDKPersist_jcall,
8055                 .update_persisted_channel = update_persisted_channel_LDKPersist_jcall,
8056                 .free = LDKPersist_JCalls_free,
8057         };
8058         return ret;
8059 }
8060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPersist_1new(JNIEnv *env, jclass clz, jobject o) {
8061         LDKPersist *res_ptr = MALLOC(sizeof(LDKPersist), "LDKPersist");
8062         *res_ptr = LDKPersist_init(env, clz, o);
8063         return (uint64_t)res_ptr;
8064 }
8065 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) {
8066         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8067         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8068         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8069         LDKOutPoint channel_id_conv;
8070         channel_id_conv.inner = (void*)(channel_id & (~1));
8071         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8072         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8073         channel_id_conv = OutPoint_clone(&channel_id_conv);
8074         LDKChannelMonitor data_conv;
8075         data_conv.inner = (void*)(data & (~1));
8076         data_conv.is_owned = false;
8077         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8078         LDKMonitorUpdateId update_id_conv;
8079         update_id_conv.inner = (void*)(update_id & (~1));
8080         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8081         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8082         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8083         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8084         *ret_conv = (this_arg_conv->persist_new_channel)(this_arg_conv->this_arg, channel_id_conv, &data_conv, update_id_conv);
8085         return (uint64_t)ret_conv;
8086 }
8087
8088 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) {
8089         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8090         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8091         LDKPersist* this_arg_conv = (LDKPersist*)this_arg_ptr;
8092         LDKOutPoint channel_id_conv;
8093         channel_id_conv.inner = (void*)(channel_id & (~1));
8094         channel_id_conv.is_owned = (channel_id & 1) || (channel_id == 0);
8095         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_id_conv);
8096         channel_id_conv = OutPoint_clone(&channel_id_conv);
8097         LDKChannelMonitorUpdate update_conv;
8098         update_conv.inner = (void*)(update & (~1));
8099         update_conv.is_owned = false;
8100         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_conv);
8101         LDKChannelMonitor data_conv;
8102         data_conv.inner = (void*)(data & (~1));
8103         data_conv.is_owned = false;
8104         CHECK_INNER_FIELD_ACCESS_OR_NULL(data_conv);
8105         LDKMonitorUpdateId update_id_conv;
8106         update_id_conv.inner = (void*)(update_id & (~1));
8107         update_id_conv.is_owned = (update_id & 1) || (update_id == 0);
8108         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_id_conv);
8109         update_id_conv = MonitorUpdateId_clone(&update_id_conv);
8110         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
8111         *ret_conv = (this_arg_conv->update_persisted_channel)(this_arg_conv->this_arg, channel_id_conv, &update_conv, &data_conv, update_id_conv);
8112         return (uint64_t)ret_conv;
8113 }
8114
8115 typedef struct LDKChannelMessageHandler_JCalls {
8116         atomic_size_t refcnt;
8117         JavaVM *vm;
8118         jweak o;
8119         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
8120         jmethodID handle_open_channel_meth;
8121         jmethodID handle_accept_channel_meth;
8122         jmethodID handle_funding_created_meth;
8123         jmethodID handle_funding_signed_meth;
8124         jmethodID handle_funding_locked_meth;
8125         jmethodID handle_shutdown_meth;
8126         jmethodID handle_closing_signed_meth;
8127         jmethodID handle_update_add_htlc_meth;
8128         jmethodID handle_update_fulfill_htlc_meth;
8129         jmethodID handle_update_fail_htlc_meth;
8130         jmethodID handle_update_fail_malformed_htlc_meth;
8131         jmethodID handle_commitment_signed_meth;
8132         jmethodID handle_revoke_and_ack_meth;
8133         jmethodID handle_update_fee_meth;
8134         jmethodID handle_announcement_signatures_meth;
8135         jmethodID peer_disconnected_meth;
8136         jmethodID peer_connected_meth;
8137         jmethodID handle_channel_reestablish_meth;
8138         jmethodID handle_channel_update_meth;
8139         jmethodID handle_error_meth;
8140 } LDKChannelMessageHandler_JCalls;
8141 static void LDKChannelMessageHandler_JCalls_free(void* this_arg) {
8142         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8143         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
8144                 JNIEnv *env;
8145                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8146                 if (get_jenv_res == JNI_EDETACHED) {
8147                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8148                 } else {
8149                         DO_ASSERT(get_jenv_res == JNI_OK);
8150                 }
8151                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
8152                 if (get_jenv_res == JNI_EDETACHED) {
8153                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8154                 }
8155                 FREE(j_calls);
8156         }
8157 }
8158 void handle_open_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKOpenChannel * msg) {
8159         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8160         JNIEnv *env;
8161         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8162         if (get_jenv_res == JNI_EDETACHED) {
8163                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8164         } else {
8165                 DO_ASSERT(get_jenv_res == JNI_OK);
8166         }
8167         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8168         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8169         LDKInitFeatures their_features_var = their_features;
8170         uint64_t their_features_ref = 0;
8171         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8172         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8173         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8174         their_features_ref = (uint64_t)their_features_var.inner;
8175         if (their_features_var.is_owned) {
8176                 their_features_ref |= 1;
8177         }
8178         LDKOpenChannel msg_var = *msg;
8179         uint64_t msg_ref = 0;
8180         msg_var = OpenChannel_clone(msg);
8181         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8182         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8183         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8184         msg_ref = (uint64_t)msg_var.inner;
8185         if (msg_var.is_owned) {
8186                 msg_ref |= 1;
8187         }
8188         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8189         CHECK(obj != NULL);
8190         (*env)->CallVoidMethod(env, obj, j_calls->handle_open_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8191         if ((*env)->ExceptionCheck(env)) {
8192                 (*env)->ExceptionDescribe(env);
8193                 (*env)->FatalError(env, "A call to handle_open_channel in LDKChannelMessageHandler from rust threw an exception.");
8194         }
8195         if (get_jenv_res == JNI_EDETACHED) {
8196                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8197         }
8198 }
8199 void handle_accept_channel_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKInitFeatures their_features, const LDKAcceptChannel * msg) {
8200         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8201         JNIEnv *env;
8202         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8203         if (get_jenv_res == JNI_EDETACHED) {
8204                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8205         } else {
8206                 DO_ASSERT(get_jenv_res == JNI_OK);
8207         }
8208         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8209         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8210         LDKInitFeatures their_features_var = their_features;
8211         uint64_t their_features_ref = 0;
8212         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8213         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8214         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8215         their_features_ref = (uint64_t)their_features_var.inner;
8216         if (their_features_var.is_owned) {
8217                 their_features_ref |= 1;
8218         }
8219         LDKAcceptChannel msg_var = *msg;
8220         uint64_t msg_ref = 0;
8221         msg_var = AcceptChannel_clone(msg);
8222         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8223         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8224         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8225         msg_ref = (uint64_t)msg_var.inner;
8226         if (msg_var.is_owned) {
8227                 msg_ref |= 1;
8228         }
8229         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8230         CHECK(obj != NULL);
8231         (*env)->CallVoidMethod(env, obj, j_calls->handle_accept_channel_meth, their_node_id_arr, their_features_ref, msg_ref);
8232         if ((*env)->ExceptionCheck(env)) {
8233                 (*env)->ExceptionDescribe(env);
8234                 (*env)->FatalError(env, "A call to handle_accept_channel in LDKChannelMessageHandler from rust threw an exception.");
8235         }
8236         if (get_jenv_res == JNI_EDETACHED) {
8237                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8238         }
8239 }
8240 void handle_funding_created_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingCreated * msg) {
8241         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8242         JNIEnv *env;
8243         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8244         if (get_jenv_res == JNI_EDETACHED) {
8245                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8246         } else {
8247                 DO_ASSERT(get_jenv_res == JNI_OK);
8248         }
8249         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8250         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8251         LDKFundingCreated msg_var = *msg;
8252         uint64_t msg_ref = 0;
8253         msg_var = FundingCreated_clone(msg);
8254         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8255         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8256         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8257         msg_ref = (uint64_t)msg_var.inner;
8258         if (msg_var.is_owned) {
8259                 msg_ref |= 1;
8260         }
8261         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8262         CHECK(obj != NULL);
8263         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_created_meth, their_node_id_arr, msg_ref);
8264         if ((*env)->ExceptionCheck(env)) {
8265                 (*env)->ExceptionDescribe(env);
8266                 (*env)->FatalError(env, "A call to handle_funding_created in LDKChannelMessageHandler from rust threw an exception.");
8267         }
8268         if (get_jenv_res == JNI_EDETACHED) {
8269                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8270         }
8271 }
8272 void handle_funding_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingSigned * msg) {
8273         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8274         JNIEnv *env;
8275         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8276         if (get_jenv_res == JNI_EDETACHED) {
8277                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8278         } else {
8279                 DO_ASSERT(get_jenv_res == JNI_OK);
8280         }
8281         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8282         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8283         LDKFundingSigned msg_var = *msg;
8284         uint64_t msg_ref = 0;
8285         msg_var = FundingSigned_clone(msg);
8286         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8287         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8288         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8289         msg_ref = (uint64_t)msg_var.inner;
8290         if (msg_var.is_owned) {
8291                 msg_ref |= 1;
8292         }
8293         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8294         CHECK(obj != NULL);
8295         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_signed_meth, their_node_id_arr, msg_ref);
8296         if ((*env)->ExceptionCheck(env)) {
8297                 (*env)->ExceptionDescribe(env);
8298                 (*env)->FatalError(env, "A call to handle_funding_signed in LDKChannelMessageHandler from rust threw an exception.");
8299         }
8300         if (get_jenv_res == JNI_EDETACHED) {
8301                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8302         }
8303 }
8304 void handle_funding_locked_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKFundingLocked * msg) {
8305         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8306         JNIEnv *env;
8307         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8308         if (get_jenv_res == JNI_EDETACHED) {
8309                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8310         } else {
8311                 DO_ASSERT(get_jenv_res == JNI_OK);
8312         }
8313         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8314         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8315         LDKFundingLocked msg_var = *msg;
8316         uint64_t msg_ref = 0;
8317         msg_var = FundingLocked_clone(msg);
8318         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8319         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8320         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8321         msg_ref = (uint64_t)msg_var.inner;
8322         if (msg_var.is_owned) {
8323                 msg_ref |= 1;
8324         }
8325         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8326         CHECK(obj != NULL);
8327         (*env)->CallVoidMethod(env, obj, j_calls->handle_funding_locked_meth, their_node_id_arr, msg_ref);
8328         if ((*env)->ExceptionCheck(env)) {
8329                 (*env)->ExceptionDescribe(env);
8330                 (*env)->FatalError(env, "A call to handle_funding_locked in LDKChannelMessageHandler from rust threw an exception.");
8331         }
8332         if (get_jenv_res == JNI_EDETACHED) {
8333                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8334         }
8335 }
8336 void handle_shutdown_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInitFeatures * their_features, const LDKShutdown * msg) {
8337         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8338         JNIEnv *env;
8339         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8340         if (get_jenv_res == JNI_EDETACHED) {
8341                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8342         } else {
8343                 DO_ASSERT(get_jenv_res == JNI_OK);
8344         }
8345         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8346         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8347         LDKInitFeatures their_features_var = *their_features;
8348         uint64_t their_features_ref = 0;
8349         their_features_var = InitFeatures_clone(their_features);
8350         CHECK((((uint64_t)their_features_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8351         CHECK((((uint64_t)&their_features_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8352         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_var);
8353         their_features_ref = (uint64_t)their_features_var.inner;
8354         if (their_features_var.is_owned) {
8355                 their_features_ref |= 1;
8356         }
8357         LDKShutdown msg_var = *msg;
8358         uint64_t msg_ref = 0;
8359         msg_var = Shutdown_clone(msg);
8360         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8361         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8362         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8363         msg_ref = (uint64_t)msg_var.inner;
8364         if (msg_var.is_owned) {
8365                 msg_ref |= 1;
8366         }
8367         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8368         CHECK(obj != NULL);
8369         (*env)->CallVoidMethod(env, obj, j_calls->handle_shutdown_meth, their_node_id_arr, their_features_ref, msg_ref);
8370         if ((*env)->ExceptionCheck(env)) {
8371                 (*env)->ExceptionDescribe(env);
8372                 (*env)->FatalError(env, "A call to handle_shutdown in LDKChannelMessageHandler from rust threw an exception.");
8373         }
8374         if (get_jenv_res == JNI_EDETACHED) {
8375                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8376         }
8377 }
8378 void handle_closing_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKClosingSigned * msg) {
8379         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8380         JNIEnv *env;
8381         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8382         if (get_jenv_res == JNI_EDETACHED) {
8383                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8384         } else {
8385                 DO_ASSERT(get_jenv_res == JNI_OK);
8386         }
8387         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8388         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8389         LDKClosingSigned msg_var = *msg;
8390         uint64_t msg_ref = 0;
8391         msg_var = ClosingSigned_clone(msg);
8392         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8393         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8394         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8395         msg_ref = (uint64_t)msg_var.inner;
8396         if (msg_var.is_owned) {
8397                 msg_ref |= 1;
8398         }
8399         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8400         CHECK(obj != NULL);
8401         (*env)->CallVoidMethod(env, obj, j_calls->handle_closing_signed_meth, their_node_id_arr, msg_ref);
8402         if ((*env)->ExceptionCheck(env)) {
8403                 (*env)->ExceptionDescribe(env);
8404                 (*env)->FatalError(env, "A call to handle_closing_signed in LDKChannelMessageHandler from rust threw an exception.");
8405         }
8406         if (get_jenv_res == JNI_EDETACHED) {
8407                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8408         }
8409 }
8410 void handle_update_add_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateAddHTLC * msg) {
8411         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8412         JNIEnv *env;
8413         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8414         if (get_jenv_res == JNI_EDETACHED) {
8415                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8416         } else {
8417                 DO_ASSERT(get_jenv_res == JNI_OK);
8418         }
8419         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8420         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8421         LDKUpdateAddHTLC msg_var = *msg;
8422         uint64_t msg_ref = 0;
8423         msg_var = UpdateAddHTLC_clone(msg);
8424         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8425         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8426         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8427         msg_ref = (uint64_t)msg_var.inner;
8428         if (msg_var.is_owned) {
8429                 msg_ref |= 1;
8430         }
8431         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8432         CHECK(obj != NULL);
8433         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_add_htlc_meth, their_node_id_arr, msg_ref);
8434         if ((*env)->ExceptionCheck(env)) {
8435                 (*env)->ExceptionDescribe(env);
8436                 (*env)->FatalError(env, "A call to handle_update_add_htlc in LDKChannelMessageHandler from rust threw an exception.");
8437         }
8438         if (get_jenv_res == JNI_EDETACHED) {
8439                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8440         }
8441 }
8442 void handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFulfillHTLC * msg) {
8443         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8444         JNIEnv *env;
8445         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8446         if (get_jenv_res == JNI_EDETACHED) {
8447                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8448         } else {
8449                 DO_ASSERT(get_jenv_res == JNI_OK);
8450         }
8451         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8452         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8453         LDKUpdateFulfillHTLC msg_var = *msg;
8454         uint64_t msg_ref = 0;
8455         msg_var = UpdateFulfillHTLC_clone(msg);
8456         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8457         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8458         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8459         msg_ref = (uint64_t)msg_var.inner;
8460         if (msg_var.is_owned) {
8461                 msg_ref |= 1;
8462         }
8463         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8464         CHECK(obj != NULL);
8465         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fulfill_htlc_meth, their_node_id_arr, msg_ref);
8466         if ((*env)->ExceptionCheck(env)) {
8467                 (*env)->ExceptionDescribe(env);
8468                 (*env)->FatalError(env, "A call to handle_update_fulfill_htlc in LDKChannelMessageHandler from rust threw an exception.");
8469         }
8470         if (get_jenv_res == JNI_EDETACHED) {
8471                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8472         }
8473 }
8474 void handle_update_fail_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailHTLC * msg) {
8475         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8476         JNIEnv *env;
8477         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8478         if (get_jenv_res == JNI_EDETACHED) {
8479                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8480         } else {
8481                 DO_ASSERT(get_jenv_res == JNI_OK);
8482         }
8483         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8484         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8485         LDKUpdateFailHTLC msg_var = *msg;
8486         uint64_t msg_ref = 0;
8487         msg_var = UpdateFailHTLC_clone(msg);
8488         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8489         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8490         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8491         msg_ref = (uint64_t)msg_var.inner;
8492         if (msg_var.is_owned) {
8493                 msg_ref |= 1;
8494         }
8495         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8496         CHECK(obj != NULL);
8497         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_htlc_meth, their_node_id_arr, msg_ref);
8498         if ((*env)->ExceptionCheck(env)) {
8499                 (*env)->ExceptionDescribe(env);
8500                 (*env)->FatalError(env, "A call to handle_update_fail_htlc in LDKChannelMessageHandler from rust threw an exception.");
8501         }
8502         if (get_jenv_res == JNI_EDETACHED) {
8503                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8504         }
8505 }
8506 void handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFailMalformedHTLC * msg) {
8507         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8508         JNIEnv *env;
8509         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8510         if (get_jenv_res == JNI_EDETACHED) {
8511                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8512         } else {
8513                 DO_ASSERT(get_jenv_res == JNI_OK);
8514         }
8515         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8516         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8517         LDKUpdateFailMalformedHTLC msg_var = *msg;
8518         uint64_t msg_ref = 0;
8519         msg_var = UpdateFailMalformedHTLC_clone(msg);
8520         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8521         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8522         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8523         msg_ref = (uint64_t)msg_var.inner;
8524         if (msg_var.is_owned) {
8525                 msg_ref |= 1;
8526         }
8527         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8528         CHECK(obj != NULL);
8529         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fail_malformed_htlc_meth, their_node_id_arr, msg_ref);
8530         if ((*env)->ExceptionCheck(env)) {
8531                 (*env)->ExceptionDescribe(env);
8532                 (*env)->FatalError(env, "A call to handle_update_fail_malformed_htlc in LDKChannelMessageHandler from rust threw an exception.");
8533         }
8534         if (get_jenv_res == JNI_EDETACHED) {
8535                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8536         }
8537 }
8538 void handle_commitment_signed_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKCommitmentSigned * msg) {
8539         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8540         JNIEnv *env;
8541         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8542         if (get_jenv_res == JNI_EDETACHED) {
8543                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8544         } else {
8545                 DO_ASSERT(get_jenv_res == JNI_OK);
8546         }
8547         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8548         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8549         LDKCommitmentSigned msg_var = *msg;
8550         uint64_t msg_ref = 0;
8551         msg_var = CommitmentSigned_clone(msg);
8552         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8553         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8554         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8555         msg_ref = (uint64_t)msg_var.inner;
8556         if (msg_var.is_owned) {
8557                 msg_ref |= 1;
8558         }
8559         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8560         CHECK(obj != NULL);
8561         (*env)->CallVoidMethod(env, obj, j_calls->handle_commitment_signed_meth, their_node_id_arr, msg_ref);
8562         if ((*env)->ExceptionCheck(env)) {
8563                 (*env)->ExceptionDescribe(env);
8564                 (*env)->FatalError(env, "A call to handle_commitment_signed in LDKChannelMessageHandler from rust threw an exception.");
8565         }
8566         if (get_jenv_res == JNI_EDETACHED) {
8567                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8568         }
8569 }
8570 void handle_revoke_and_ack_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKRevokeAndACK * msg) {
8571         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8572         JNIEnv *env;
8573         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8574         if (get_jenv_res == JNI_EDETACHED) {
8575                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8576         } else {
8577                 DO_ASSERT(get_jenv_res == JNI_OK);
8578         }
8579         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8580         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8581         LDKRevokeAndACK msg_var = *msg;
8582         uint64_t msg_ref = 0;
8583         msg_var = RevokeAndACK_clone(msg);
8584         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8585         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8586         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8587         msg_ref = (uint64_t)msg_var.inner;
8588         if (msg_var.is_owned) {
8589                 msg_ref |= 1;
8590         }
8591         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8592         CHECK(obj != NULL);
8593         (*env)->CallVoidMethod(env, obj, j_calls->handle_revoke_and_ack_meth, their_node_id_arr, msg_ref);
8594         if ((*env)->ExceptionCheck(env)) {
8595                 (*env)->ExceptionDescribe(env);
8596                 (*env)->FatalError(env, "A call to handle_revoke_and_ack in LDKChannelMessageHandler from rust threw an exception.");
8597         }
8598         if (get_jenv_res == JNI_EDETACHED) {
8599                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8600         }
8601 }
8602 void handle_update_fee_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKUpdateFee * msg) {
8603         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8604         JNIEnv *env;
8605         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8606         if (get_jenv_res == JNI_EDETACHED) {
8607                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8608         } else {
8609                 DO_ASSERT(get_jenv_res == JNI_OK);
8610         }
8611         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8612         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8613         LDKUpdateFee msg_var = *msg;
8614         uint64_t msg_ref = 0;
8615         msg_var = UpdateFee_clone(msg);
8616         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8617         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8618         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8619         msg_ref = (uint64_t)msg_var.inner;
8620         if (msg_var.is_owned) {
8621                 msg_ref |= 1;
8622         }
8623         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8624         CHECK(obj != NULL);
8625         (*env)->CallVoidMethod(env, obj, j_calls->handle_update_fee_meth, their_node_id_arr, msg_ref);
8626         if ((*env)->ExceptionCheck(env)) {
8627                 (*env)->ExceptionDescribe(env);
8628                 (*env)->FatalError(env, "A call to handle_update_fee in LDKChannelMessageHandler from rust threw an exception.");
8629         }
8630         if (get_jenv_res == JNI_EDETACHED) {
8631                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8632         }
8633 }
8634 void handle_announcement_signatures_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKAnnouncementSignatures * msg) {
8635         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8636         JNIEnv *env;
8637         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8638         if (get_jenv_res == JNI_EDETACHED) {
8639                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8640         } else {
8641                 DO_ASSERT(get_jenv_res == JNI_OK);
8642         }
8643         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8644         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8645         LDKAnnouncementSignatures msg_var = *msg;
8646         uint64_t msg_ref = 0;
8647         msg_var = AnnouncementSignatures_clone(msg);
8648         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8649         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8650         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8651         msg_ref = (uint64_t)msg_var.inner;
8652         if (msg_var.is_owned) {
8653                 msg_ref |= 1;
8654         }
8655         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8656         CHECK(obj != NULL);
8657         (*env)->CallVoidMethod(env, obj, j_calls->handle_announcement_signatures_meth, their_node_id_arr, msg_ref);
8658         if ((*env)->ExceptionCheck(env)) {
8659                 (*env)->ExceptionDescribe(env);
8660                 (*env)->FatalError(env, "A call to handle_announcement_signatures in LDKChannelMessageHandler from rust threw an exception.");
8661         }
8662         if (get_jenv_res == JNI_EDETACHED) {
8663                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8664         }
8665 }
8666 void peer_disconnected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, bool no_connection_possible) {
8667         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8668         JNIEnv *env;
8669         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8670         if (get_jenv_res == JNI_EDETACHED) {
8671                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8672         } else {
8673                 DO_ASSERT(get_jenv_res == JNI_OK);
8674         }
8675         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8676         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8677         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8678         CHECK(obj != NULL);
8679         (*env)->CallVoidMethod(env, obj, j_calls->peer_disconnected_meth, their_node_id_arr, no_connection_possible);
8680         if ((*env)->ExceptionCheck(env)) {
8681                 (*env)->ExceptionDescribe(env);
8682                 (*env)->FatalError(env, "A call to peer_disconnected in LDKChannelMessageHandler from rust threw an exception.");
8683         }
8684         if (get_jenv_res == JNI_EDETACHED) {
8685                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8686         }
8687 }
8688 void peer_connected_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * msg) {
8689         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8690         JNIEnv *env;
8691         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8692         if (get_jenv_res == JNI_EDETACHED) {
8693                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8694         } else {
8695                 DO_ASSERT(get_jenv_res == JNI_OK);
8696         }
8697         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8698         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8699         LDKInit msg_var = *msg;
8700         uint64_t msg_ref = 0;
8701         msg_var = Init_clone(msg);
8702         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8703         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8704         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8705         msg_ref = (uint64_t)msg_var.inner;
8706         if (msg_var.is_owned) {
8707                 msg_ref |= 1;
8708         }
8709         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8710         CHECK(obj != NULL);
8711         (*env)->CallVoidMethod(env, obj, j_calls->peer_connected_meth, their_node_id_arr, msg_ref);
8712         if ((*env)->ExceptionCheck(env)) {
8713                 (*env)->ExceptionDescribe(env);
8714                 (*env)->FatalError(env, "A call to peer_connected in LDKChannelMessageHandler from rust threw an exception.");
8715         }
8716         if (get_jenv_res == JNI_EDETACHED) {
8717                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8718         }
8719 }
8720 void handle_channel_reestablish_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelReestablish * msg) {
8721         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8722         JNIEnv *env;
8723         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8724         if (get_jenv_res == JNI_EDETACHED) {
8725                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8726         } else {
8727                 DO_ASSERT(get_jenv_res == JNI_OK);
8728         }
8729         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8730         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8731         LDKChannelReestablish msg_var = *msg;
8732         uint64_t msg_ref = 0;
8733         msg_var = ChannelReestablish_clone(msg);
8734         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8735         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8736         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8737         msg_ref = (uint64_t)msg_var.inner;
8738         if (msg_var.is_owned) {
8739                 msg_ref |= 1;
8740         }
8741         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8742         CHECK(obj != NULL);
8743         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_reestablish_meth, their_node_id_arr, msg_ref);
8744         if ((*env)->ExceptionCheck(env)) {
8745                 (*env)->ExceptionDescribe(env);
8746                 (*env)->FatalError(env, "A call to handle_channel_reestablish in LDKChannelMessageHandler from rust threw an exception.");
8747         }
8748         if (get_jenv_res == JNI_EDETACHED) {
8749                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8750         }
8751 }
8752 void handle_channel_update_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKChannelUpdate * msg) {
8753         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8754         JNIEnv *env;
8755         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8756         if (get_jenv_res == JNI_EDETACHED) {
8757                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8758         } else {
8759                 DO_ASSERT(get_jenv_res == JNI_OK);
8760         }
8761         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8762         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8763         LDKChannelUpdate msg_var = *msg;
8764         uint64_t msg_ref = 0;
8765         msg_var = ChannelUpdate_clone(msg);
8766         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8767         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8768         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8769         msg_ref = (uint64_t)msg_var.inner;
8770         if (msg_var.is_owned) {
8771                 msg_ref |= 1;
8772         }
8773         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8774         CHECK(obj != NULL);
8775         (*env)->CallVoidMethod(env, obj, j_calls->handle_channel_update_meth, their_node_id_arr, msg_ref);
8776         if ((*env)->ExceptionCheck(env)) {
8777                 (*env)->ExceptionDescribe(env);
8778                 (*env)->FatalError(env, "A call to handle_channel_update in LDKChannelMessageHandler from rust threw an exception.");
8779         }
8780         if (get_jenv_res == JNI_EDETACHED) {
8781                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8782         }
8783 }
8784 void handle_error_LDKChannelMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKErrorMessage * msg) {
8785         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) this_arg;
8786         JNIEnv *env;
8787         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
8788         if (get_jenv_res == JNI_EDETACHED) {
8789                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
8790         } else {
8791                 DO_ASSERT(get_jenv_res == JNI_OK);
8792         }
8793         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
8794         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
8795         LDKErrorMessage msg_var = *msg;
8796         uint64_t msg_ref = 0;
8797         msg_var = ErrorMessage_clone(msg);
8798         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
8799         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
8800         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
8801         msg_ref = (uint64_t)msg_var.inner;
8802         if (msg_var.is_owned) {
8803                 msg_ref |= 1;
8804         }
8805         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
8806         CHECK(obj != NULL);
8807         (*env)->CallVoidMethod(env, obj, j_calls->handle_error_meth, their_node_id_arr, msg_ref);
8808         if ((*env)->ExceptionCheck(env)) {
8809                 (*env)->ExceptionDescribe(env);
8810                 (*env)->FatalError(env, "A call to handle_error in LDKChannelMessageHandler from rust threw an exception.");
8811         }
8812         if (get_jenv_res == JNI_EDETACHED) {
8813                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
8814         }
8815 }
8816 static void LDKChannelMessageHandler_JCalls_cloned(LDKChannelMessageHandler* new_obj) {
8817         LDKChannelMessageHandler_JCalls *j_calls = (LDKChannelMessageHandler_JCalls*) new_obj->this_arg;
8818         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
8819         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
8820 }
8821 static inline LDKChannelMessageHandler LDKChannelMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8822         jclass c = (*env)->GetObjectClass(env, o);
8823         CHECK(c != NULL);
8824         LDKChannelMessageHandler_JCalls *calls = MALLOC(sizeof(LDKChannelMessageHandler_JCalls), "LDKChannelMessageHandler_JCalls");
8825         atomic_init(&calls->refcnt, 1);
8826         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
8827         calls->o = (*env)->NewWeakGlobalRef(env, o);
8828         calls->handle_open_channel_meth = (*env)->GetMethodID(env, c, "handle_open_channel", "([BJJ)V");
8829         CHECK(calls->handle_open_channel_meth != NULL);
8830         calls->handle_accept_channel_meth = (*env)->GetMethodID(env, c, "handle_accept_channel", "([BJJ)V");
8831         CHECK(calls->handle_accept_channel_meth != NULL);
8832         calls->handle_funding_created_meth = (*env)->GetMethodID(env, c, "handle_funding_created", "([BJ)V");
8833         CHECK(calls->handle_funding_created_meth != NULL);
8834         calls->handle_funding_signed_meth = (*env)->GetMethodID(env, c, "handle_funding_signed", "([BJ)V");
8835         CHECK(calls->handle_funding_signed_meth != NULL);
8836         calls->handle_funding_locked_meth = (*env)->GetMethodID(env, c, "handle_funding_locked", "([BJ)V");
8837         CHECK(calls->handle_funding_locked_meth != NULL);
8838         calls->handle_shutdown_meth = (*env)->GetMethodID(env, c, "handle_shutdown", "([BJJ)V");
8839         CHECK(calls->handle_shutdown_meth != NULL);
8840         calls->handle_closing_signed_meth = (*env)->GetMethodID(env, c, "handle_closing_signed", "([BJ)V");
8841         CHECK(calls->handle_closing_signed_meth != NULL);
8842         calls->handle_update_add_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_add_htlc", "([BJ)V");
8843         CHECK(calls->handle_update_add_htlc_meth != NULL);
8844         calls->handle_update_fulfill_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fulfill_htlc", "([BJ)V");
8845         CHECK(calls->handle_update_fulfill_htlc_meth != NULL);
8846         calls->handle_update_fail_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_htlc", "([BJ)V");
8847         CHECK(calls->handle_update_fail_htlc_meth != NULL);
8848         calls->handle_update_fail_malformed_htlc_meth = (*env)->GetMethodID(env, c, "handle_update_fail_malformed_htlc", "([BJ)V");
8849         CHECK(calls->handle_update_fail_malformed_htlc_meth != NULL);
8850         calls->handle_commitment_signed_meth = (*env)->GetMethodID(env, c, "handle_commitment_signed", "([BJ)V");
8851         CHECK(calls->handle_commitment_signed_meth != NULL);
8852         calls->handle_revoke_and_ack_meth = (*env)->GetMethodID(env, c, "handle_revoke_and_ack", "([BJ)V");
8853         CHECK(calls->handle_revoke_and_ack_meth != NULL);
8854         calls->handle_update_fee_meth = (*env)->GetMethodID(env, c, "handle_update_fee", "([BJ)V");
8855         CHECK(calls->handle_update_fee_meth != NULL);
8856         calls->handle_announcement_signatures_meth = (*env)->GetMethodID(env, c, "handle_announcement_signatures", "([BJ)V");
8857         CHECK(calls->handle_announcement_signatures_meth != NULL);
8858         calls->peer_disconnected_meth = (*env)->GetMethodID(env, c, "peer_disconnected", "([BZ)V");
8859         CHECK(calls->peer_disconnected_meth != NULL);
8860         calls->peer_connected_meth = (*env)->GetMethodID(env, c, "peer_connected", "([BJ)V");
8861         CHECK(calls->peer_connected_meth != NULL);
8862         calls->handle_channel_reestablish_meth = (*env)->GetMethodID(env, c, "handle_channel_reestablish", "([BJ)V");
8863         CHECK(calls->handle_channel_reestablish_meth != NULL);
8864         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "([BJ)V");
8865         CHECK(calls->handle_channel_update_meth != NULL);
8866         calls->handle_error_meth = (*env)->GetMethodID(env, c, "handle_error", "([BJ)V");
8867         CHECK(calls->handle_error_meth != NULL);
8868
8869         LDKChannelMessageHandler ret = {
8870                 .this_arg = (void*) calls,
8871                 .handle_open_channel = handle_open_channel_LDKChannelMessageHandler_jcall,
8872                 .handle_accept_channel = handle_accept_channel_LDKChannelMessageHandler_jcall,
8873                 .handle_funding_created = handle_funding_created_LDKChannelMessageHandler_jcall,
8874                 .handle_funding_signed = handle_funding_signed_LDKChannelMessageHandler_jcall,
8875                 .handle_funding_locked = handle_funding_locked_LDKChannelMessageHandler_jcall,
8876                 .handle_shutdown = handle_shutdown_LDKChannelMessageHandler_jcall,
8877                 .handle_closing_signed = handle_closing_signed_LDKChannelMessageHandler_jcall,
8878                 .handle_update_add_htlc = handle_update_add_htlc_LDKChannelMessageHandler_jcall,
8879                 .handle_update_fulfill_htlc = handle_update_fulfill_htlc_LDKChannelMessageHandler_jcall,
8880                 .handle_update_fail_htlc = handle_update_fail_htlc_LDKChannelMessageHandler_jcall,
8881                 .handle_update_fail_malformed_htlc = handle_update_fail_malformed_htlc_LDKChannelMessageHandler_jcall,
8882                 .handle_commitment_signed = handle_commitment_signed_LDKChannelMessageHandler_jcall,
8883                 .handle_revoke_and_ack = handle_revoke_and_ack_LDKChannelMessageHandler_jcall,
8884                 .handle_update_fee = handle_update_fee_LDKChannelMessageHandler_jcall,
8885                 .handle_announcement_signatures = handle_announcement_signatures_LDKChannelMessageHandler_jcall,
8886                 .peer_disconnected = peer_disconnected_LDKChannelMessageHandler_jcall,
8887                 .peer_connected = peer_connected_LDKChannelMessageHandler_jcall,
8888                 .handle_channel_reestablish = handle_channel_reestablish_LDKChannelMessageHandler_jcall,
8889                 .handle_channel_update = handle_channel_update_LDKChannelMessageHandler_jcall,
8890                 .handle_error = handle_error_LDKChannelMessageHandler_jcall,
8891                 .free = LDKChannelMessageHandler_JCalls_free,
8892                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
8893         };
8894         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
8895         return ret;
8896 }
8897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
8898         LDKChannelMessageHandler *res_ptr = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
8899         *res_ptr = LDKChannelMessageHandler_init(env, clz, o, MessageSendEventsProvider);
8900         return (uint64_t)res_ptr;
8901 }
8902 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
8903         LDKChannelMessageHandler *inp = (LDKChannelMessageHandler *)(arg & ~1);
8904         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
8905         DO_ASSERT((res_ptr & 1) == 0);
8906         return (int64_t)(res_ptr | 1);
8907 }
8908 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) {
8909         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8910         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8911         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8912         LDKPublicKey their_node_id_ref;
8913         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8914         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8915         LDKInitFeatures their_features_conv;
8916         their_features_conv.inner = (void*)(their_features & (~1));
8917         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8918         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8919         their_features_conv = InitFeatures_clone(&their_features_conv);
8920         LDKOpenChannel msg_conv;
8921         msg_conv.inner = (void*)(msg & (~1));
8922         msg_conv.is_owned = false;
8923         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8924         (this_arg_conv->handle_open_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8925 }
8926
8927 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) {
8928         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8929         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8930         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8931         LDKPublicKey their_node_id_ref;
8932         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8933         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8934         LDKInitFeatures their_features_conv;
8935         their_features_conv.inner = (void*)(their_features & (~1));
8936         their_features_conv.is_owned = (their_features & 1) || (their_features == 0);
8937         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8938         their_features_conv = InitFeatures_clone(&their_features_conv);
8939         LDKAcceptChannel msg_conv;
8940         msg_conv.inner = (void*)(msg & (~1));
8941         msg_conv.is_owned = false;
8942         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8943         (this_arg_conv->handle_accept_channel)(this_arg_conv->this_arg, their_node_id_ref, their_features_conv, &msg_conv);
8944 }
8945
8946 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) {
8947         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8948         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8949         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8950         LDKPublicKey their_node_id_ref;
8951         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8952         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8953         LDKFundingCreated msg_conv;
8954         msg_conv.inner = (void*)(msg & (~1));
8955         msg_conv.is_owned = false;
8956         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8957         (this_arg_conv->handle_funding_created)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8958 }
8959
8960 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) {
8961         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8962         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8963         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8964         LDKPublicKey their_node_id_ref;
8965         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8966         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8967         LDKFundingSigned msg_conv;
8968         msg_conv.inner = (void*)(msg & (~1));
8969         msg_conv.is_owned = false;
8970         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8971         (this_arg_conv->handle_funding_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8972 }
8973
8974 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) {
8975         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8976         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8977         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8978         LDKPublicKey their_node_id_ref;
8979         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8980         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8981         LDKFundingLocked msg_conv;
8982         msg_conv.inner = (void*)(msg & (~1));
8983         msg_conv.is_owned = false;
8984         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
8985         (this_arg_conv->handle_funding_locked)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
8986 }
8987
8988 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) {
8989         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
8990         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
8991         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
8992         LDKPublicKey their_node_id_ref;
8993         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
8994         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
8995         LDKInitFeatures their_features_conv;
8996         their_features_conv.inner = (void*)(their_features & (~1));
8997         their_features_conv.is_owned = false;
8998         CHECK_INNER_FIELD_ACCESS_OR_NULL(their_features_conv);
8999         LDKShutdown msg_conv;
9000         msg_conv.inner = (void*)(msg & (~1));
9001         msg_conv.is_owned = false;
9002         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9003         (this_arg_conv->handle_shutdown)(this_arg_conv->this_arg, their_node_id_ref, &their_features_conv, &msg_conv);
9004 }
9005
9006 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) {
9007         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9008         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9009         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9010         LDKPublicKey their_node_id_ref;
9011         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9012         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9013         LDKClosingSigned msg_conv;
9014         msg_conv.inner = (void*)(msg & (~1));
9015         msg_conv.is_owned = false;
9016         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9017         (this_arg_conv->handle_closing_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9018 }
9019
9020 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) {
9021         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9022         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9023         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9024         LDKPublicKey their_node_id_ref;
9025         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9026         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9027         LDKUpdateAddHTLC msg_conv;
9028         msg_conv.inner = (void*)(msg & (~1));
9029         msg_conv.is_owned = false;
9030         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9031         (this_arg_conv->handle_update_add_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9032 }
9033
9034 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) {
9035         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9036         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9037         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9038         LDKPublicKey their_node_id_ref;
9039         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9040         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9041         LDKUpdateFulfillHTLC msg_conv;
9042         msg_conv.inner = (void*)(msg & (~1));
9043         msg_conv.is_owned = false;
9044         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9045         (this_arg_conv->handle_update_fulfill_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9046 }
9047
9048 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) {
9049         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9050         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9051         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9052         LDKPublicKey their_node_id_ref;
9053         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9054         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9055         LDKUpdateFailHTLC msg_conv;
9056         msg_conv.inner = (void*)(msg & (~1));
9057         msg_conv.is_owned = false;
9058         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9059         (this_arg_conv->handle_update_fail_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9060 }
9061
9062 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) {
9063         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9064         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9065         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9066         LDKPublicKey their_node_id_ref;
9067         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9068         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9069         LDKUpdateFailMalformedHTLC msg_conv;
9070         msg_conv.inner = (void*)(msg & (~1));
9071         msg_conv.is_owned = false;
9072         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9073         (this_arg_conv->handle_update_fail_malformed_htlc)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9074 }
9075
9076 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) {
9077         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9078         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9079         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9080         LDKPublicKey their_node_id_ref;
9081         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9082         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9083         LDKCommitmentSigned msg_conv;
9084         msg_conv.inner = (void*)(msg & (~1));
9085         msg_conv.is_owned = false;
9086         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9087         (this_arg_conv->handle_commitment_signed)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9088 }
9089
9090 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) {
9091         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9092         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9093         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9094         LDKPublicKey their_node_id_ref;
9095         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9096         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9097         LDKRevokeAndACK msg_conv;
9098         msg_conv.inner = (void*)(msg & (~1));
9099         msg_conv.is_owned = false;
9100         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9101         (this_arg_conv->handle_revoke_and_ack)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9102 }
9103
9104 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) {
9105         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9106         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9107         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9108         LDKPublicKey their_node_id_ref;
9109         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9110         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9111         LDKUpdateFee msg_conv;
9112         msg_conv.inner = (void*)(msg & (~1));
9113         msg_conv.is_owned = false;
9114         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9115         (this_arg_conv->handle_update_fee)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9116 }
9117
9118 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) {
9119         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9120         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9121         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9122         LDKPublicKey their_node_id_ref;
9123         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9124         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9125         LDKAnnouncementSignatures msg_conv;
9126         msg_conv.inner = (void*)(msg & (~1));
9127         msg_conv.is_owned = false;
9128         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9129         (this_arg_conv->handle_announcement_signatures)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9130 }
9131
9132 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) {
9133         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9134         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9135         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9136         LDKPublicKey their_node_id_ref;
9137         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9138         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9139         (this_arg_conv->peer_disconnected)(this_arg_conv->this_arg, their_node_id_ref, no_connection_possible);
9140 }
9141
9142 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) {
9143         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9144         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9145         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9146         LDKPublicKey their_node_id_ref;
9147         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9148         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9149         LDKInit msg_conv;
9150         msg_conv.inner = (void*)(msg & (~1));
9151         msg_conv.is_owned = false;
9152         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9153         (this_arg_conv->peer_connected)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9154 }
9155
9156 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) {
9157         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9158         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9159         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9160         LDKPublicKey their_node_id_ref;
9161         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9162         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9163         LDKChannelReestablish msg_conv;
9164         msg_conv.inner = (void*)(msg & (~1));
9165         msg_conv.is_owned = false;
9166         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9167         (this_arg_conv->handle_channel_reestablish)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9168 }
9169
9170 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) {
9171         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9172         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9173         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9174         LDKPublicKey their_node_id_ref;
9175         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9176         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9177         LDKChannelUpdate msg_conv;
9178         msg_conv.inner = (void*)(msg & (~1));
9179         msg_conv.is_owned = false;
9180         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9181         (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9182 }
9183
9184 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) {
9185         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9186         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9187         LDKChannelMessageHandler* this_arg_conv = (LDKChannelMessageHandler*)this_arg_ptr;
9188         LDKPublicKey their_node_id_ref;
9189         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9190         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9191         LDKErrorMessage msg_conv;
9192         msg_conv.inner = (void*)(msg & (~1));
9193         msg_conv.is_owned = false;
9194         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9195         (this_arg_conv->handle_error)(this_arg_conv->this_arg, their_node_id_ref, &msg_conv);
9196 }
9197
9198 typedef struct LDKRoutingMessageHandler_JCalls {
9199         atomic_size_t refcnt;
9200         JavaVM *vm;
9201         jweak o;
9202         LDKMessageSendEventsProvider_JCalls* MessageSendEventsProvider;
9203         jmethodID handle_node_announcement_meth;
9204         jmethodID handle_channel_announcement_meth;
9205         jmethodID handle_channel_update_meth;
9206         jmethodID get_next_channel_announcements_meth;
9207         jmethodID get_next_node_announcements_meth;
9208         jmethodID sync_routing_table_meth;
9209         jmethodID handle_reply_channel_range_meth;
9210         jmethodID handle_reply_short_channel_ids_end_meth;
9211         jmethodID handle_query_channel_range_meth;
9212         jmethodID handle_query_short_channel_ids_meth;
9213 } LDKRoutingMessageHandler_JCalls;
9214 static void LDKRoutingMessageHandler_JCalls_free(void* this_arg) {
9215         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9216         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9217                 JNIEnv *env;
9218                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9219                 if (get_jenv_res == JNI_EDETACHED) {
9220                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9221                 } else {
9222                         DO_ASSERT(get_jenv_res == JNI_OK);
9223                 }
9224                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9225                 if (get_jenv_res == JNI_EDETACHED) {
9226                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9227                 }
9228                 FREE(j_calls);
9229         }
9230 }
9231 LDKCResult_boolLightningErrorZ handle_node_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKNodeAnnouncement * msg) {
9232         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9233         JNIEnv *env;
9234         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9235         if (get_jenv_res == JNI_EDETACHED) {
9236                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9237         } else {
9238                 DO_ASSERT(get_jenv_res == JNI_OK);
9239         }
9240         LDKNodeAnnouncement msg_var = *msg;
9241         uint64_t msg_ref = 0;
9242         msg_var = NodeAnnouncement_clone(msg);
9243         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9244         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9245         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9246         msg_ref = (uint64_t)msg_var.inner;
9247         if (msg_var.is_owned) {
9248                 msg_ref |= 1;
9249         }
9250         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9251         CHECK(obj != NULL);
9252         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_node_announcement_meth, msg_ref);
9253         if ((*env)->ExceptionCheck(env)) {
9254                 (*env)->ExceptionDescribe(env);
9255                 (*env)->FatalError(env, "A call to handle_node_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9256         }
9257         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9258         CHECK_ACCESS(ret_ptr);
9259         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9260         FREE((void*)ret);
9261         if (get_jenv_res == JNI_EDETACHED) {
9262                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9263         }
9264         return ret_conv;
9265 }
9266 LDKCResult_boolLightningErrorZ handle_channel_announcement_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelAnnouncement * msg) {
9267         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9268         JNIEnv *env;
9269         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9270         if (get_jenv_res == JNI_EDETACHED) {
9271                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9272         } else {
9273                 DO_ASSERT(get_jenv_res == JNI_OK);
9274         }
9275         LDKChannelAnnouncement msg_var = *msg;
9276         uint64_t msg_ref = 0;
9277         msg_var = ChannelAnnouncement_clone(msg);
9278         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9279         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9280         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9281         msg_ref = (uint64_t)msg_var.inner;
9282         if (msg_var.is_owned) {
9283                 msg_ref |= 1;
9284         }
9285         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9286         CHECK(obj != NULL);
9287         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_announcement_meth, msg_ref);
9288         if ((*env)->ExceptionCheck(env)) {
9289                 (*env)->ExceptionDescribe(env);
9290                 (*env)->FatalError(env, "A call to handle_channel_announcement in LDKRoutingMessageHandler from rust threw an exception.");
9291         }
9292         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9293         CHECK_ACCESS(ret_ptr);
9294         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9295         FREE((void*)ret);
9296         if (get_jenv_res == JNI_EDETACHED) {
9297                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9298         }
9299         return ret_conv;
9300 }
9301 LDKCResult_boolLightningErrorZ handle_channel_update_LDKRoutingMessageHandler_jcall(const void* this_arg, const LDKChannelUpdate * msg) {
9302         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9303         JNIEnv *env;
9304         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9305         if (get_jenv_res == JNI_EDETACHED) {
9306                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9307         } else {
9308                 DO_ASSERT(get_jenv_res == JNI_OK);
9309         }
9310         LDKChannelUpdate msg_var = *msg;
9311         uint64_t msg_ref = 0;
9312         msg_var = ChannelUpdate_clone(msg);
9313         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9314         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9315         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9316         msg_ref = (uint64_t)msg_var.inner;
9317         if (msg_var.is_owned) {
9318                 msg_ref |= 1;
9319         }
9320         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9321         CHECK(obj != NULL);
9322         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_channel_update_meth, msg_ref);
9323         if ((*env)->ExceptionCheck(env)) {
9324                 (*env)->ExceptionDescribe(env);
9325                 (*env)->FatalError(env, "A call to handle_channel_update in LDKRoutingMessageHandler from rust threw an exception.");
9326         }
9327         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9328         CHECK_ACCESS(ret_ptr);
9329         LDKCResult_boolLightningErrorZ ret_conv = *(LDKCResult_boolLightningErrorZ*)(ret_ptr);
9330         FREE((void*)ret);
9331         if (get_jenv_res == JNI_EDETACHED) {
9332                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9333         }
9334         return ret_conv;
9335 }
9336 LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ get_next_channel_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, uint64_t starting_point, uint8_t batch_amount) {
9337         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9338         JNIEnv *env;
9339         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9340         if (get_jenv_res == JNI_EDETACHED) {
9341                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9342         } else {
9343                 DO_ASSERT(get_jenv_res == JNI_OK);
9344         }
9345         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9346         CHECK(obj != NULL);
9347         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_channel_announcements_meth, starting_point, batch_amount);
9348         if ((*env)->ExceptionCheck(env)) {
9349                 (*env)->ExceptionDescribe(env);
9350                 (*env)->FatalError(env, "A call to get_next_channel_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9351         }
9352         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_constr;
9353         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9354         if (ret_constr.datalen > 0)
9355                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
9356         else
9357                 ret_constr.data = NULL;
9358         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9359         for (size_t h = 0; h < ret_constr.datalen; h++) {
9360                 int64_t ret_conv_59 = ret_vals[h];
9361                 void* ret_conv_59_ptr = (void*)(((uint64_t)ret_conv_59) & ~1);
9362                 CHECK_ACCESS(ret_conv_59_ptr);
9363                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ ret_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(ret_conv_59_ptr);
9364                 FREE((void*)ret_conv_59);
9365                 ret_constr.data[h] = ret_conv_59_conv;
9366         }
9367         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9368         if (get_jenv_res == JNI_EDETACHED) {
9369                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9370         }
9371         return ret_constr;
9372 }
9373 LDKCVec_NodeAnnouncementZ get_next_node_announcements_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey starting_point, uint8_t batch_amount) {
9374         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9375         JNIEnv *env;
9376         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9377         if (get_jenv_res == JNI_EDETACHED) {
9378                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9379         } else {
9380                 DO_ASSERT(get_jenv_res == JNI_OK);
9381         }
9382         int8_tArray starting_point_arr = (*env)->NewByteArray(env, 33);
9383         (*env)->SetByteArrayRegion(env, starting_point_arr, 0, 33, starting_point.compressed_form);
9384         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9385         CHECK(obj != NULL);
9386         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_next_node_announcements_meth, starting_point_arr, batch_amount);
9387         if ((*env)->ExceptionCheck(env)) {
9388                 (*env)->ExceptionDescribe(env);
9389                 (*env)->FatalError(env, "A call to get_next_node_announcements in LDKRoutingMessageHandler from rust threw an exception.");
9390         }
9391         LDKCVec_NodeAnnouncementZ ret_constr;
9392         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9393         if (ret_constr.datalen > 0)
9394                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
9395         else
9396                 ret_constr.data = NULL;
9397         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9398         for (size_t s = 0; s < ret_constr.datalen; s++) {
9399                 int64_t ret_conv_18 = ret_vals[s];
9400                 LDKNodeAnnouncement ret_conv_18_conv;
9401                 ret_conv_18_conv.inner = (void*)(ret_conv_18 & (~1));
9402                 ret_conv_18_conv.is_owned = (ret_conv_18 & 1) || (ret_conv_18 == 0);
9403                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_conv);
9404                 ret_constr.data[s] = ret_conv_18_conv;
9405         }
9406         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9407         if (get_jenv_res == JNI_EDETACHED) {
9408                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9409         }
9410         return ret_constr;
9411 }
9412 void sync_routing_table_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, const LDKInit * init) {
9413         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9414         JNIEnv *env;
9415         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9416         if (get_jenv_res == JNI_EDETACHED) {
9417                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9418         } else {
9419                 DO_ASSERT(get_jenv_res == JNI_OK);
9420         }
9421         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9422         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9423         LDKInit init_var = *init;
9424         uint64_t init_ref = 0;
9425         init_var = Init_clone(init);
9426         CHECK((((uint64_t)init_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9427         CHECK((((uint64_t)&init_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9428         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_var);
9429         init_ref = (uint64_t)init_var.inner;
9430         if (init_var.is_owned) {
9431                 init_ref |= 1;
9432         }
9433         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9434         CHECK(obj != NULL);
9435         (*env)->CallVoidMethod(env, obj, j_calls->sync_routing_table_meth, their_node_id_arr, init_ref);
9436         if ((*env)->ExceptionCheck(env)) {
9437                 (*env)->ExceptionDescribe(env);
9438                 (*env)->FatalError(env, "A call to sync_routing_table in LDKRoutingMessageHandler from rust threw an exception.");
9439         }
9440         if (get_jenv_res == JNI_EDETACHED) {
9441                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9442         }
9443 }
9444 LDKCResult_NoneLightningErrorZ handle_reply_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyChannelRange msg) {
9445         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9446         JNIEnv *env;
9447         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9448         if (get_jenv_res == JNI_EDETACHED) {
9449                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9450         } else {
9451                 DO_ASSERT(get_jenv_res == JNI_OK);
9452         }
9453         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9454         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9455         LDKReplyChannelRange msg_var = msg;
9456         uint64_t msg_ref = 0;
9457         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9458         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9459         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9460         msg_ref = (uint64_t)msg_var.inner;
9461         if (msg_var.is_owned) {
9462                 msg_ref |= 1;
9463         }
9464         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9465         CHECK(obj != NULL);
9466         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_channel_range_meth, their_node_id_arr, msg_ref);
9467         if ((*env)->ExceptionCheck(env)) {
9468                 (*env)->ExceptionDescribe(env);
9469                 (*env)->FatalError(env, "A call to handle_reply_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9470         }
9471         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9472         CHECK_ACCESS(ret_ptr);
9473         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9474         FREE((void*)ret);
9475         if (get_jenv_res == JNI_EDETACHED) {
9476                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9477         }
9478         return ret_conv;
9479 }
9480 LDKCResult_NoneLightningErrorZ handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKReplyShortChannelIdsEnd msg) {
9481         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9482         JNIEnv *env;
9483         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9484         if (get_jenv_res == JNI_EDETACHED) {
9485                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9486         } else {
9487                 DO_ASSERT(get_jenv_res == JNI_OK);
9488         }
9489         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9490         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9491         LDKReplyShortChannelIdsEnd msg_var = msg;
9492         uint64_t msg_ref = 0;
9493         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9494         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9495         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9496         msg_ref = (uint64_t)msg_var.inner;
9497         if (msg_var.is_owned) {
9498                 msg_ref |= 1;
9499         }
9500         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9501         CHECK(obj != NULL);
9502         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_reply_short_channel_ids_end_meth, their_node_id_arr, msg_ref);
9503         if ((*env)->ExceptionCheck(env)) {
9504                 (*env)->ExceptionDescribe(env);
9505                 (*env)->FatalError(env, "A call to handle_reply_short_channel_ids_end in LDKRoutingMessageHandler from rust threw an exception.");
9506         }
9507         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9508         CHECK_ACCESS(ret_ptr);
9509         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9510         FREE((void*)ret);
9511         if (get_jenv_res == JNI_EDETACHED) {
9512                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9513         }
9514         return ret_conv;
9515 }
9516 LDKCResult_NoneLightningErrorZ handle_query_channel_range_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryChannelRange msg) {
9517         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9518         JNIEnv *env;
9519         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9520         if (get_jenv_res == JNI_EDETACHED) {
9521                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9522         } else {
9523                 DO_ASSERT(get_jenv_res == JNI_OK);
9524         }
9525         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9526         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9527         LDKQueryChannelRange msg_var = msg;
9528         uint64_t msg_ref = 0;
9529         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9530         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9531         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9532         msg_ref = (uint64_t)msg_var.inner;
9533         if (msg_var.is_owned) {
9534                 msg_ref |= 1;
9535         }
9536         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9537         CHECK(obj != NULL);
9538         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_channel_range_meth, their_node_id_arr, msg_ref);
9539         if ((*env)->ExceptionCheck(env)) {
9540                 (*env)->ExceptionDescribe(env);
9541                 (*env)->FatalError(env, "A call to handle_query_channel_range in LDKRoutingMessageHandler from rust threw an exception.");
9542         }
9543         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9544         CHECK_ACCESS(ret_ptr);
9545         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9546         FREE((void*)ret);
9547         if (get_jenv_res == JNI_EDETACHED) {
9548                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9549         }
9550         return ret_conv;
9551 }
9552 LDKCResult_NoneLightningErrorZ handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall(const void* this_arg, LDKPublicKey their_node_id, LDKQueryShortChannelIds msg) {
9553         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) this_arg;
9554         JNIEnv *env;
9555         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9556         if (get_jenv_res == JNI_EDETACHED) {
9557                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9558         } else {
9559                 DO_ASSERT(get_jenv_res == JNI_OK);
9560         }
9561         int8_tArray their_node_id_arr = (*env)->NewByteArray(env, 33);
9562         (*env)->SetByteArrayRegion(env, their_node_id_arr, 0, 33, their_node_id.compressed_form);
9563         LDKQueryShortChannelIds msg_var = msg;
9564         uint64_t msg_ref = 0;
9565         CHECK((((uint64_t)msg_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9566         CHECK((((uint64_t)&msg_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9567         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_var);
9568         msg_ref = (uint64_t)msg_var.inner;
9569         if (msg_var.is_owned) {
9570                 msg_ref |= 1;
9571         }
9572         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9573         CHECK(obj != NULL);
9574         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_query_short_channel_ids_meth, their_node_id_arr, msg_ref);
9575         if ((*env)->ExceptionCheck(env)) {
9576                 (*env)->ExceptionDescribe(env);
9577                 (*env)->FatalError(env, "A call to handle_query_short_channel_ids in LDKRoutingMessageHandler from rust threw an exception.");
9578         }
9579         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9580         CHECK_ACCESS(ret_ptr);
9581         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9582         FREE((void*)ret);
9583         if (get_jenv_res == JNI_EDETACHED) {
9584                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9585         }
9586         return ret_conv;
9587 }
9588 static void LDKRoutingMessageHandler_JCalls_cloned(LDKRoutingMessageHandler* new_obj) {
9589         LDKRoutingMessageHandler_JCalls *j_calls = (LDKRoutingMessageHandler_JCalls*) new_obj->this_arg;
9590         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9591         atomic_fetch_add_explicit(&j_calls->MessageSendEventsProvider->refcnt, 1, memory_order_release);
9592 }
9593 static inline LDKRoutingMessageHandler LDKRoutingMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9594         jclass c = (*env)->GetObjectClass(env, o);
9595         CHECK(c != NULL);
9596         LDKRoutingMessageHandler_JCalls *calls = MALLOC(sizeof(LDKRoutingMessageHandler_JCalls), "LDKRoutingMessageHandler_JCalls");
9597         atomic_init(&calls->refcnt, 1);
9598         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9599         calls->o = (*env)->NewWeakGlobalRef(env, o);
9600         calls->handle_node_announcement_meth = (*env)->GetMethodID(env, c, "handle_node_announcement", "(J)J");
9601         CHECK(calls->handle_node_announcement_meth != NULL);
9602         calls->handle_channel_announcement_meth = (*env)->GetMethodID(env, c, "handle_channel_announcement", "(J)J");
9603         CHECK(calls->handle_channel_announcement_meth != NULL);
9604         calls->handle_channel_update_meth = (*env)->GetMethodID(env, c, "handle_channel_update", "(J)J");
9605         CHECK(calls->handle_channel_update_meth != NULL);
9606         calls->get_next_channel_announcements_meth = (*env)->GetMethodID(env, c, "get_next_channel_announcements", "(JB)[J");
9607         CHECK(calls->get_next_channel_announcements_meth != NULL);
9608         calls->get_next_node_announcements_meth = (*env)->GetMethodID(env, c, "get_next_node_announcements", "([BB)[J");
9609         CHECK(calls->get_next_node_announcements_meth != NULL);
9610         calls->sync_routing_table_meth = (*env)->GetMethodID(env, c, "sync_routing_table", "([BJ)V");
9611         CHECK(calls->sync_routing_table_meth != NULL);
9612         calls->handle_reply_channel_range_meth = (*env)->GetMethodID(env, c, "handle_reply_channel_range", "([BJ)J");
9613         CHECK(calls->handle_reply_channel_range_meth != NULL);
9614         calls->handle_reply_short_channel_ids_end_meth = (*env)->GetMethodID(env, c, "handle_reply_short_channel_ids_end", "([BJ)J");
9615         CHECK(calls->handle_reply_short_channel_ids_end_meth != NULL);
9616         calls->handle_query_channel_range_meth = (*env)->GetMethodID(env, c, "handle_query_channel_range", "([BJ)J");
9617         CHECK(calls->handle_query_channel_range_meth != NULL);
9618         calls->handle_query_short_channel_ids_meth = (*env)->GetMethodID(env, c, "handle_query_short_channel_ids", "([BJ)J");
9619         CHECK(calls->handle_query_short_channel_ids_meth != NULL);
9620
9621         LDKRoutingMessageHandler ret = {
9622                 .this_arg = (void*) calls,
9623                 .handle_node_announcement = handle_node_announcement_LDKRoutingMessageHandler_jcall,
9624                 .handle_channel_announcement = handle_channel_announcement_LDKRoutingMessageHandler_jcall,
9625                 .handle_channel_update = handle_channel_update_LDKRoutingMessageHandler_jcall,
9626                 .get_next_channel_announcements = get_next_channel_announcements_LDKRoutingMessageHandler_jcall,
9627                 .get_next_node_announcements = get_next_node_announcements_LDKRoutingMessageHandler_jcall,
9628                 .sync_routing_table = sync_routing_table_LDKRoutingMessageHandler_jcall,
9629                 .handle_reply_channel_range = handle_reply_channel_range_LDKRoutingMessageHandler_jcall,
9630                 .handle_reply_short_channel_ids_end = handle_reply_short_channel_ids_end_LDKRoutingMessageHandler_jcall,
9631                 .handle_query_channel_range = handle_query_channel_range_LDKRoutingMessageHandler_jcall,
9632                 .handle_query_short_channel_ids = handle_query_short_channel_ids_LDKRoutingMessageHandler_jcall,
9633                 .free = LDKRoutingMessageHandler_JCalls_free,
9634                 .MessageSendEventsProvider = LDKMessageSendEventsProvider_init(env, clz, MessageSendEventsProvider),
9635         };
9636         calls->MessageSendEventsProvider = ret.MessageSendEventsProvider.this_arg;
9637         return ret;
9638 }
9639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject MessageSendEventsProvider) {
9640         LDKRoutingMessageHandler *res_ptr = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
9641         *res_ptr = LDKRoutingMessageHandler_init(env, clz, o, MessageSendEventsProvider);
9642         return (uint64_t)res_ptr;
9643 }
9644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRoutingMessageHandler_1get_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t arg) {
9645         LDKRoutingMessageHandler *inp = (LDKRoutingMessageHandler *)(arg & ~1);
9646         uint64_t res_ptr = (uint64_t)&inp->MessageSendEventsProvider;
9647         DO_ASSERT((res_ptr & 1) == 0);
9648         return (int64_t)(res_ptr | 1);
9649 }
9650 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1node_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9651         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9652         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9653         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9654         LDKNodeAnnouncement msg_conv;
9655         msg_conv.inner = (void*)(msg & (~1));
9656         msg_conv.is_owned = false;
9657         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9658         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9659         *ret_conv = (this_arg_conv->handle_node_announcement)(this_arg_conv->this_arg, &msg_conv);
9660         return (uint64_t)ret_conv;
9661 }
9662
9663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1announcement(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9664         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9665         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9666         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9667         LDKChannelAnnouncement msg_conv;
9668         msg_conv.inner = (void*)(msg & (~1));
9669         msg_conv.is_owned = false;
9670         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9671         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9672         *ret_conv = (this_arg_conv->handle_channel_announcement)(this_arg_conv->this_arg, &msg_conv);
9673         return (uint64_t)ret_conv;
9674 }
9675
9676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1handle_1channel_1update(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
9677         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9678         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9679         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9680         LDKChannelUpdate msg_conv;
9681         msg_conv.inner = (void*)(msg & (~1));
9682         msg_conv.is_owned = false;
9683         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9684         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
9685         *ret_conv = (this_arg_conv->handle_channel_update)(this_arg_conv->this_arg, &msg_conv);
9686         return (uint64_t)ret_conv;
9687 }
9688
9689 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) {
9690         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9691         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9692         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9693         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ ret_var = (this_arg_conv->get_next_channel_announcements)(this_arg_conv->this_arg, starting_point, batch_amount);
9694         int64_tArray ret_arr = NULL;
9695         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9696         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9697         for (size_t h = 0; h < ret_var.datalen; h++) {
9698                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv_59_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
9699                 *ret_conv_59_conv = ret_var.data[h];
9700                 ret_arr_ptr[h] = ((uint64_t)ret_conv_59_conv);
9701         }
9702         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9703         FREE(ret_var.data);
9704         return ret_arr;
9705 }
9706
9707 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) {
9708         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9709         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9710         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9711         LDKPublicKey starting_point_ref;
9712         CHECK((*env)->GetArrayLength(env, starting_point) == 33);
9713         (*env)->GetByteArrayRegion(env, starting_point, 0, 33, starting_point_ref.compressed_form);
9714         LDKCVec_NodeAnnouncementZ ret_var = (this_arg_conv->get_next_node_announcements)(this_arg_conv->this_arg, starting_point_ref, batch_amount);
9715         int64_tArray ret_arr = NULL;
9716         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
9717         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
9718         for (size_t s = 0; s < ret_var.datalen; s++) {
9719                 LDKNodeAnnouncement ret_conv_18_var = ret_var.data[s];
9720                 uint64_t ret_conv_18_ref = 0;
9721                 CHECK((((uint64_t)ret_conv_18_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
9722                 CHECK((((uint64_t)&ret_conv_18_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
9723                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_18_var);
9724                 ret_conv_18_ref = (uint64_t)ret_conv_18_var.inner;
9725                 if (ret_conv_18_var.is_owned) {
9726                         ret_conv_18_ref |= 1;
9727                 }
9728                 ret_arr_ptr[s] = ret_conv_18_ref;
9729         }
9730         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
9731         FREE(ret_var.data);
9732         return ret_arr;
9733 }
9734
9735 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) {
9736         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9737         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9738         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9739         LDKPublicKey their_node_id_ref;
9740         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9741         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9742         LDKInit init_conv;
9743         init_conv.inner = (void*)(init & (~1));
9744         init_conv.is_owned = false;
9745         CHECK_INNER_FIELD_ACCESS_OR_NULL(init_conv);
9746         (this_arg_conv->sync_routing_table)(this_arg_conv->this_arg, their_node_id_ref, &init_conv);
9747 }
9748
9749 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) {
9750         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9751         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9752         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9753         LDKPublicKey their_node_id_ref;
9754         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9755         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9756         LDKReplyChannelRange msg_conv;
9757         msg_conv.inner = (void*)(msg & (~1));
9758         msg_conv.is_owned = (msg & 1) || (msg == 0);
9759         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9760         msg_conv = ReplyChannelRange_clone(&msg_conv);
9761         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9762         *ret_conv = (this_arg_conv->handle_reply_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9763         return (uint64_t)ret_conv;
9764 }
9765
9766 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) {
9767         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9768         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9769         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9770         LDKPublicKey their_node_id_ref;
9771         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9772         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9773         LDKReplyShortChannelIdsEnd msg_conv;
9774         msg_conv.inner = (void*)(msg & (~1));
9775         msg_conv.is_owned = (msg & 1) || (msg == 0);
9776         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9777         msg_conv = ReplyShortChannelIdsEnd_clone(&msg_conv);
9778         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9779         *ret_conv = (this_arg_conv->handle_reply_short_channel_ids_end)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9780         return (uint64_t)ret_conv;
9781 }
9782
9783 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) {
9784         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9785         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9786         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9787         LDKPublicKey their_node_id_ref;
9788         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9789         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9790         LDKQueryChannelRange msg_conv;
9791         msg_conv.inner = (void*)(msg & (~1));
9792         msg_conv.is_owned = (msg & 1) || (msg == 0);
9793         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9794         msg_conv = QueryChannelRange_clone(&msg_conv);
9795         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9796         *ret_conv = (this_arg_conv->handle_query_channel_range)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9797         return (uint64_t)ret_conv;
9798 }
9799
9800 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) {
9801         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9802         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9803         LDKRoutingMessageHandler* this_arg_conv = (LDKRoutingMessageHandler*)this_arg_ptr;
9804         LDKPublicKey their_node_id_ref;
9805         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
9806         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
9807         LDKQueryShortChannelIds msg_conv;
9808         msg_conv.inner = (void*)(msg & (~1));
9809         msg_conv.is_owned = (msg & 1) || (msg == 0);
9810         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
9811         msg_conv = QueryShortChannelIds_clone(&msg_conv);
9812         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
9813         *ret_conv = (this_arg_conv->handle_query_short_channel_ids)(this_arg_conv->this_arg, their_node_id_ref, msg_conv);
9814         return (uint64_t)ret_conv;
9815 }
9816
9817 typedef struct LDKCustomMessageReader_JCalls {
9818         atomic_size_t refcnt;
9819         JavaVM *vm;
9820         jweak o;
9821         jmethodID read_meth;
9822 } LDKCustomMessageReader_JCalls;
9823 static void LDKCustomMessageReader_JCalls_free(void* this_arg) {
9824         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9825         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9826                 JNIEnv *env;
9827                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9828                 if (get_jenv_res == JNI_EDETACHED) {
9829                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9830                 } else {
9831                         DO_ASSERT(get_jenv_res == JNI_OK);
9832                 }
9833                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9834                 if (get_jenv_res == JNI_EDETACHED) {
9835                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9836                 }
9837                 FREE(j_calls);
9838         }
9839 }
9840 LDKCResult_COption_TypeZDecodeErrorZ read_LDKCustomMessageReader_jcall(const void* this_arg, uint16_t message_type, LDKu8slice buffer) {
9841         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) this_arg;
9842         JNIEnv *env;
9843         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9844         if (get_jenv_res == JNI_EDETACHED) {
9845                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9846         } else {
9847                 DO_ASSERT(get_jenv_res == JNI_OK);
9848         }
9849         LDKu8slice buffer_var = buffer;
9850         int8_tArray buffer_arr = (*env)->NewByteArray(env, buffer_var.datalen);
9851         (*env)->SetByteArrayRegion(env, buffer_arr, 0, buffer_var.datalen, buffer_var.data);
9852         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9853         CHECK(obj != NULL);
9854         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->read_meth, message_type, buffer_arr);
9855         if ((*env)->ExceptionCheck(env)) {
9856                 (*env)->ExceptionDescribe(env);
9857                 (*env)->FatalError(env, "A call to read in LDKCustomMessageReader from rust threw an exception.");
9858         }
9859         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9860         CHECK_ACCESS(ret_ptr);
9861         LDKCResult_COption_TypeZDecodeErrorZ ret_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(ret_ptr);
9862         FREE((void*)ret);
9863         if (get_jenv_res == JNI_EDETACHED) {
9864                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9865         }
9866         return ret_conv;
9867 }
9868 static void LDKCustomMessageReader_JCalls_cloned(LDKCustomMessageReader* new_obj) {
9869         LDKCustomMessageReader_JCalls *j_calls = (LDKCustomMessageReader_JCalls*) new_obj->this_arg;
9870         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
9871 }
9872 static inline LDKCustomMessageReader LDKCustomMessageReader_init (JNIEnv *env, jclass clz, jobject o) {
9873         jclass c = (*env)->GetObjectClass(env, o);
9874         CHECK(c != NULL);
9875         LDKCustomMessageReader_JCalls *calls = MALLOC(sizeof(LDKCustomMessageReader_JCalls), "LDKCustomMessageReader_JCalls");
9876         atomic_init(&calls->refcnt, 1);
9877         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
9878         calls->o = (*env)->NewWeakGlobalRef(env, o);
9879         calls->read_meth = (*env)->GetMethodID(env, c, "read", "(S[B)J");
9880         CHECK(calls->read_meth != NULL);
9881
9882         LDKCustomMessageReader ret = {
9883                 .this_arg = (void*) calls,
9884                 .read = read_LDKCustomMessageReader_jcall,
9885                 .free = LDKCustomMessageReader_JCalls_free,
9886         };
9887         return ret;
9888 }
9889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageReader_1new(JNIEnv *env, jclass clz, jobject o) {
9890         LDKCustomMessageReader *res_ptr = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
9891         *res_ptr = LDKCustomMessageReader_init(env, clz, o);
9892         return (uint64_t)res_ptr;
9893 }
9894 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) {
9895         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
9896         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
9897         LDKCustomMessageReader* this_arg_conv = (LDKCustomMessageReader*)this_arg_ptr;
9898         LDKu8slice buffer_ref;
9899         buffer_ref.datalen = (*env)->GetArrayLength(env, buffer);
9900         buffer_ref.data = (*env)->GetByteArrayElements (env, buffer, NULL);
9901         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
9902         *ret_conv = (this_arg_conv->read)(this_arg_conv->this_arg, message_type, buffer_ref);
9903         (*env)->ReleaseByteArrayElements(env, buffer, (int8_t*)buffer_ref.data, 0);
9904         return (uint64_t)ret_conv;
9905 }
9906
9907 typedef struct LDKCustomMessageHandler_JCalls {
9908         atomic_size_t refcnt;
9909         JavaVM *vm;
9910         jweak o;
9911         LDKCustomMessageReader_JCalls* CustomMessageReader;
9912         jmethodID handle_custom_message_meth;
9913         jmethodID get_and_clear_pending_msg_meth;
9914 } LDKCustomMessageHandler_JCalls;
9915 static void LDKCustomMessageHandler_JCalls_free(void* this_arg) {
9916         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9917         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
9918                 JNIEnv *env;
9919                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9920                 if (get_jenv_res == JNI_EDETACHED) {
9921                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9922                 } else {
9923                         DO_ASSERT(get_jenv_res == JNI_OK);
9924                 }
9925                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
9926                 if (get_jenv_res == JNI_EDETACHED) {
9927                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9928                 }
9929                 FREE(j_calls);
9930         }
9931 }
9932 LDKCResult_NoneLightningErrorZ handle_custom_message_LDKCustomMessageHandler_jcall(const void* this_arg, LDKType msg, LDKPublicKey sender_node_id) {
9933         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9934         JNIEnv *env;
9935         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9936         if (get_jenv_res == JNI_EDETACHED) {
9937                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9938         } else {
9939                 DO_ASSERT(get_jenv_res == JNI_OK);
9940         }
9941         LDKType* msg_ret = MALLOC(sizeof(LDKType), "LDKType");
9942         *msg_ret = msg;
9943         int8_tArray sender_node_id_arr = (*env)->NewByteArray(env, 33);
9944         (*env)->SetByteArrayRegion(env, sender_node_id_arr, 0, 33, sender_node_id.compressed_form);
9945         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9946         CHECK(obj != NULL);
9947         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->handle_custom_message_meth, (uint64_t)msg_ret, sender_node_id_arr);
9948         if ((*env)->ExceptionCheck(env)) {
9949                 (*env)->ExceptionDescribe(env);
9950                 (*env)->FatalError(env, "A call to handle_custom_message in LDKCustomMessageHandler from rust threw an exception.");
9951         }
9952         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
9953         CHECK_ACCESS(ret_ptr);
9954         LDKCResult_NoneLightningErrorZ ret_conv = *(LDKCResult_NoneLightningErrorZ*)(ret_ptr);
9955         FREE((void*)ret);
9956         if (get_jenv_res == JNI_EDETACHED) {
9957                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9958         }
9959         return ret_conv;
9960 }
9961 LDKCVec_C2Tuple_PublicKeyTypeZZ get_and_clear_pending_msg_LDKCustomMessageHandler_jcall(const void* this_arg) {
9962         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) this_arg;
9963         JNIEnv *env;
9964         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
9965         if (get_jenv_res == JNI_EDETACHED) {
9966                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
9967         } else {
9968                 DO_ASSERT(get_jenv_res == JNI_OK);
9969         }
9970         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
9971         CHECK(obj != NULL);
9972         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->get_and_clear_pending_msg_meth);
9973         if ((*env)->ExceptionCheck(env)) {
9974                 (*env)->ExceptionDescribe(env);
9975                 (*env)->FatalError(env, "A call to get_and_clear_pending_msg in LDKCustomMessageHandler from rust threw an exception.");
9976         }
9977         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_constr;
9978         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
9979         if (ret_constr.datalen > 0)
9980                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
9981         else
9982                 ret_constr.data = NULL;
9983         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
9984         for (size_t z = 0; z < ret_constr.datalen; z++) {
9985                 int64_t ret_conv_25 = ret_vals[z];
9986                 void* ret_conv_25_ptr = (void*)(((uint64_t)ret_conv_25) & ~1);
9987                 CHECK_ACCESS(ret_conv_25_ptr);
9988                 LDKC2Tuple_PublicKeyTypeZ ret_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(ret_conv_25_ptr);
9989                 FREE((void*)ret_conv_25);
9990                 ret_constr.data[z] = ret_conv_25_conv;
9991         }
9992         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
9993         if (get_jenv_res == JNI_EDETACHED) {
9994                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
9995         }
9996         return ret_constr;
9997 }
9998 static void LDKCustomMessageHandler_JCalls_cloned(LDKCustomMessageHandler* new_obj) {
9999         LDKCustomMessageHandler_JCalls *j_calls = (LDKCustomMessageHandler_JCalls*) new_obj->this_arg;
10000         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10001         atomic_fetch_add_explicit(&j_calls->CustomMessageReader->refcnt, 1, memory_order_release);
10002 }
10003 static inline LDKCustomMessageHandler LDKCustomMessageHandler_init (JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10004         jclass c = (*env)->GetObjectClass(env, o);
10005         CHECK(c != NULL);
10006         LDKCustomMessageHandler_JCalls *calls = MALLOC(sizeof(LDKCustomMessageHandler_JCalls), "LDKCustomMessageHandler_JCalls");
10007         atomic_init(&calls->refcnt, 1);
10008         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10009         calls->o = (*env)->NewWeakGlobalRef(env, o);
10010         calls->handle_custom_message_meth = (*env)->GetMethodID(env, c, "handle_custom_message", "(J[B)J");
10011         CHECK(calls->handle_custom_message_meth != NULL);
10012         calls->get_and_clear_pending_msg_meth = (*env)->GetMethodID(env, c, "get_and_clear_pending_msg", "()[J");
10013         CHECK(calls->get_and_clear_pending_msg_meth != NULL);
10014
10015         LDKCustomMessageHandler ret = {
10016                 .this_arg = (void*) calls,
10017                 .handle_custom_message = handle_custom_message_LDKCustomMessageHandler_jcall,
10018                 .get_and_clear_pending_msg = get_and_clear_pending_msg_LDKCustomMessageHandler_jcall,
10019                 .free = LDKCustomMessageHandler_JCalls_free,
10020                 .CustomMessageReader = LDKCustomMessageReader_init(env, clz, CustomMessageReader),
10021         };
10022         calls->CustomMessageReader = ret.CustomMessageReader.this_arg;
10023         return ret;
10024 }
10025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1new(JNIEnv *env, jclass clz, jobject o, jobject CustomMessageReader) {
10026         LDKCustomMessageHandler *res_ptr = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
10027         *res_ptr = LDKCustomMessageHandler_init(env, clz, o, CustomMessageReader);
10028         return (uint64_t)res_ptr;
10029 }
10030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKCustomMessageHandler_1get_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t arg) {
10031         LDKCustomMessageHandler *inp = (LDKCustomMessageHandler *)(arg & ~1);
10032         uint64_t res_ptr = (uint64_t)&inp->CustomMessageReader;
10033         DO_ASSERT((res_ptr & 1) == 0);
10034         return (int64_t)(res_ptr | 1);
10035 }
10036 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) {
10037         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10038         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10039         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10040         void* msg_ptr = (void*)(((uint64_t)msg) & ~1);
10041         CHECK_ACCESS(msg_ptr);
10042         LDKType msg_conv = *(LDKType*)(msg_ptr);
10043         if (msg_conv.free == LDKType_JCalls_free) {
10044                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
10045                 LDKType_JCalls_cloned(&msg_conv);
10046         }
10047         LDKPublicKey sender_node_id_ref;
10048         CHECK((*env)->GetArrayLength(env, sender_node_id) == 33);
10049         (*env)->GetByteArrayRegion(env, sender_node_id, 0, 33, sender_node_id_ref.compressed_form);
10050         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
10051         *ret_conv = (this_arg_conv->handle_custom_message)(this_arg_conv->this_arg, msg_conv, sender_node_id_ref);
10052         return (uint64_t)ret_conv;
10053 }
10054
10055 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1get_1and_1clear_1pending_1msg(JNIEnv *env, jclass clz, int64_t this_arg) {
10056         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10057         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10058         LDKCustomMessageHandler* this_arg_conv = (LDKCustomMessageHandler*)this_arg_ptr;
10059         LDKCVec_C2Tuple_PublicKeyTypeZZ ret_var = (this_arg_conv->get_and_clear_pending_msg)(this_arg_conv->this_arg);
10060         int64_tArray ret_arr = NULL;
10061         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10062         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10063         for (size_t z = 0; z < ret_var.datalen; z++) {
10064                 LDKC2Tuple_PublicKeyTypeZ* ret_conv_25_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
10065                 *ret_conv_25_conv = ret_var.data[z];
10066                 ret_arr_ptr[z] = ((uint64_t)ret_conv_25_conv);
10067         }
10068         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10069         FREE(ret_var.data);
10070         return ret_arr;
10071 }
10072
10073 typedef struct LDKSocketDescriptor_JCalls {
10074         atomic_size_t refcnt;
10075         JavaVM *vm;
10076         jweak o;
10077         jmethodID send_data_meth;
10078         jmethodID disconnect_socket_meth;
10079         jmethodID eq_meth;
10080         jmethodID hash_meth;
10081 } LDKSocketDescriptor_JCalls;
10082 static void LDKSocketDescriptor_JCalls_free(void* this_arg) {
10083         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10084         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10085                 JNIEnv *env;
10086                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10087                 if (get_jenv_res == JNI_EDETACHED) {
10088                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10089                 } else {
10090                         DO_ASSERT(get_jenv_res == JNI_OK);
10091                 }
10092                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10093                 if (get_jenv_res == JNI_EDETACHED) {
10094                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10095                 }
10096                 FREE(j_calls);
10097         }
10098 }
10099 uintptr_t send_data_LDKSocketDescriptor_jcall(void* this_arg, LDKu8slice data, bool resume_read) {
10100         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10101         JNIEnv *env;
10102         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10103         if (get_jenv_res == JNI_EDETACHED) {
10104                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10105         } else {
10106                 DO_ASSERT(get_jenv_res == JNI_OK);
10107         }
10108         LDKu8slice data_var = data;
10109         int8_tArray data_arr = (*env)->NewByteArray(env, data_var.datalen);
10110         (*env)->SetByteArrayRegion(env, data_arr, 0, data_var.datalen, data_var.data);
10111         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10112         CHECK(obj != NULL);
10113         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_data_meth, data_arr, resume_read);
10114         if ((*env)->ExceptionCheck(env)) {
10115                 (*env)->ExceptionDescribe(env);
10116                 (*env)->FatalError(env, "A call to send_data in LDKSocketDescriptor from rust threw an exception.");
10117         }
10118         if (get_jenv_res == JNI_EDETACHED) {
10119                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10120         }
10121         return ret;
10122 }
10123 void disconnect_socket_LDKSocketDescriptor_jcall(void* this_arg) {
10124         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10125         JNIEnv *env;
10126         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10127         if (get_jenv_res == JNI_EDETACHED) {
10128                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10129         } else {
10130                 DO_ASSERT(get_jenv_res == JNI_OK);
10131         }
10132         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10133         CHECK(obj != NULL);
10134         (*env)->CallVoidMethod(env, obj, j_calls->disconnect_socket_meth);
10135         if ((*env)->ExceptionCheck(env)) {
10136                 (*env)->ExceptionDescribe(env);
10137                 (*env)->FatalError(env, "A call to disconnect_socket in LDKSocketDescriptor from rust threw an exception.");
10138         }
10139         if (get_jenv_res == JNI_EDETACHED) {
10140                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10141         }
10142 }
10143 bool eq_LDKSocketDescriptor_jcall(const void* this_arg, const LDKSocketDescriptor * other_arg) {
10144         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10145         JNIEnv *env;
10146         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10147         if (get_jenv_res == JNI_EDETACHED) {
10148                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10149         } else {
10150                 DO_ASSERT(get_jenv_res == JNI_OK);
10151         }
10152         LDKSocketDescriptor *other_arg_clone = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10153         *other_arg_clone = SocketDescriptor_clone(other_arg);
10154         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10155         CHECK(obj != NULL);
10156         jboolean ret = (*env)->CallBooleanMethod(env, obj, j_calls->eq_meth, (uint64_t)other_arg_clone);
10157         if ((*env)->ExceptionCheck(env)) {
10158                 (*env)->ExceptionDescribe(env);
10159                 (*env)->FatalError(env, "A call to eq in LDKSocketDescriptor from rust threw an exception.");
10160         }
10161         if (get_jenv_res == JNI_EDETACHED) {
10162                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10163         }
10164         return ret;
10165 }
10166 uint64_t hash_LDKSocketDescriptor_jcall(const void* this_arg) {
10167         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) this_arg;
10168         JNIEnv *env;
10169         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10170         if (get_jenv_res == JNI_EDETACHED) {
10171                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10172         } else {
10173                 DO_ASSERT(get_jenv_res == JNI_OK);
10174         }
10175         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10176         CHECK(obj != NULL);
10177         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->hash_meth);
10178         if ((*env)->ExceptionCheck(env)) {
10179                 (*env)->ExceptionDescribe(env);
10180                 (*env)->FatalError(env, "A call to hash in LDKSocketDescriptor from rust threw an exception.");
10181         }
10182         if (get_jenv_res == JNI_EDETACHED) {
10183                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10184         }
10185         return ret;
10186 }
10187 static void LDKSocketDescriptor_JCalls_cloned(LDKSocketDescriptor* new_obj) {
10188         LDKSocketDescriptor_JCalls *j_calls = (LDKSocketDescriptor_JCalls*) new_obj->this_arg;
10189         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10190 }
10191 static inline LDKSocketDescriptor LDKSocketDescriptor_init (JNIEnv *env, jclass clz, jobject o) {
10192         jclass c = (*env)->GetObjectClass(env, o);
10193         CHECK(c != NULL);
10194         LDKSocketDescriptor_JCalls *calls = MALLOC(sizeof(LDKSocketDescriptor_JCalls), "LDKSocketDescriptor_JCalls");
10195         atomic_init(&calls->refcnt, 1);
10196         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10197         calls->o = (*env)->NewWeakGlobalRef(env, o);
10198         calls->send_data_meth = (*env)->GetMethodID(env, c, "send_data", "([BZ)J");
10199         CHECK(calls->send_data_meth != NULL);
10200         calls->disconnect_socket_meth = (*env)->GetMethodID(env, c, "disconnect_socket", "()V");
10201         CHECK(calls->disconnect_socket_meth != NULL);
10202         calls->eq_meth = (*env)->GetMethodID(env, c, "eq", "(J)Z");
10203         CHECK(calls->eq_meth != NULL);
10204         calls->hash_meth = (*env)->GetMethodID(env, c, "hash", "()J");
10205         CHECK(calls->hash_meth != NULL);
10206
10207         LDKSocketDescriptor ret = {
10208                 .this_arg = (void*) calls,
10209                 .send_data = send_data_LDKSocketDescriptor_jcall,
10210                 .disconnect_socket = disconnect_socket_LDKSocketDescriptor_jcall,
10211                 .eq = eq_LDKSocketDescriptor_jcall,
10212                 .hash = hash_LDKSocketDescriptor_jcall,
10213                 .cloned = LDKSocketDescriptor_JCalls_cloned,
10214                 .free = LDKSocketDescriptor_JCalls_free,
10215         };
10216         return ret;
10217 }
10218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKSocketDescriptor_1new(JNIEnv *env, jclass clz, jobject o) {
10219         LDKSocketDescriptor *res_ptr = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
10220         *res_ptr = LDKSocketDescriptor_init(env, clz, o);
10221         return (uint64_t)res_ptr;
10222 }
10223 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) {
10224         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10225         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10226         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10227         LDKu8slice data_ref;
10228         data_ref.datalen = (*env)->GetArrayLength(env, data);
10229         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
10230         int64_t ret_val = (this_arg_conv->send_data)(this_arg_conv->this_arg, data_ref, resume_read);
10231         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
10232         return ret_val;
10233 }
10234
10235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1disconnect_1socket(JNIEnv *env, jclass clz, int64_t this_arg) {
10236         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10237         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10238         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10239         (this_arg_conv->disconnect_socket)(this_arg_conv->this_arg);
10240 }
10241
10242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
10243         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10244         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10245         LDKSocketDescriptor* this_arg_conv = (LDKSocketDescriptor*)this_arg_ptr;
10246         int64_t ret_val = (this_arg_conv->hash)(this_arg_conv->this_arg);
10247         return ret_val;
10248 }
10249
10250 typedef struct LDKScore_JCalls {
10251         atomic_size_t refcnt;
10252         JavaVM *vm;
10253         jweak o;
10254         jmethodID channel_penalty_msat_meth;
10255         jmethodID payment_path_failed_meth;
10256         jmethodID write_meth;
10257 } LDKScore_JCalls;
10258 static void LDKScore_JCalls_free(void* this_arg) {
10259         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10260         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10261                 JNIEnv *env;
10262                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10263                 if (get_jenv_res == JNI_EDETACHED) {
10264                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10265                 } else {
10266                         DO_ASSERT(get_jenv_res == JNI_OK);
10267                 }
10268                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10269                 if (get_jenv_res == JNI_EDETACHED) {
10270                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10271                 }
10272                 FREE(j_calls);
10273         }
10274 }
10275 uint64_t channel_penalty_msat_LDKScore_jcall(const void* this_arg, uint64_t short_channel_id, const LDKNodeId * source, const LDKNodeId * target) {
10276         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10277         JNIEnv *env;
10278         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10279         if (get_jenv_res == JNI_EDETACHED) {
10280                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10281         } else {
10282                 DO_ASSERT(get_jenv_res == JNI_OK);
10283         }
10284         LDKNodeId source_var = *source;
10285         uint64_t source_ref = 0;
10286         source_var = NodeId_clone(source);
10287         CHECK((((uint64_t)source_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10288         CHECK((((uint64_t)&source_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10289         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_var);
10290         source_ref = (uint64_t)source_var.inner;
10291         if (source_var.is_owned) {
10292                 source_ref |= 1;
10293         }
10294         LDKNodeId target_var = *target;
10295         uint64_t target_ref = 0;
10296         target_var = NodeId_clone(target);
10297         CHECK((((uint64_t)target_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10298         CHECK((((uint64_t)&target_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10299         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_var);
10300         target_ref = (uint64_t)target_var.inner;
10301         if (target_var.is_owned) {
10302                 target_ref |= 1;
10303         }
10304         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10305         CHECK(obj != NULL);
10306         int64_t ret = (*env)->CallLongMethod(env, obj, j_calls->channel_penalty_msat_meth, short_channel_id, source_ref, target_ref);
10307         if ((*env)->ExceptionCheck(env)) {
10308                 (*env)->ExceptionDescribe(env);
10309                 (*env)->FatalError(env, "A call to channel_penalty_msat in LDKScore from rust threw an exception.");
10310         }
10311         if (get_jenv_res == JNI_EDETACHED) {
10312                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10313         }
10314         return ret;
10315 }
10316 void payment_path_failed_LDKScore_jcall(void* this_arg, LDKCVec_RouteHopZ path, uint64_t short_channel_id) {
10317         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10318         JNIEnv *env;
10319         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10320         if (get_jenv_res == JNI_EDETACHED) {
10321                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10322         } else {
10323                 DO_ASSERT(get_jenv_res == JNI_OK);
10324         }
10325         LDKCVec_RouteHopZ path_var = path;
10326         int64_tArray path_arr = NULL;
10327         path_arr = (*env)->NewLongArray(env, path_var.datalen);
10328         int64_t *path_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, path_arr, NULL);
10329         for (size_t k = 0; k < path_var.datalen; k++) {
10330                 LDKRouteHop path_conv_10_var = path_var.data[k];
10331                 uint64_t path_conv_10_ref = 0;
10332                 CHECK((((uint64_t)path_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10333                 CHECK((((uint64_t)&path_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10334                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_var);
10335                 path_conv_10_ref = (uint64_t)path_conv_10_var.inner;
10336                 if (path_conv_10_var.is_owned) {
10337                         path_conv_10_ref |= 1;
10338                 }
10339                 path_arr_ptr[k] = path_conv_10_ref;
10340         }
10341         (*env)->ReleasePrimitiveArrayCritical(env, path_arr, path_arr_ptr, 0);
10342         FREE(path_var.data);
10343         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10344         CHECK(obj != NULL);
10345         (*env)->CallVoidMethod(env, obj, j_calls->payment_path_failed_meth, path_arr, short_channel_id);
10346         if ((*env)->ExceptionCheck(env)) {
10347                 (*env)->ExceptionDescribe(env);
10348                 (*env)->FatalError(env, "A call to payment_path_failed in LDKScore from rust threw an exception.");
10349         }
10350         if (get_jenv_res == JNI_EDETACHED) {
10351                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10352         }
10353 }
10354 LDKCVec_u8Z write_LDKScore_jcall(const void* this_arg) {
10355         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) this_arg;
10356         JNIEnv *env;
10357         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10358         if (get_jenv_res == JNI_EDETACHED) {
10359                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10360         } else {
10361                 DO_ASSERT(get_jenv_res == JNI_OK);
10362         }
10363         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10364         CHECK(obj != NULL);
10365         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->write_meth);
10366         if ((*env)->ExceptionCheck(env)) {
10367                 (*env)->ExceptionDescribe(env);
10368                 (*env)->FatalError(env, "A call to write in LDKScore from rust threw an exception.");
10369         }
10370         LDKCVec_u8Z ret_ref;
10371         ret_ref.datalen = (*env)->GetArrayLength(env, ret);
10372         ret_ref.data = MALLOC(ret_ref.datalen, "LDKCVec_u8Z Bytes");
10373         (*env)->GetByteArrayRegion(env, ret, 0, ret_ref.datalen, ret_ref.data);
10374         if (get_jenv_res == JNI_EDETACHED) {
10375                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10376         }
10377         return ret_ref;
10378 }
10379 static void LDKScore_JCalls_cloned(LDKScore* new_obj) {
10380         LDKScore_JCalls *j_calls = (LDKScore_JCalls*) new_obj->this_arg;
10381         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10382 }
10383 static inline LDKScore LDKScore_init (JNIEnv *env, jclass clz, jobject o) {
10384         jclass c = (*env)->GetObjectClass(env, o);
10385         CHECK(c != NULL);
10386         LDKScore_JCalls *calls = MALLOC(sizeof(LDKScore_JCalls), "LDKScore_JCalls");
10387         atomic_init(&calls->refcnt, 1);
10388         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10389         calls->o = (*env)->NewWeakGlobalRef(env, o);
10390         calls->channel_penalty_msat_meth = (*env)->GetMethodID(env, c, "channel_penalty_msat", "(JJJ)J");
10391         CHECK(calls->channel_penalty_msat_meth != NULL);
10392         calls->payment_path_failed_meth = (*env)->GetMethodID(env, c, "payment_path_failed", "([JJ)V");
10393         CHECK(calls->payment_path_failed_meth != NULL);
10394         calls->write_meth = (*env)->GetMethodID(env, c, "write", "()[B");
10395         CHECK(calls->write_meth != NULL);
10396
10397         LDKScore ret = {
10398                 .this_arg = (void*) calls,
10399                 .channel_penalty_msat = channel_penalty_msat_LDKScore_jcall,
10400                 .payment_path_failed = payment_path_failed_LDKScore_jcall,
10401                 .write = write_LDKScore_jcall,
10402                 .free = LDKScore_JCalls_free,
10403         };
10404         return ret;
10405 }
10406 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKScore_1new(JNIEnv *env, jclass clz, jobject o) {
10407         LDKScore *res_ptr = MALLOC(sizeof(LDKScore), "LDKScore");
10408         *res_ptr = LDKScore_init(env, clz, o);
10409         return (uint64_t)res_ptr;
10410 }
10411 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) {
10412         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10413         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10414         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10415         LDKNodeId source_conv;
10416         source_conv.inner = (void*)(source & (~1));
10417         source_conv.is_owned = false;
10418         CHECK_INNER_FIELD_ACCESS_OR_NULL(source_conv);
10419         LDKNodeId target_conv;
10420         target_conv.inner = (void*)(target & (~1));
10421         target_conv.is_owned = false;
10422         CHECK_INNER_FIELD_ACCESS_OR_NULL(target_conv);
10423         int64_t ret_val = (this_arg_conv->channel_penalty_msat)(this_arg_conv->this_arg, short_channel_id, &source_conv, &target_conv);
10424         return ret_val;
10425 }
10426
10427 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) {
10428         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10429         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10430         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10431         LDKCVec_RouteHopZ path_constr;
10432         path_constr.datalen = (*env)->GetArrayLength(env, path);
10433         if (path_constr.datalen > 0)
10434                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
10435         else
10436                 path_constr.data = NULL;
10437         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
10438         for (size_t k = 0; k < path_constr.datalen; k++) {
10439                 int64_t path_conv_10 = path_vals[k];
10440                 LDKRouteHop path_conv_10_conv;
10441                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
10442                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
10443                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
10444                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
10445                 path_constr.data[k] = path_conv_10_conv;
10446         }
10447         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
10448         (this_arg_conv->payment_path_failed)(this_arg_conv->this_arg, path_constr, short_channel_id);
10449 }
10450
10451 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Score_1write(JNIEnv *env, jclass clz, int64_t this_arg) {
10452         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10453         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10454         LDKScore* this_arg_conv = (LDKScore*)this_arg_ptr;
10455         LDKCVec_u8Z ret_var = (this_arg_conv->write)(this_arg_conv->this_arg);
10456         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
10457         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
10458         CVec_u8Z_free(ret_var);
10459         return ret_arr;
10460 }
10461
10462 typedef struct LDKChannelManagerPersister_JCalls {
10463         atomic_size_t refcnt;
10464         JavaVM *vm;
10465         jweak o;
10466         jmethodID persist_manager_meth;
10467 } LDKChannelManagerPersister_JCalls;
10468 static void LDKChannelManagerPersister_JCalls_free(void* this_arg) {
10469         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10470         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10471                 JNIEnv *env;
10472                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10473                 if (get_jenv_res == JNI_EDETACHED) {
10474                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10475                 } else {
10476                         DO_ASSERT(get_jenv_res == JNI_OK);
10477                 }
10478                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10479                 if (get_jenv_res == JNI_EDETACHED) {
10480                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10481                 }
10482                 FREE(j_calls);
10483         }
10484 }
10485 LDKCResult_NoneErrorZ persist_manager_LDKChannelManagerPersister_jcall(const void* this_arg, const LDKChannelManager * channel_manager) {
10486         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) this_arg;
10487         JNIEnv *env;
10488         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10489         if (get_jenv_res == JNI_EDETACHED) {
10490                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10491         } else {
10492                 DO_ASSERT(get_jenv_res == JNI_OK);
10493         }
10494         LDKChannelManager channel_manager_var = *channel_manager;
10495         uint64_t channel_manager_ref = 0;
10496         // Warning: we may need a move here but no clone is available for LDKChannelManager
10497         CHECK((((uint64_t)channel_manager_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10498         CHECK((((uint64_t)&channel_manager_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10499         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_var);
10500         channel_manager_ref = (uint64_t)channel_manager_var.inner;
10501         if (channel_manager_var.is_owned) {
10502                 channel_manager_ref |= 1;
10503         }
10504         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10505         CHECK(obj != NULL);
10506         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->persist_manager_meth, channel_manager_ref);
10507         if ((*env)->ExceptionCheck(env)) {
10508                 (*env)->ExceptionDescribe(env);
10509                 (*env)->FatalError(env, "A call to persist_manager in LDKChannelManagerPersister from rust threw an exception.");
10510         }
10511         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10512         CHECK_ACCESS(ret_ptr);
10513         LDKCResult_NoneErrorZ ret_conv = *(LDKCResult_NoneErrorZ*)(ret_ptr);
10514         FREE((void*)ret);
10515         if (get_jenv_res == JNI_EDETACHED) {
10516                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10517         }
10518         return ret_conv;
10519 }
10520 static void LDKChannelManagerPersister_JCalls_cloned(LDKChannelManagerPersister* new_obj) {
10521         LDKChannelManagerPersister_JCalls *j_calls = (LDKChannelManagerPersister_JCalls*) new_obj->this_arg;
10522         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10523 }
10524 static inline LDKChannelManagerPersister LDKChannelManagerPersister_init (JNIEnv *env, jclass clz, jobject o) {
10525         jclass c = (*env)->GetObjectClass(env, o);
10526         CHECK(c != NULL);
10527         LDKChannelManagerPersister_JCalls *calls = MALLOC(sizeof(LDKChannelManagerPersister_JCalls), "LDKChannelManagerPersister_JCalls");
10528         atomic_init(&calls->refcnt, 1);
10529         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10530         calls->o = (*env)->NewWeakGlobalRef(env, o);
10531         calls->persist_manager_meth = (*env)->GetMethodID(env, c, "persist_manager", "(J)J");
10532         CHECK(calls->persist_manager_meth != NULL);
10533
10534         LDKChannelManagerPersister ret = {
10535                 .this_arg = (void*) calls,
10536                 .persist_manager = persist_manager_LDKChannelManagerPersister_jcall,
10537                 .free = LDKChannelManagerPersister_JCalls_free,
10538         };
10539         return ret;
10540 }
10541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKChannelManagerPersister_1new(JNIEnv *env, jclass clz, jobject o) {
10542         LDKChannelManagerPersister *res_ptr = MALLOC(sizeof(LDKChannelManagerPersister), "LDKChannelManagerPersister");
10543         *res_ptr = LDKChannelManagerPersister_init(env, clz, o);
10544         return (uint64_t)res_ptr;
10545 }
10546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1persist_1manager(JNIEnv *env, jclass clz, int64_t this_arg, int64_t channel_manager) {
10547         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10548         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10549         LDKChannelManagerPersister* this_arg_conv = (LDKChannelManagerPersister*)this_arg_ptr;
10550         LDKChannelManager channel_manager_conv;
10551         channel_manager_conv.inner = (void*)(channel_manager & (~1));
10552         channel_manager_conv.is_owned = false;
10553         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
10554         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
10555         *ret_conv = (this_arg_conv->persist_manager)(this_arg_conv->this_arg, &channel_manager_conv);
10556         return (uint64_t)ret_conv;
10557 }
10558
10559 static jclass LDKFallback_SegWitProgram_class = NULL;
10560 static jmethodID LDKFallback_SegWitProgram_meth = NULL;
10561 static jclass LDKFallback_PubKeyHash_class = NULL;
10562 static jmethodID LDKFallback_PubKeyHash_meth = NULL;
10563 static jclass LDKFallback_ScriptHash_class = NULL;
10564 static jmethodID LDKFallback_ScriptHash_meth = NULL;
10565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_00024LDKFallback_init (JNIEnv *env, jclass clz) {
10566         LDKFallback_SegWitProgram_class =
10567                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$SegWitProgram;"));
10568         CHECK(LDKFallback_SegWitProgram_class != NULL);
10569         LDKFallback_SegWitProgram_meth = (*env)->GetMethodID(env, LDKFallback_SegWitProgram_class, "<init>", "(B[B)V");
10570         CHECK(LDKFallback_SegWitProgram_meth != NULL);
10571         LDKFallback_PubKeyHash_class =
10572                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$PubKeyHash;"));
10573         CHECK(LDKFallback_PubKeyHash_class != NULL);
10574         LDKFallback_PubKeyHash_meth = (*env)->GetMethodID(env, LDKFallback_PubKeyHash_class, "<init>", "([B)V");
10575         CHECK(LDKFallback_PubKeyHash_meth != NULL);
10576         LDKFallback_ScriptHash_class =
10577                 (*env)->NewGlobalRef(env, (*env)->FindClass(env, "Lorg/ldk/impl/bindings$LDKFallback$ScriptHash;"));
10578         CHECK(LDKFallback_ScriptHash_class != NULL);
10579         LDKFallback_ScriptHash_meth = (*env)->GetMethodID(env, LDKFallback_ScriptHash_class, "<init>", "([B)V");
10580         CHECK(LDKFallback_ScriptHash_meth != NULL);
10581 }
10582 JNIEXPORT jobject JNICALL Java_org_ldk_impl_bindings_LDKFallback_1ref_1from_1ptr(JNIEnv *env, jclass clz, int64_t ptr) {
10583         LDKFallback *obj = (LDKFallback*)(ptr & ~1);
10584         switch(obj->tag) {
10585                 case LDKFallback_SegWitProgram: {
10586                         uint8_t version_val = obj->seg_wit_program.version._0;
10587                         LDKCVec_u8Z program_var = obj->seg_wit_program.program;
10588                         int8_tArray program_arr = (*env)->NewByteArray(env, program_var.datalen);
10589                         (*env)->SetByteArrayRegion(env, program_arr, 0, program_var.datalen, program_var.data);
10590                         return (*env)->NewObject(env, LDKFallback_SegWitProgram_class, LDKFallback_SegWitProgram_meth, version_val, program_arr);
10591                 }
10592                 case LDKFallback_PubKeyHash: {
10593                         int8_tArray pub_key_hash_arr = (*env)->NewByteArray(env, 20);
10594                         (*env)->SetByteArrayRegion(env, pub_key_hash_arr, 0, 20, obj->pub_key_hash.data);
10595                         return (*env)->NewObject(env, LDKFallback_PubKeyHash_class, LDKFallback_PubKeyHash_meth, pub_key_hash_arr);
10596                 }
10597                 case LDKFallback_ScriptHash: {
10598                         int8_tArray script_hash_arr = (*env)->NewByteArray(env, 20);
10599                         (*env)->SetByteArrayRegion(env, script_hash_arr, 0, 20, obj->script_hash.data);
10600                         return (*env)->NewObject(env, LDKFallback_ScriptHash_class, LDKFallback_ScriptHash_meth, script_hash_arr);
10601                 }
10602                 default: abort();
10603         }
10604 }
10605 typedef struct LDKPayer_JCalls {
10606         atomic_size_t refcnt;
10607         JavaVM *vm;
10608         jweak o;
10609         jmethodID node_id_meth;
10610         jmethodID first_hops_meth;
10611         jmethodID send_payment_meth;
10612         jmethodID retry_payment_meth;
10613 } LDKPayer_JCalls;
10614 static void LDKPayer_JCalls_free(void* this_arg) {
10615         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10616         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10617                 JNIEnv *env;
10618                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10619                 if (get_jenv_res == JNI_EDETACHED) {
10620                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10621                 } else {
10622                         DO_ASSERT(get_jenv_res == JNI_OK);
10623                 }
10624                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10625                 if (get_jenv_res == JNI_EDETACHED) {
10626                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10627                 }
10628                 FREE(j_calls);
10629         }
10630 }
10631 LDKPublicKey node_id_LDKPayer_jcall(const void* this_arg) {
10632         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10633         JNIEnv *env;
10634         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10635         if (get_jenv_res == JNI_EDETACHED) {
10636                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10637         } else {
10638                 DO_ASSERT(get_jenv_res == JNI_OK);
10639         }
10640         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10641         CHECK(obj != NULL);
10642         int8_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->node_id_meth);
10643         if ((*env)->ExceptionCheck(env)) {
10644                 (*env)->ExceptionDescribe(env);
10645                 (*env)->FatalError(env, "A call to node_id in LDKPayer from rust threw an exception.");
10646         }
10647         LDKPublicKey ret_ref;
10648         CHECK((*env)->GetArrayLength(env, ret) == 33);
10649         (*env)->GetByteArrayRegion(env, ret, 0, 33, ret_ref.compressed_form);
10650         if (get_jenv_res == JNI_EDETACHED) {
10651                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10652         }
10653         return ret_ref;
10654 }
10655 LDKCVec_ChannelDetailsZ first_hops_LDKPayer_jcall(const void* this_arg) {
10656         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10657         JNIEnv *env;
10658         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10659         if (get_jenv_res == JNI_EDETACHED) {
10660                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10661         } else {
10662                 DO_ASSERT(get_jenv_res == JNI_OK);
10663         }
10664         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10665         CHECK(obj != NULL);
10666         int64_tArray ret = (*env)->CallObjectMethod(env, obj, j_calls->first_hops_meth);
10667         if ((*env)->ExceptionCheck(env)) {
10668                 (*env)->ExceptionDescribe(env);
10669                 (*env)->FatalError(env, "A call to first_hops in LDKPayer from rust threw an exception.");
10670         }
10671         LDKCVec_ChannelDetailsZ ret_constr;
10672         ret_constr.datalen = (*env)->GetArrayLength(env, ret);
10673         if (ret_constr.datalen > 0)
10674                 ret_constr.data = MALLOC(ret_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10675         else
10676                 ret_constr.data = NULL;
10677         int64_t* ret_vals = (*env)->GetLongArrayElements (env, ret, NULL);
10678         for (size_t q = 0; q < ret_constr.datalen; q++) {
10679                 int64_t ret_conv_16 = ret_vals[q];
10680                 LDKChannelDetails ret_conv_16_conv;
10681                 ret_conv_16_conv.inner = (void*)(ret_conv_16 & (~1));
10682                 ret_conv_16_conv.is_owned = (ret_conv_16 & 1) || (ret_conv_16 == 0);
10683                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_conv);
10684                 ret_constr.data[q] = ret_conv_16_conv;
10685         }
10686         (*env)->ReleaseLongArrayElements(env, ret, ret_vals, 0);
10687         if (get_jenv_res == JNI_EDETACHED) {
10688                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10689         }
10690         return ret_constr;
10691 }
10692 LDKCResult_PaymentIdPaymentSendFailureZ send_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_hash, LDKThirtyTwoBytes payment_secret) {
10693         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10694         JNIEnv *env;
10695         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10696         if (get_jenv_res == JNI_EDETACHED) {
10697                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10698         } else {
10699                 DO_ASSERT(get_jenv_res == JNI_OK);
10700         }
10701         LDKRoute route_var = *route;
10702         uint64_t route_ref = 0;
10703         route_var = Route_clone(route);
10704         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10705         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10706         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10707         route_ref = (uint64_t)route_var.inner;
10708         if (route_var.is_owned) {
10709                 route_ref |= 1;
10710         }
10711         int8_tArray payment_hash_arr = (*env)->NewByteArray(env, 32);
10712         (*env)->SetByteArrayRegion(env, payment_hash_arr, 0, 32, payment_hash.data);
10713         int8_tArray payment_secret_arr = (*env)->NewByteArray(env, 32);
10714         (*env)->SetByteArrayRegion(env, payment_secret_arr, 0, 32, payment_secret.data);
10715         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10716         CHECK(obj != NULL);
10717         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->send_payment_meth, route_ref, payment_hash_arr, payment_secret_arr);
10718         if ((*env)->ExceptionCheck(env)) {
10719                 (*env)->ExceptionDescribe(env);
10720                 (*env)->FatalError(env, "A call to send_payment in LDKPayer from rust threw an exception.");
10721         }
10722         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10723         CHECK_ACCESS(ret_ptr);
10724         LDKCResult_PaymentIdPaymentSendFailureZ ret_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(ret_ptr);
10725         FREE((void*)ret);
10726         if (get_jenv_res == JNI_EDETACHED) {
10727                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10728         }
10729         return ret_conv;
10730 }
10731 LDKCResult_NonePaymentSendFailureZ retry_payment_LDKPayer_jcall(const void* this_arg, const LDKRoute * route, LDKThirtyTwoBytes payment_id) {
10732         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) this_arg;
10733         JNIEnv *env;
10734         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10735         if (get_jenv_res == JNI_EDETACHED) {
10736                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10737         } else {
10738                 DO_ASSERT(get_jenv_res == JNI_OK);
10739         }
10740         LDKRoute route_var = *route;
10741         uint64_t route_ref = 0;
10742         route_var = Route_clone(route);
10743         CHECK((((uint64_t)route_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10744         CHECK((((uint64_t)&route_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10745         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_var);
10746         route_ref = (uint64_t)route_var.inner;
10747         if (route_var.is_owned) {
10748                 route_ref |= 1;
10749         }
10750         int8_tArray payment_id_arr = (*env)->NewByteArray(env, 32);
10751         (*env)->SetByteArrayRegion(env, payment_id_arr, 0, 32, payment_id.data);
10752         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10753         CHECK(obj != NULL);
10754         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->retry_payment_meth, route_ref, payment_id_arr);
10755         if ((*env)->ExceptionCheck(env)) {
10756                 (*env)->ExceptionDescribe(env);
10757                 (*env)->FatalError(env, "A call to retry_payment in LDKPayer from rust threw an exception.");
10758         }
10759         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10760         CHECK_ACCESS(ret_ptr);
10761         LDKCResult_NonePaymentSendFailureZ ret_conv = *(LDKCResult_NonePaymentSendFailureZ*)(ret_ptr);
10762         FREE((void*)ret);
10763         if (get_jenv_res == JNI_EDETACHED) {
10764                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10765         }
10766         return ret_conv;
10767 }
10768 static void LDKPayer_JCalls_cloned(LDKPayer* new_obj) {
10769         LDKPayer_JCalls *j_calls = (LDKPayer_JCalls*) new_obj->this_arg;
10770         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10771 }
10772 static inline LDKPayer LDKPayer_init (JNIEnv *env, jclass clz, jobject o) {
10773         jclass c = (*env)->GetObjectClass(env, o);
10774         CHECK(c != NULL);
10775         LDKPayer_JCalls *calls = MALLOC(sizeof(LDKPayer_JCalls), "LDKPayer_JCalls");
10776         atomic_init(&calls->refcnt, 1);
10777         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10778         calls->o = (*env)->NewWeakGlobalRef(env, o);
10779         calls->node_id_meth = (*env)->GetMethodID(env, c, "node_id", "()[B");
10780         CHECK(calls->node_id_meth != NULL);
10781         calls->first_hops_meth = (*env)->GetMethodID(env, c, "first_hops", "()[J");
10782         CHECK(calls->first_hops_meth != NULL);
10783         calls->send_payment_meth = (*env)->GetMethodID(env, c, "send_payment", "(J[B[B)J");
10784         CHECK(calls->send_payment_meth != NULL);
10785         calls->retry_payment_meth = (*env)->GetMethodID(env, c, "retry_payment", "(J[B)J");
10786         CHECK(calls->retry_payment_meth != NULL);
10787
10788         LDKPayer ret = {
10789                 .this_arg = (void*) calls,
10790                 .node_id = node_id_LDKPayer_jcall,
10791                 .first_hops = first_hops_LDKPayer_jcall,
10792                 .send_payment = send_payment_LDKPayer_jcall,
10793                 .retry_payment = retry_payment_LDKPayer_jcall,
10794                 .free = LDKPayer_JCalls_free,
10795         };
10796         return ret;
10797 }
10798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKPayer_1new(JNIEnv *env, jclass clz, jobject o) {
10799         LDKPayer *res_ptr = MALLOC(sizeof(LDKPayer), "LDKPayer");
10800         *res_ptr = LDKPayer_init(env, clz, o);
10801         return (uint64_t)res_ptr;
10802 }
10803 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
10804         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10805         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10806         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10807         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
10808         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, (this_arg_conv->node_id)(this_arg_conv->this_arg).compressed_form);
10809         return ret_arr;
10810 }
10811
10812 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payer_1first_1hops(JNIEnv *env, jclass clz, int64_t this_arg) {
10813         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10814         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10815         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10816         LDKCVec_ChannelDetailsZ ret_var = (this_arg_conv->first_hops)(this_arg_conv->this_arg);
10817         int64_tArray ret_arr = NULL;
10818         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
10819         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
10820         for (size_t q = 0; q < ret_var.datalen; q++) {
10821                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
10822                 uint64_t ret_conv_16_ref = 0;
10823                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10824                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10825                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
10826                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
10827                 if (ret_conv_16_var.is_owned) {
10828                         ret_conv_16_ref |= 1;
10829                 }
10830                 ret_arr_ptr[q] = ret_conv_16_ref;
10831         }
10832         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
10833         FREE(ret_var.data);
10834         return ret_arr;
10835 }
10836
10837 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) {
10838         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10839         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10840         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10841         LDKRoute route_conv;
10842         route_conv.inner = (void*)(route & (~1));
10843         route_conv.is_owned = false;
10844         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10845         LDKThirtyTwoBytes payment_hash_ref;
10846         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
10847         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
10848         LDKThirtyTwoBytes payment_secret_ref;
10849         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
10850         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
10851         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
10852         *ret_conv = (this_arg_conv->send_payment)(this_arg_conv->this_arg, &route_conv, payment_hash_ref, payment_secret_ref);
10853         return (uint64_t)ret_conv;
10854 }
10855
10856 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) {
10857         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10858         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10859         LDKPayer* this_arg_conv = (LDKPayer*)this_arg_ptr;
10860         LDKRoute route_conv;
10861         route_conv.inner = (void*)(route & (~1));
10862         route_conv.is_owned = false;
10863         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
10864         LDKThirtyTwoBytes payment_id_ref;
10865         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
10866         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
10867         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
10868         *ret_conv = (this_arg_conv->retry_payment)(this_arg_conv->this_arg, &route_conv, payment_id_ref);
10869         return (uint64_t)ret_conv;
10870 }
10871
10872 typedef struct LDKRouter_JCalls {
10873         atomic_size_t refcnt;
10874         JavaVM *vm;
10875         jweak o;
10876         jmethodID find_route_meth;
10877 } LDKRouter_JCalls;
10878 static void LDKRouter_JCalls_free(void* this_arg) {
10879         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10880         if (atomic_fetch_sub_explicit(&j_calls->refcnt, 1, memory_order_acquire) == 1) {
10881                 JNIEnv *env;
10882                 jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10883                 if (get_jenv_res == JNI_EDETACHED) {
10884                         DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10885                 } else {
10886                         DO_ASSERT(get_jenv_res == JNI_OK);
10887                 }
10888                 (*env)->DeleteWeakGlobalRef(env, j_calls->o);
10889                 if (get_jenv_res == JNI_EDETACHED) {
10890                         DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10891                 }
10892                 FREE(j_calls);
10893         }
10894 }
10895 LDKCResult_RouteLightningErrorZ find_route_LDKRouter_jcall(const void* this_arg, LDKPublicKey payer, const LDKRouteParameters * params, LDKCVec_ChannelDetailsZ * first_hops, const LDKScore * scorer) {
10896         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) this_arg;
10897         JNIEnv *env;
10898         jint get_jenv_res = (*j_calls->vm)->GetEnv(j_calls->vm, (void**)&env, JNI_VERSION_1_6);
10899         if (get_jenv_res == JNI_EDETACHED) {
10900                 DO_ASSERT((*j_calls->vm)->AttachCurrentThread(j_calls->vm, (void**)&env, NULL) == JNI_OK);
10901         } else {
10902                 DO_ASSERT(get_jenv_res == JNI_OK);
10903         }
10904         int8_tArray payer_arr = (*env)->NewByteArray(env, 33);
10905         (*env)->SetByteArrayRegion(env, payer_arr, 0, 33, payer.compressed_form);
10906         LDKRouteParameters params_var = *params;
10907         uint64_t params_ref = 0;
10908         params_var = RouteParameters_clone(params);
10909         CHECK((((uint64_t)params_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10910         CHECK((((uint64_t)&params_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10911         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_var);
10912         params_ref = (uint64_t)params_var.inner;
10913         if (params_var.is_owned) {
10914                 params_ref |= 1;
10915         }
10916         LDKCVec_ChannelDetailsZ *first_hops_var_ptr = first_hops;
10917         int64_tArray first_hops_arr = NULL;
10918         if (first_hops != NULL) {
10919                 LDKCVec_ChannelDetailsZ first_hops_var = *first_hops_var_ptr;
10920                 first_hops_arr = (*env)->NewLongArray(env, first_hops_var.datalen);
10921                 int64_t *first_hops_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, first_hops_arr, NULL);
10922                 for (size_t q = 0; q < first_hops_var.datalen; q++) {
10923                         LDKChannelDetails first_hops_conv_16_var =      first_hops_var.data[q];
10924                         uint64_t first_hops_conv_16_ref = 0;
10925                         CHECK((((uint64_t)first_hops_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
10926                         CHECK((((uint64_t)&first_hops_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
10927                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_var);
10928                         first_hops_conv_16_ref = (uint64_t)first_hops_conv_16_var.inner;
10929                         if (first_hops_conv_16_var.is_owned) {
10930                                 first_hops_conv_16_ref |= 1;
10931                         }
10932                         first_hops_arr_ptr[q] = first_hops_conv_16_ref;
10933                 }
10934                 (*env)->ReleasePrimitiveArrayCritical(env, first_hops_arr, first_hops_arr_ptr, 0);
10935         }
10936         // WARNING: This object doesn't live past this scope, needs clone!
10937         uint64_t ret_scorer = ((uint64_t)scorer) | 1;
10938         jobject obj = (*env)->NewLocalRef(env, j_calls->o);
10939         CHECK(obj != NULL);
10940         uint64_t ret = (*env)->CallLongMethod(env, obj, j_calls->find_route_meth, payer_arr, params_ref, first_hops_arr, ret_scorer);
10941         if ((*env)->ExceptionCheck(env)) {
10942                 (*env)->ExceptionDescribe(env);
10943                 (*env)->FatalError(env, "A call to find_route in LDKRouter from rust threw an exception.");
10944         }
10945         void* ret_ptr = (void*)(((uint64_t)ret) & ~1);
10946         CHECK_ACCESS(ret_ptr);
10947         LDKCResult_RouteLightningErrorZ ret_conv = *(LDKCResult_RouteLightningErrorZ*)(ret_ptr);
10948         FREE((void*)ret);
10949         if (get_jenv_res == JNI_EDETACHED) {
10950                 DO_ASSERT((*j_calls->vm)->DetachCurrentThread(j_calls->vm) == JNI_OK);
10951         }
10952         return ret_conv;
10953 }
10954 static void LDKRouter_JCalls_cloned(LDKRouter* new_obj) {
10955         LDKRouter_JCalls *j_calls = (LDKRouter_JCalls*) new_obj->this_arg;
10956         atomic_fetch_add_explicit(&j_calls->refcnt, 1, memory_order_release);
10957 }
10958 static inline LDKRouter LDKRouter_init (JNIEnv *env, jclass clz, jobject o) {
10959         jclass c = (*env)->GetObjectClass(env, o);
10960         CHECK(c != NULL);
10961         LDKRouter_JCalls *calls = MALLOC(sizeof(LDKRouter_JCalls), "LDKRouter_JCalls");
10962         atomic_init(&calls->refcnt, 1);
10963         DO_ASSERT((*env)->GetJavaVM(env, &calls->vm) == 0);
10964         calls->o = (*env)->NewWeakGlobalRef(env, o);
10965         calls->find_route_meth = (*env)->GetMethodID(env, c, "find_route", "([BJ[JJ)J");
10966         CHECK(calls->find_route_meth != NULL);
10967
10968         LDKRouter ret = {
10969                 .this_arg = (void*) calls,
10970                 .find_route = find_route_LDKRouter_jcall,
10971                 .free = LDKRouter_JCalls_free,
10972         };
10973         return ret;
10974 }
10975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LDKRouter_1new(JNIEnv *env, jclass clz, jobject o) {
10976         LDKRouter *res_ptr = MALLOC(sizeof(LDKRouter), "LDKRouter");
10977         *res_ptr = LDKRouter_init(env, clz, o);
10978         return (uint64_t)res_ptr;
10979 }
10980 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) {
10981         void* this_arg_ptr = (void*)(((uint64_t)this_arg) & ~1);
10982         if (!(this_arg & 1)) { CHECK_ACCESS(this_arg_ptr); }
10983         LDKRouter* this_arg_conv = (LDKRouter*)this_arg_ptr;
10984         LDKPublicKey payer_ref;
10985         CHECK((*env)->GetArrayLength(env, payer) == 33);
10986         (*env)->GetByteArrayRegion(env, payer, 0, 33, payer_ref.compressed_form);
10987         LDKRouteParameters params_conv;
10988         params_conv.inner = (void*)(params & (~1));
10989         params_conv.is_owned = false;
10990         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
10991         LDKCVec_ChannelDetailsZ first_hops_constr;
10992         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
10993         if (first_hops != NULL) {
10994                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
10995                 if (first_hops_constr.datalen > 0)
10996                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
10997                 else
10998                         first_hops_constr.data = NULL;
10999                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
11000                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
11001                         int64_t first_hops_conv_16 = first_hops_vals[q];
11002                         LDKChannelDetails first_hops_conv_16_conv;
11003                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
11004                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
11005                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
11006                         first_hops_constr.data[q] = first_hops_conv_16_conv;
11007                 }
11008                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
11009                 first_hops_ptr = &first_hops_constr;
11010         }
11011         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
11012         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
11013         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
11014         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
11015         *ret_conv = (this_arg_conv->find_route)(this_arg_conv->this_arg, payer_ref, &params_conv, first_hops_ptr, scorer_conv);
11016         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
11017         return (uint64_t)ret_conv;
11018 }
11019
11020 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1get_1compiled_1version(JNIEnv *env, jclass clz) {
11021         LDKStr ret_str = _ldk_get_compiled_version();
11022         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
11023         Str_free(ret_str);
11024         return ret_conv;
11025 }
11026
11027 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings__1ldk_1c_1bindings_1get_1compiled_1version(JNIEnv *env, jclass clz) {
11028         LDKStr ret_str = _ldk_c_bindings_get_compiled_version();
11029         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
11030         Str_free(ret_str);
11031         return ret_conv;
11032 }
11033
11034 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Transaction_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
11035         LDKTransaction _res_ref;
11036         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
11037         _res_ref.data = MALLOC(_res_ref.datalen, "LDKTransaction Bytes");
11038         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
11039         _res_ref.data_is_owned = true;
11040         Transaction_free(_res_ref);
11041 }
11042
11043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1new(JNIEnv *env, jclass clz, int8_tArray script_pubkey, int64_t value) {
11044         LDKCVec_u8Z script_pubkey_ref;
11045         script_pubkey_ref.datalen = (*env)->GetArrayLength(env, script_pubkey);
11046         script_pubkey_ref.data = MALLOC(script_pubkey_ref.datalen, "LDKCVec_u8Z Bytes");
11047         (*env)->GetByteArrayRegion(env, script_pubkey, 0, script_pubkey_ref.datalen, script_pubkey_ref.data);
11048         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11049         *ret_ref = TxOut_new(script_pubkey_ref, value);
11050         return (uint64_t)ret_ref;
11051 }
11052
11053 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxOut_1free(JNIEnv *env, jclass clz, int64_t _res) {
11054         if ((_res & 1) != 0) return;
11055         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11056         CHECK_ACCESS(_res_ptr);
11057         LDKTxOut _res_conv = *(LDKTxOut*)(_res_ptr);
11058         FREE((void*)_res);
11059         TxOut_free(_res_conv);
11060 }
11061
11062 static inline uint64_t TxOut_clone_ptr(LDKTxOut *NONNULL_PTR arg) {
11063         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11064         *ret_ref = TxOut_clone(arg);
11065         return (uint64_t)ret_ref;
11066 }
11067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11068         LDKTxOut* arg_conv = (LDKTxOut*)(arg & ~1);
11069         int64_t ret_val = TxOut_clone_ptr(arg_conv);
11070         return ret_val;
11071 }
11072
11073 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxOut_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11074         LDKTxOut* orig_conv = (LDKTxOut*)(orig & ~1);
11075         LDKTxOut* ret_ref = MALLOC(sizeof(LDKTxOut), "LDKTxOut");
11076         *ret_ref = TxOut_clone(orig_conv);
11077         return (uint64_t)ret_ref;
11078 }
11079
11080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Str_1free(JNIEnv *env, jclass clz, jstring _res) {
11081         LDKStr dummy = { .chars = NULL, .len = 0, .chars_is_owned = false };
11082         Str_free(dummy);
11083 }
11084
11085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11086         LDKSecretKey o_ref;
11087         CHECK((*env)->GetArrayLength(env, o) == 32);
11088         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.bytes);
11089         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11090         *ret_conv = CResult_SecretKeyErrorZ_ok(o_ref);
11091         return (uint64_t)ret_conv;
11092 }
11093
11094 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11095         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11096         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
11097         *ret_conv = CResult_SecretKeyErrorZ_err(e_conv);
11098         return (uint64_t)ret_conv;
11099 }
11100
11101 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11102         LDKCResult_SecretKeyErrorZ* o_conv = (LDKCResult_SecretKeyErrorZ*)(o & ~1);
11103         jboolean ret_val = CResult_SecretKeyErrorZ_is_ok(o_conv);
11104         return ret_val;
11105 }
11106
11107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SecretKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11108         if ((_res & 1) != 0) return;
11109         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11110         CHECK_ACCESS(_res_ptr);
11111         LDKCResult_SecretKeyErrorZ _res_conv = *(LDKCResult_SecretKeyErrorZ*)(_res_ptr);
11112         FREE((void*)_res);
11113         CResult_SecretKeyErrorZ_free(_res_conv);
11114 }
11115
11116 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
11117         LDKPublicKey o_ref;
11118         CHECK((*env)->GetArrayLength(env, o) == 33);
11119         (*env)->GetByteArrayRegion(env, o, 0, 33, o_ref.compressed_form);
11120         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11121         *ret_conv = CResult_PublicKeyErrorZ_ok(o_ref);
11122         return (uint64_t)ret_conv;
11123 }
11124
11125 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11126         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11127         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11128         *ret_conv = CResult_PublicKeyErrorZ_err(e_conv);
11129         return (uint64_t)ret_conv;
11130 }
11131
11132 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11133         LDKCResult_PublicKeyErrorZ* o_conv = (LDKCResult_PublicKeyErrorZ*)(o & ~1);
11134         jboolean ret_val = CResult_PublicKeyErrorZ_is_ok(o_conv);
11135         return ret_val;
11136 }
11137
11138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11139         if ((_res & 1) != 0) return;
11140         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11141         CHECK_ACCESS(_res_ptr);
11142         LDKCResult_PublicKeyErrorZ _res_conv = *(LDKCResult_PublicKeyErrorZ*)(_res_ptr);
11143         FREE((void*)_res);
11144         CResult_PublicKeyErrorZ_free(_res_conv);
11145 }
11146
11147 static inline uint64_t CResult_PublicKeyErrorZ_clone_ptr(LDKCResult_PublicKeyErrorZ *NONNULL_PTR arg) {
11148         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11149         *ret_conv = CResult_PublicKeyErrorZ_clone(arg);
11150         return (uint64_t)ret_conv;
11151 }
11152 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11153         LDKCResult_PublicKeyErrorZ* arg_conv = (LDKCResult_PublicKeyErrorZ*)(arg & ~1);
11154         int64_t ret_val = CResult_PublicKeyErrorZ_clone_ptr(arg_conv);
11155         return ret_val;
11156 }
11157
11158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PublicKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11159         LDKCResult_PublicKeyErrorZ* orig_conv = (LDKCResult_PublicKeyErrorZ*)(orig & ~1);
11160         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
11161         *ret_conv = CResult_PublicKeyErrorZ_clone(orig_conv);
11162         return (uint64_t)ret_conv;
11163 }
11164
11165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11166         LDKTxCreationKeys o_conv;
11167         o_conv.inner = (void*)(o & (~1));
11168         o_conv.is_owned = (o & 1) || (o == 0);
11169         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11170         o_conv = TxCreationKeys_clone(&o_conv);
11171         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11172         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_ok(o_conv);
11173         return (uint64_t)ret_conv;
11174 }
11175
11176 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11177         LDKDecodeError e_conv;
11178         e_conv.inner = (void*)(e & (~1));
11179         e_conv.is_owned = (e & 1) || (e == 0);
11180         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11181         e_conv = DecodeError_clone(&e_conv);
11182         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11183         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_err(e_conv);
11184         return (uint64_t)ret_conv;
11185 }
11186
11187 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11188         LDKCResult_TxCreationKeysDecodeErrorZ* o_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(o & ~1);
11189         jboolean ret_val = CResult_TxCreationKeysDecodeErrorZ_is_ok(o_conv);
11190         return ret_val;
11191 }
11192
11193 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11194         if ((_res & 1) != 0) return;
11195         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11196         CHECK_ACCESS(_res_ptr);
11197         LDKCResult_TxCreationKeysDecodeErrorZ _res_conv = *(LDKCResult_TxCreationKeysDecodeErrorZ*)(_res_ptr);
11198         FREE((void*)_res);
11199         CResult_TxCreationKeysDecodeErrorZ_free(_res_conv);
11200 }
11201
11202 static inline uint64_t CResult_TxCreationKeysDecodeErrorZ_clone_ptr(LDKCResult_TxCreationKeysDecodeErrorZ *NONNULL_PTR arg) {
11203         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11204         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(arg);
11205         return (uint64_t)ret_conv;
11206 }
11207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11208         LDKCResult_TxCreationKeysDecodeErrorZ* arg_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(arg & ~1);
11209         int64_t ret_val = CResult_TxCreationKeysDecodeErrorZ_clone_ptr(arg_conv);
11210         return ret_val;
11211 }
11212
11213 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11214         LDKCResult_TxCreationKeysDecodeErrorZ* orig_conv = (LDKCResult_TxCreationKeysDecodeErrorZ*)(orig & ~1);
11215         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
11216         *ret_conv = CResult_TxCreationKeysDecodeErrorZ_clone(orig_conv);
11217         return (uint64_t)ret_conv;
11218 }
11219
11220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11221         LDKChannelPublicKeys o_conv;
11222         o_conv.inner = (void*)(o & (~1));
11223         o_conv.is_owned = (o & 1) || (o == 0);
11224         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11225         o_conv = ChannelPublicKeys_clone(&o_conv);
11226         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11227         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_ok(o_conv);
11228         return (uint64_t)ret_conv;
11229 }
11230
11231 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11232         LDKDecodeError e_conv;
11233         e_conv.inner = (void*)(e & (~1));
11234         e_conv.is_owned = (e & 1) || (e == 0);
11235         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11236         e_conv = DecodeError_clone(&e_conv);
11237         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11238         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_err(e_conv);
11239         return (uint64_t)ret_conv;
11240 }
11241
11242 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11243         LDKCResult_ChannelPublicKeysDecodeErrorZ* o_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(o & ~1);
11244         jboolean ret_val = CResult_ChannelPublicKeysDecodeErrorZ_is_ok(o_conv);
11245         return ret_val;
11246 }
11247
11248 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11249         if ((_res & 1) != 0) return;
11250         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11251         CHECK_ACCESS(_res_ptr);
11252         LDKCResult_ChannelPublicKeysDecodeErrorZ _res_conv = *(LDKCResult_ChannelPublicKeysDecodeErrorZ*)(_res_ptr);
11253         FREE((void*)_res);
11254         CResult_ChannelPublicKeysDecodeErrorZ_free(_res_conv);
11255 }
11256
11257 static inline uint64_t CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(LDKCResult_ChannelPublicKeysDecodeErrorZ *NONNULL_PTR arg) {
11258         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11259         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(arg);
11260         return (uint64_t)ret_conv;
11261 }
11262 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11263         LDKCResult_ChannelPublicKeysDecodeErrorZ* arg_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(arg & ~1);
11264         int64_t ret_val = CResult_ChannelPublicKeysDecodeErrorZ_clone_ptr(arg_conv);
11265         return ret_val;
11266 }
11267
11268 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelPublicKeysDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11269         LDKCResult_ChannelPublicKeysDecodeErrorZ* orig_conv = (LDKCResult_ChannelPublicKeysDecodeErrorZ*)(orig & ~1);
11270         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
11271         *ret_conv = CResult_ChannelPublicKeysDecodeErrorZ_clone(orig_conv);
11272         return (uint64_t)ret_conv;
11273 }
11274
11275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11276         LDKTxCreationKeys o_conv;
11277         o_conv.inner = (void*)(o & (~1));
11278         o_conv.is_owned = (o & 1) || (o == 0);
11279         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11280         o_conv = TxCreationKeys_clone(&o_conv);
11281         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11282         *ret_conv = CResult_TxCreationKeysErrorZ_ok(o_conv);
11283         return (uint64_t)ret_conv;
11284 }
11285
11286 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11287         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
11288         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11289         *ret_conv = CResult_TxCreationKeysErrorZ_err(e_conv);
11290         return (uint64_t)ret_conv;
11291 }
11292
11293 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11294         LDKCResult_TxCreationKeysErrorZ* o_conv = (LDKCResult_TxCreationKeysErrorZ*)(o & ~1);
11295         jboolean ret_val = CResult_TxCreationKeysErrorZ_is_ok(o_conv);
11296         return ret_val;
11297 }
11298
11299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11300         if ((_res & 1) != 0) return;
11301         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11302         CHECK_ACCESS(_res_ptr);
11303         LDKCResult_TxCreationKeysErrorZ _res_conv = *(LDKCResult_TxCreationKeysErrorZ*)(_res_ptr);
11304         FREE((void*)_res);
11305         CResult_TxCreationKeysErrorZ_free(_res_conv);
11306 }
11307
11308 static inline uint64_t CResult_TxCreationKeysErrorZ_clone_ptr(LDKCResult_TxCreationKeysErrorZ *NONNULL_PTR arg) {
11309         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11310         *ret_conv = CResult_TxCreationKeysErrorZ_clone(arg);
11311         return (uint64_t)ret_conv;
11312 }
11313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11314         LDKCResult_TxCreationKeysErrorZ* arg_conv = (LDKCResult_TxCreationKeysErrorZ*)(arg & ~1);
11315         int64_t ret_val = CResult_TxCreationKeysErrorZ_clone_ptr(arg_conv);
11316         return ret_val;
11317 }
11318
11319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxCreationKeysErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11320         LDKCResult_TxCreationKeysErrorZ* orig_conv = (LDKCResult_TxCreationKeysErrorZ*)(orig & ~1);
11321         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
11322         *ret_conv = CResult_TxCreationKeysErrorZ_clone(orig_conv);
11323         return (uint64_t)ret_conv;
11324 }
11325
11326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1some(JNIEnv *env, jclass clz, int32_t o) {
11327         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11328         *ret_copy = COption_u32Z_some(o);
11329         uint64_t ret_ref = (uint64_t)ret_copy;
11330         return ret_ref;
11331 }
11332
11333 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1none(JNIEnv *env, jclass clz) {
11334         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11335         *ret_copy = COption_u32Z_none();
11336         uint64_t ret_ref = (uint64_t)ret_copy;
11337         return ret_ref;
11338 }
11339
11340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
11341         if ((_res & 1) != 0) return;
11342         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11343         CHECK_ACCESS(_res_ptr);
11344         LDKCOption_u32Z _res_conv = *(LDKCOption_u32Z*)(_res_ptr);
11345         FREE((void*)_res);
11346         COption_u32Z_free(_res_conv);
11347 }
11348
11349 static inline uint64_t COption_u32Z_clone_ptr(LDKCOption_u32Z *NONNULL_PTR arg) {
11350         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11351         *ret_copy = COption_u32Z_clone(arg);
11352 uint64_t ret_ref = (uint64_t)ret_copy;
11353         return ret_ref;
11354 }
11355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11356         LDKCOption_u32Z* arg_conv = (LDKCOption_u32Z*)arg;
11357         int64_t ret_val = COption_u32Z_clone_ptr(arg_conv);
11358         return ret_val;
11359 }
11360
11361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u32Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11362         LDKCOption_u32Z* orig_conv = (LDKCOption_u32Z*)orig;
11363         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
11364         *ret_copy = COption_u32Z_clone(orig_conv);
11365         uint64_t ret_ref = (uint64_t)ret_copy;
11366         return ret_ref;
11367 }
11368
11369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11370         LDKHTLCOutputInCommitment o_conv;
11371         o_conv.inner = (void*)(o & (~1));
11372         o_conv.is_owned = (o & 1) || (o == 0);
11373         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11374         o_conv = HTLCOutputInCommitment_clone(&o_conv);
11375         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11376         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_ok(o_conv);
11377         return (uint64_t)ret_conv;
11378 }
11379
11380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11381         LDKDecodeError e_conv;
11382         e_conv.inner = (void*)(e & (~1));
11383         e_conv.is_owned = (e & 1) || (e == 0);
11384         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11385         e_conv = DecodeError_clone(&e_conv);
11386         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11387         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_err(e_conv);
11388         return (uint64_t)ret_conv;
11389 }
11390
11391 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11392         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* o_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(o & ~1);
11393         jboolean ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_is_ok(o_conv);
11394         return ret_val;
11395 }
11396
11397 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11398         if ((_res & 1) != 0) return;
11399         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11400         CHECK_ACCESS(_res_ptr);
11401         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ _res_conv = *(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(_res_ptr);
11402         FREE((void*)_res);
11403         CResult_HTLCOutputInCommitmentDecodeErrorZ_free(_res_conv);
11404 }
11405
11406 static inline uint64_t CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ *NONNULL_PTR arg) {
11407         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11408         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(arg);
11409         return (uint64_t)ret_conv;
11410 }
11411 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11412         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* arg_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(arg & ~1);
11413         int64_t ret_val = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone_ptr(arg_conv);
11414         return ret_val;
11415 }
11416
11417 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCOutputInCommitmentDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11418         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* orig_conv = (LDKCResult_HTLCOutputInCommitmentDecodeErrorZ*)(orig & ~1);
11419         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
11420         *ret_conv = CResult_HTLCOutputInCommitmentDecodeErrorZ_clone(orig_conv);
11421         return (uint64_t)ret_conv;
11422 }
11423
11424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11425         LDKCounterpartyChannelTransactionParameters o_conv;
11426         o_conv.inner = (void*)(o & (~1));
11427         o_conv.is_owned = (o & 1) || (o == 0);
11428         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11429         o_conv = CounterpartyChannelTransactionParameters_clone(&o_conv);
11430         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11431         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11432         return (uint64_t)ret_conv;
11433 }
11434
11435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11436         LDKDecodeError e_conv;
11437         e_conv.inner = (void*)(e & (~1));
11438         e_conv.is_owned = (e & 1) || (e == 0);
11439         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11440         e_conv = DecodeError_clone(&e_conv);
11441         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11442         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_err(e_conv);
11443         return (uint64_t)ret_conv;
11444 }
11445
11446 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11447         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11448         jboolean ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11449         return ret_val;
11450 }
11451
11452 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11453         if ((_res & 1) != 0) return;
11454         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11455         CHECK_ACCESS(_res_ptr);
11456         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11457         FREE((void*)_res);
11458         CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11459 }
11460
11461 static inline uint64_t CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11462         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11463         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(arg);
11464         return (uint64_t)ret_conv;
11465 }
11466 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11467         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11468         int64_t ret_val = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11469         return ret_val;
11470 }
11471
11472 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CounterpartyChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11473         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11474         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
11475         *ret_conv = CResult_CounterpartyChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11476         return (uint64_t)ret_conv;
11477 }
11478
11479 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11480         LDKChannelTransactionParameters o_conv;
11481         o_conv.inner = (void*)(o & (~1));
11482         o_conv.is_owned = (o & 1) || (o == 0);
11483         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11484         o_conv = ChannelTransactionParameters_clone(&o_conv);
11485         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11486         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_ok(o_conv);
11487         return (uint64_t)ret_conv;
11488 }
11489
11490 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11491         LDKDecodeError e_conv;
11492         e_conv.inner = (void*)(e & (~1));
11493         e_conv.is_owned = (e & 1) || (e == 0);
11494         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11495         e_conv = DecodeError_clone(&e_conv);
11496         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11497         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_err(e_conv);
11498         return (uint64_t)ret_conv;
11499 }
11500
11501 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11502         LDKCResult_ChannelTransactionParametersDecodeErrorZ* o_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(o & ~1);
11503         jboolean ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_is_ok(o_conv);
11504         return ret_val;
11505 }
11506
11507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11508         if ((_res & 1) != 0) return;
11509         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11510         CHECK_ACCESS(_res_ptr);
11511         LDKCResult_ChannelTransactionParametersDecodeErrorZ _res_conv = *(LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(_res_ptr);
11512         FREE((void*)_res);
11513         CResult_ChannelTransactionParametersDecodeErrorZ_free(_res_conv);
11514 }
11515
11516 static inline uint64_t CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(LDKCResult_ChannelTransactionParametersDecodeErrorZ *NONNULL_PTR arg) {
11517         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11518         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(arg);
11519         return (uint64_t)ret_conv;
11520 }
11521 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11522         LDKCResult_ChannelTransactionParametersDecodeErrorZ* arg_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(arg & ~1);
11523         int64_t ret_val = CResult_ChannelTransactionParametersDecodeErrorZ_clone_ptr(arg_conv);
11524         return ret_val;
11525 }
11526
11527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelTransactionParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11528         LDKCResult_ChannelTransactionParametersDecodeErrorZ* orig_conv = (LDKCResult_ChannelTransactionParametersDecodeErrorZ*)(orig & ~1);
11529         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
11530         *ret_conv = CResult_ChannelTransactionParametersDecodeErrorZ_clone(orig_conv);
11531         return (uint64_t)ret_conv;
11532 }
11533
11534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SignatureZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
11535         LDKCVec_SignatureZ _res_constr;
11536         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
11537         if (_res_constr.datalen > 0)
11538                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11539         else
11540                 _res_constr.data = NULL;
11541         for (size_t i = 0; i < _res_constr.datalen; i++) {
11542                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
11543                 LDKSignature _res_conv_8_ref;
11544                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 64);
11545                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 64, _res_conv_8_ref.compact_form);
11546                 _res_constr.data[i] = _res_conv_8_ref;
11547         }
11548         CVec_SignatureZ_free(_res_constr);
11549 }
11550
11551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11552         LDKHolderCommitmentTransaction o_conv;
11553         o_conv.inner = (void*)(o & (~1));
11554         o_conv.is_owned = (o & 1) || (o == 0);
11555         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11556         o_conv = HolderCommitmentTransaction_clone(&o_conv);
11557         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11558         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_ok(o_conv);
11559         return (uint64_t)ret_conv;
11560 }
11561
11562 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11563         LDKDecodeError e_conv;
11564         e_conv.inner = (void*)(e & (~1));
11565         e_conv.is_owned = (e & 1) || (e == 0);
11566         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11567         e_conv = DecodeError_clone(&e_conv);
11568         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11569         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_err(e_conv);
11570         return (uint64_t)ret_conv;
11571 }
11572
11573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11574         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(o & ~1);
11575         jboolean ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11576         return ret_val;
11577 }
11578
11579 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11580         if ((_res & 1) != 0) return;
11581         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11582         CHECK_ACCESS(_res_ptr);
11583         LDKCResult_HolderCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11584         FREE((void*)_res);
11585         CResult_HolderCommitmentTransactionDecodeErrorZ_free(_res_conv);
11586 }
11587
11588 static inline uint64_t CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_HolderCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11589         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11590         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(arg);
11591         return (uint64_t)ret_conv;
11592 }
11593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11594         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11595         int64_t ret_val = CResult_HolderCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11596         return ret_val;
11597 }
11598
11599 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HolderCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11600         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_HolderCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11601         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
11602         *ret_conv = CResult_HolderCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11603         return (uint64_t)ret_conv;
11604 }
11605
11606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11607         LDKBuiltCommitmentTransaction o_conv;
11608         o_conv.inner = (void*)(o & (~1));
11609         o_conv.is_owned = (o & 1) || (o == 0);
11610         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11611         o_conv = BuiltCommitmentTransaction_clone(&o_conv);
11612         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11613         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_ok(o_conv);
11614         return (uint64_t)ret_conv;
11615 }
11616
11617 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11618         LDKDecodeError e_conv;
11619         e_conv.inner = (void*)(e & (~1));
11620         e_conv.is_owned = (e & 1) || (e == 0);
11621         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11622         e_conv = DecodeError_clone(&e_conv);
11623         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11624         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_err(e_conv);
11625         return (uint64_t)ret_conv;
11626 }
11627
11628 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11629         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(o & ~1);
11630         jboolean ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11631         return ret_val;
11632 }
11633
11634 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11635         if ((_res & 1) != 0) return;
11636         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11637         CHECK_ACCESS(_res_ptr);
11638         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(_res_ptr);
11639         FREE((void*)_res);
11640         CResult_BuiltCommitmentTransactionDecodeErrorZ_free(_res_conv);
11641 }
11642
11643 static inline uint64_t CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11644         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11645         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(arg);
11646         return (uint64_t)ret_conv;
11647 }
11648 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11649         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(arg & ~1);
11650         int64_t ret_val = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11651         return ret_val;
11652 }
11653
11654 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1BuiltCommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11655         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_BuiltCommitmentTransactionDecodeErrorZ*)(orig & ~1);
11656         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
11657         *ret_conv = CResult_BuiltCommitmentTransactionDecodeErrorZ_clone(orig_conv);
11658         return (uint64_t)ret_conv;
11659 }
11660
11661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11662         LDKTrustedClosingTransaction o_conv;
11663         o_conv.inner = (void*)(o & (~1));
11664         o_conv.is_owned = (o & 1) || (o == 0);
11665         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11666         // Warning: we need a move here but no clone is available for LDKTrustedClosingTransaction
11667         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11668         *ret_conv = CResult_TrustedClosingTransactionNoneZ_ok(o_conv);
11669         return (uint64_t)ret_conv;
11670 }
11671
11672 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
11673         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
11674         *ret_conv = CResult_TrustedClosingTransactionNoneZ_err();
11675         return (uint64_t)ret_conv;
11676 }
11677
11678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11679         LDKCResult_TrustedClosingTransactionNoneZ* o_conv = (LDKCResult_TrustedClosingTransactionNoneZ*)(o & ~1);
11680         jboolean ret_val = CResult_TrustedClosingTransactionNoneZ_is_ok(o_conv);
11681         return ret_val;
11682 }
11683
11684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedClosingTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11685         if ((_res & 1) != 0) return;
11686         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11687         CHECK_ACCESS(_res_ptr);
11688         LDKCResult_TrustedClosingTransactionNoneZ _res_conv = *(LDKCResult_TrustedClosingTransactionNoneZ*)(_res_ptr);
11689         FREE((void*)_res);
11690         CResult_TrustedClosingTransactionNoneZ_free(_res_conv);
11691 }
11692
11693 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11694         LDKCommitmentTransaction o_conv;
11695         o_conv.inner = (void*)(o & (~1));
11696         o_conv.is_owned = (o & 1) || (o == 0);
11697         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11698         o_conv = CommitmentTransaction_clone(&o_conv);
11699         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11700         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_ok(o_conv);
11701         return (uint64_t)ret_conv;
11702 }
11703
11704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11705         LDKDecodeError e_conv;
11706         e_conv.inner = (void*)(e & (~1));
11707         e_conv.is_owned = (e & 1) || (e == 0);
11708         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11709         e_conv = DecodeError_clone(&e_conv);
11710         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11711         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_err(e_conv);
11712         return (uint64_t)ret_conv;
11713 }
11714
11715 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11716         LDKCResult_CommitmentTransactionDecodeErrorZ* o_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(o & ~1);
11717         jboolean ret_val = CResult_CommitmentTransactionDecodeErrorZ_is_ok(o_conv);
11718         return ret_val;
11719 }
11720
11721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11722         if ((_res & 1) != 0) return;
11723         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11724         CHECK_ACCESS(_res_ptr);
11725         LDKCResult_CommitmentTransactionDecodeErrorZ _res_conv = *(LDKCResult_CommitmentTransactionDecodeErrorZ*)(_res_ptr);
11726         FREE((void*)_res);
11727         CResult_CommitmentTransactionDecodeErrorZ_free(_res_conv);
11728 }
11729
11730 static inline uint64_t CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(LDKCResult_CommitmentTransactionDecodeErrorZ *NONNULL_PTR arg) {
11731         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11732         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(arg);
11733         return (uint64_t)ret_conv;
11734 }
11735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11736         LDKCResult_CommitmentTransactionDecodeErrorZ* arg_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(arg & ~1);
11737         int64_t ret_val = CResult_CommitmentTransactionDecodeErrorZ_clone_ptr(arg_conv);
11738         return ret_val;
11739 }
11740
11741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentTransactionDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11742         LDKCResult_CommitmentTransactionDecodeErrorZ* orig_conv = (LDKCResult_CommitmentTransactionDecodeErrorZ*)(orig & ~1);
11743         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
11744         *ret_conv = CResult_CommitmentTransactionDecodeErrorZ_clone(orig_conv);
11745         return (uint64_t)ret_conv;
11746 }
11747
11748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11749         LDKTrustedCommitmentTransaction o_conv;
11750         o_conv.inner = (void*)(o & (~1));
11751         o_conv.is_owned = (o & 1) || (o == 0);
11752         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11753         // Warning: we need a move here but no clone is available for LDKTrustedCommitmentTransaction
11754         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11755         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_ok(o_conv);
11756         return (uint64_t)ret_conv;
11757 }
11758
11759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1err(JNIEnv *env, jclass clz) {
11760         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
11761         *ret_conv = CResult_TrustedCommitmentTransactionNoneZ_err();
11762         return (uint64_t)ret_conv;
11763 }
11764
11765 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11766         LDKCResult_TrustedCommitmentTransactionNoneZ* o_conv = (LDKCResult_TrustedCommitmentTransactionNoneZ*)(o & ~1);
11767         jboolean ret_val = CResult_TrustedCommitmentTransactionNoneZ_is_ok(o_conv);
11768         return ret_val;
11769 }
11770
11771 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TrustedCommitmentTransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11772         if ((_res & 1) != 0) return;
11773         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11774         CHECK_ACCESS(_res_ptr);
11775         LDKCResult_TrustedCommitmentTransactionNoneZ _res_conv = *(LDKCResult_TrustedCommitmentTransactionNoneZ*)(_res_ptr);
11776         FREE((void*)_res);
11777         CResult_TrustedCommitmentTransactionNoneZ_free(_res_conv);
11778 }
11779
11780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
11781         LDKCVec_SignatureZ o_constr;
11782         o_constr.datalen = (*env)->GetArrayLength(env, o);
11783         if (o_constr.datalen > 0)
11784                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
11785         else
11786                 o_constr.data = NULL;
11787         for (size_t i = 0; i < o_constr.datalen; i++) {
11788                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
11789                 LDKSignature o_conv_8_ref;
11790                 CHECK((*env)->GetArrayLength(env, o_conv_8) == 64);
11791                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, 64, o_conv_8_ref.compact_form);
11792                 o_constr.data[i] = o_conv_8_ref;
11793         }
11794         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11795         *ret_conv = CResult_CVec_SignatureZNoneZ_ok(o_constr);
11796         return (uint64_t)ret_conv;
11797 }
11798
11799 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1err(JNIEnv *env, jclass clz) {
11800         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11801         *ret_conv = CResult_CVec_SignatureZNoneZ_err();
11802         return (uint64_t)ret_conv;
11803 }
11804
11805 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11806         LDKCResult_CVec_SignatureZNoneZ* o_conv = (LDKCResult_CVec_SignatureZNoneZ*)(o & ~1);
11807         jboolean ret_val = CResult_CVec_SignatureZNoneZ_is_ok(o_conv);
11808         return ret_val;
11809 }
11810
11811 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11812         if ((_res & 1) != 0) return;
11813         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11814         CHECK_ACCESS(_res_ptr);
11815         LDKCResult_CVec_SignatureZNoneZ _res_conv = *(LDKCResult_CVec_SignatureZNoneZ*)(_res_ptr);
11816         FREE((void*)_res);
11817         CResult_CVec_SignatureZNoneZ_free(_res_conv);
11818 }
11819
11820 static inline uint64_t CResult_CVec_SignatureZNoneZ_clone_ptr(LDKCResult_CVec_SignatureZNoneZ *NONNULL_PTR arg) {
11821         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11822         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(arg);
11823         return (uint64_t)ret_conv;
11824 }
11825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11826         LDKCResult_CVec_SignatureZNoneZ* arg_conv = (LDKCResult_CVec_SignatureZNoneZ*)(arg & ~1);
11827         int64_t ret_val = CResult_CVec_SignatureZNoneZ_clone_ptr(arg_conv);
11828         return ret_val;
11829 }
11830
11831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1SignatureZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11832         LDKCResult_CVec_SignatureZNoneZ* orig_conv = (LDKCResult_CVec_SignatureZNoneZ*)(orig & ~1);
11833         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
11834         *ret_conv = CResult_CVec_SignatureZNoneZ_clone(orig_conv);
11835         return (uint64_t)ret_conv;
11836 }
11837
11838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11839         LDKShutdownScript o_conv;
11840         o_conv.inner = (void*)(o & (~1));
11841         o_conv.is_owned = (o & 1) || (o == 0);
11842         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11843         o_conv = ShutdownScript_clone(&o_conv);
11844         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11845         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_ok(o_conv);
11846         return (uint64_t)ret_conv;
11847 }
11848
11849 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11850         LDKDecodeError e_conv;
11851         e_conv.inner = (void*)(e & (~1));
11852         e_conv.is_owned = (e & 1) || (e == 0);
11853         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11854         e_conv = DecodeError_clone(&e_conv);
11855         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11856         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_err(e_conv);
11857         return (uint64_t)ret_conv;
11858 }
11859
11860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11861         LDKCResult_ShutdownScriptDecodeErrorZ* o_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(o & ~1);
11862         jboolean ret_val = CResult_ShutdownScriptDecodeErrorZ_is_ok(o_conv);
11863         return ret_val;
11864 }
11865
11866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11867         if ((_res & 1) != 0) return;
11868         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11869         CHECK_ACCESS(_res_ptr);
11870         LDKCResult_ShutdownScriptDecodeErrorZ _res_conv = *(LDKCResult_ShutdownScriptDecodeErrorZ*)(_res_ptr);
11871         FREE((void*)_res);
11872         CResult_ShutdownScriptDecodeErrorZ_free(_res_conv);
11873 }
11874
11875 static inline uint64_t CResult_ShutdownScriptDecodeErrorZ_clone_ptr(LDKCResult_ShutdownScriptDecodeErrorZ *NONNULL_PTR arg) {
11876         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11877         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(arg);
11878         return (uint64_t)ret_conv;
11879 }
11880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11881         LDKCResult_ShutdownScriptDecodeErrorZ* arg_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(arg & ~1);
11882         int64_t ret_val = CResult_ShutdownScriptDecodeErrorZ_clone_ptr(arg_conv);
11883         return ret_val;
11884 }
11885
11886 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11887         LDKCResult_ShutdownScriptDecodeErrorZ* orig_conv = (LDKCResult_ShutdownScriptDecodeErrorZ*)(orig & ~1);
11888         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
11889         *ret_conv = CResult_ShutdownScriptDecodeErrorZ_clone(orig_conv);
11890         return (uint64_t)ret_conv;
11891 }
11892
11893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11894         LDKShutdownScript o_conv;
11895         o_conv.inner = (void*)(o & (~1));
11896         o_conv.is_owned = (o & 1) || (o == 0);
11897         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11898         o_conv = ShutdownScript_clone(&o_conv);
11899         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11900         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_ok(o_conv);
11901         return (uint64_t)ret_conv;
11902 }
11903
11904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1err(JNIEnv *env, jclass clz, int64_t e) {
11905         LDKInvalidShutdownScript e_conv;
11906         e_conv.inner = (void*)(e & (~1));
11907         e_conv.is_owned = (e & 1) || (e == 0);
11908         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
11909         e_conv = InvalidShutdownScript_clone(&e_conv);
11910         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11911         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_err(e_conv);
11912         return (uint64_t)ret_conv;
11913 }
11914
11915 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11916         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* o_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(o & ~1);
11917         jboolean ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_is_ok(o_conv);
11918         return ret_val;
11919 }
11920
11921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11922         if ((_res & 1) != 0) return;
11923         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11924         CHECK_ACCESS(_res_ptr);
11925         LDKCResult_ShutdownScriptInvalidShutdownScriptZ _res_conv = *(LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(_res_ptr);
11926         FREE((void*)_res);
11927         CResult_ShutdownScriptInvalidShutdownScriptZ_free(_res_conv);
11928 }
11929
11930 static inline uint64_t CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(LDKCResult_ShutdownScriptInvalidShutdownScriptZ *NONNULL_PTR arg) {
11931         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11932         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(arg);
11933         return (uint64_t)ret_conv;
11934 }
11935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11936         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* arg_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(arg & ~1);
11937         int64_t ret_val = CResult_ShutdownScriptInvalidShutdownScriptZ_clone_ptr(arg_conv);
11938         return ret_val;
11939 }
11940
11941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownScriptInvalidShutdownScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11942         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* orig_conv = (LDKCResult_ShutdownScriptInvalidShutdownScriptZ*)(orig & ~1);
11943         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
11944         *ret_conv = CResult_ShutdownScriptInvalidShutdownScriptZ_clone(orig_conv);
11945         return (uint64_t)ret_conv;
11946 }
11947
11948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1ok(JNIEnv *env, jclass clz) {
11949         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11950         *ret_conv = CResult_NoneErrorZ_ok();
11951         return (uint64_t)ret_conv;
11952 }
11953
11954 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
11955         LDKIOError e_conv = LDKIOError_from_java(env, e);
11956         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11957         *ret_conv = CResult_NoneErrorZ_err(e_conv);
11958         return (uint64_t)ret_conv;
11959 }
11960
11961 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
11962         LDKCResult_NoneErrorZ* o_conv = (LDKCResult_NoneErrorZ*)(o & ~1);
11963         jboolean ret_val = CResult_NoneErrorZ_is_ok(o_conv);
11964         return ret_val;
11965 }
11966
11967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
11968         if ((_res & 1) != 0) return;
11969         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
11970         CHECK_ACCESS(_res_ptr);
11971         LDKCResult_NoneErrorZ _res_conv = *(LDKCResult_NoneErrorZ*)(_res_ptr);
11972         FREE((void*)_res);
11973         CResult_NoneErrorZ_free(_res_conv);
11974 }
11975
11976 static inline uint64_t CResult_NoneErrorZ_clone_ptr(LDKCResult_NoneErrorZ *NONNULL_PTR arg) {
11977         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11978         *ret_conv = CResult_NoneErrorZ_clone(arg);
11979         return (uint64_t)ret_conv;
11980 }
11981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
11982         LDKCResult_NoneErrorZ* arg_conv = (LDKCResult_NoneErrorZ*)(arg & ~1);
11983         int64_t ret_val = CResult_NoneErrorZ_clone_ptr(arg_conv);
11984         return ret_val;
11985 }
11986
11987 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
11988         LDKCResult_NoneErrorZ* orig_conv = (LDKCResult_NoneErrorZ*)(orig & ~1);
11989         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
11990         *ret_conv = CResult_NoneErrorZ_clone(orig_conv);
11991         return (uint64_t)ret_conv;
11992 }
11993
11994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
11995         LDKRouteHop o_conv;
11996         o_conv.inner = (void*)(o & (~1));
11997         o_conv.is_owned = (o & 1) || (o == 0);
11998         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
11999         o_conv = RouteHop_clone(&o_conv);
12000         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12001         *ret_conv = CResult_RouteHopDecodeErrorZ_ok(o_conv);
12002         return (uint64_t)ret_conv;
12003 }
12004
12005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12006         LDKDecodeError e_conv;
12007         e_conv.inner = (void*)(e & (~1));
12008         e_conv.is_owned = (e & 1) || (e == 0);
12009         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12010         e_conv = DecodeError_clone(&e_conv);
12011         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12012         *ret_conv = CResult_RouteHopDecodeErrorZ_err(e_conv);
12013         return (uint64_t)ret_conv;
12014 }
12015
12016 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12017         LDKCResult_RouteHopDecodeErrorZ* o_conv = (LDKCResult_RouteHopDecodeErrorZ*)(o & ~1);
12018         jboolean ret_val = CResult_RouteHopDecodeErrorZ_is_ok(o_conv);
12019         return ret_val;
12020 }
12021
12022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12023         if ((_res & 1) != 0) return;
12024         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12025         CHECK_ACCESS(_res_ptr);
12026         LDKCResult_RouteHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHopDecodeErrorZ*)(_res_ptr);
12027         FREE((void*)_res);
12028         CResult_RouteHopDecodeErrorZ_free(_res_conv);
12029 }
12030
12031 static inline uint64_t CResult_RouteHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHopDecodeErrorZ *NONNULL_PTR arg) {
12032         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12033         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(arg);
12034         return (uint64_t)ret_conv;
12035 }
12036 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12037         LDKCResult_RouteHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHopDecodeErrorZ*)(arg & ~1);
12038         int64_t ret_val = CResult_RouteHopDecodeErrorZ_clone_ptr(arg_conv);
12039         return ret_val;
12040 }
12041
12042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12043         LDKCResult_RouteHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHopDecodeErrorZ*)(orig & ~1);
12044         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
12045         *ret_conv = CResult_RouteHopDecodeErrorZ_clone(orig_conv);
12046         return (uint64_t)ret_conv;
12047 }
12048
12049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12050         LDKCVec_RouteHopZ _res_constr;
12051         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12052         if (_res_constr.datalen > 0)
12053                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12054         else
12055                 _res_constr.data = NULL;
12056         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12057         for (size_t k = 0; k < _res_constr.datalen; k++) {
12058                 int64_t _res_conv_10 = _res_vals[k];
12059                 LDKRouteHop _res_conv_10_conv;
12060                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
12061                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
12062                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
12063                 _res_constr.data[k] = _res_conv_10_conv;
12064         }
12065         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12066         CVec_RouteHopZ_free(_res_constr);
12067 }
12068
12069 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1RouteHopZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12070         LDKCVec_CVec_RouteHopZZ _res_constr;
12071         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12072         if (_res_constr.datalen > 0)
12073                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
12074         else
12075                 _res_constr.data = NULL;
12076         for (size_t m = 0; m < _res_constr.datalen; m++) {
12077                 int64_tArray _res_conv_12 = (*env)->GetObjectArrayElement(env, _res, m);
12078                 LDKCVec_RouteHopZ _res_conv_12_constr;
12079                 _res_conv_12_constr.datalen = (*env)->GetArrayLength(env, _res_conv_12);
12080                 if (_res_conv_12_constr.datalen > 0)
12081                         _res_conv_12_constr.data = MALLOC(_res_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
12082                 else
12083                         _res_conv_12_constr.data = NULL;
12084                 int64_t* _res_conv_12_vals = (*env)->GetLongArrayElements (env, _res_conv_12, NULL);
12085                 for (size_t k = 0; k < _res_conv_12_constr.datalen; k++) {
12086                         int64_t _res_conv_12_conv_10 = _res_conv_12_vals[k];
12087                         LDKRouteHop _res_conv_12_conv_10_conv;
12088                         _res_conv_12_conv_10_conv.inner = (void*)(_res_conv_12_conv_10 & (~1));
12089                         _res_conv_12_conv_10_conv.is_owned = (_res_conv_12_conv_10 & 1) || (_res_conv_12_conv_10 == 0);
12090                         CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_12_conv_10_conv);
12091                         _res_conv_12_constr.data[k] = _res_conv_12_conv_10_conv;
12092                 }
12093                 (*env)->ReleaseLongArrayElements(env, _res_conv_12, _res_conv_12_vals, 0);
12094                 _res_constr.data[m] = _res_conv_12_constr;
12095         }
12096         CVec_CVec_RouteHopZZ_free(_res_constr);
12097 }
12098
12099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12100         LDKRoute o_conv;
12101         o_conv.inner = (void*)(o & (~1));
12102         o_conv.is_owned = (o & 1) || (o == 0);
12103         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12104         o_conv = Route_clone(&o_conv);
12105         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12106         *ret_conv = CResult_RouteDecodeErrorZ_ok(o_conv);
12107         return (uint64_t)ret_conv;
12108 }
12109
12110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12111         LDKDecodeError e_conv;
12112         e_conv.inner = (void*)(e & (~1));
12113         e_conv.is_owned = (e & 1) || (e == 0);
12114         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12115         e_conv = DecodeError_clone(&e_conv);
12116         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12117         *ret_conv = CResult_RouteDecodeErrorZ_err(e_conv);
12118         return (uint64_t)ret_conv;
12119 }
12120
12121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12122         LDKCResult_RouteDecodeErrorZ* o_conv = (LDKCResult_RouteDecodeErrorZ*)(o & ~1);
12123         jboolean ret_val = CResult_RouteDecodeErrorZ_is_ok(o_conv);
12124         return ret_val;
12125 }
12126
12127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12128         if ((_res & 1) != 0) return;
12129         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12130         CHECK_ACCESS(_res_ptr);
12131         LDKCResult_RouteDecodeErrorZ _res_conv = *(LDKCResult_RouteDecodeErrorZ*)(_res_ptr);
12132         FREE((void*)_res);
12133         CResult_RouteDecodeErrorZ_free(_res_conv);
12134 }
12135
12136 static inline uint64_t CResult_RouteDecodeErrorZ_clone_ptr(LDKCResult_RouteDecodeErrorZ *NONNULL_PTR arg) {
12137         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12138         *ret_conv = CResult_RouteDecodeErrorZ_clone(arg);
12139         return (uint64_t)ret_conv;
12140 }
12141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12142         LDKCResult_RouteDecodeErrorZ* arg_conv = (LDKCResult_RouteDecodeErrorZ*)(arg & ~1);
12143         int64_t ret_val = CResult_RouteDecodeErrorZ_clone_ptr(arg_conv);
12144         return ret_val;
12145 }
12146
12147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12148         LDKCResult_RouteDecodeErrorZ* orig_conv = (LDKCResult_RouteDecodeErrorZ*)(orig & ~1);
12149         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
12150         *ret_conv = CResult_RouteDecodeErrorZ_clone(orig_conv);
12151         return (uint64_t)ret_conv;
12152 }
12153
12154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12155         LDKRouteParameters o_conv;
12156         o_conv.inner = (void*)(o & (~1));
12157         o_conv.is_owned = (o & 1) || (o == 0);
12158         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12159         o_conv = RouteParameters_clone(&o_conv);
12160         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12161         *ret_conv = CResult_RouteParametersDecodeErrorZ_ok(o_conv);
12162         return (uint64_t)ret_conv;
12163 }
12164
12165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12166         LDKDecodeError e_conv;
12167         e_conv.inner = (void*)(e & (~1));
12168         e_conv.is_owned = (e & 1) || (e == 0);
12169         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12170         e_conv = DecodeError_clone(&e_conv);
12171         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12172         *ret_conv = CResult_RouteParametersDecodeErrorZ_err(e_conv);
12173         return (uint64_t)ret_conv;
12174 }
12175
12176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12177         LDKCResult_RouteParametersDecodeErrorZ* o_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(o & ~1);
12178         jboolean ret_val = CResult_RouteParametersDecodeErrorZ_is_ok(o_conv);
12179         return ret_val;
12180 }
12181
12182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12183         if ((_res & 1) != 0) return;
12184         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12185         CHECK_ACCESS(_res_ptr);
12186         LDKCResult_RouteParametersDecodeErrorZ _res_conv = *(LDKCResult_RouteParametersDecodeErrorZ*)(_res_ptr);
12187         FREE((void*)_res);
12188         CResult_RouteParametersDecodeErrorZ_free(_res_conv);
12189 }
12190
12191 static inline uint64_t CResult_RouteParametersDecodeErrorZ_clone_ptr(LDKCResult_RouteParametersDecodeErrorZ *NONNULL_PTR arg) {
12192         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12193         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(arg);
12194         return (uint64_t)ret_conv;
12195 }
12196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12197         LDKCResult_RouteParametersDecodeErrorZ* arg_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(arg & ~1);
12198         int64_t ret_val = CResult_RouteParametersDecodeErrorZ_clone_ptr(arg_conv);
12199         return ret_val;
12200 }
12201
12202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteParametersDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12203         LDKCResult_RouteParametersDecodeErrorZ* orig_conv = (LDKCResult_RouteParametersDecodeErrorZ*)(orig & ~1);
12204         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
12205         *ret_conv = CResult_RouteParametersDecodeErrorZ_clone(orig_conv);
12206         return (uint64_t)ret_conv;
12207 }
12208
12209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12210         LDKCVec_RouteHintZ _res_constr;
12211         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12212         if (_res_constr.datalen > 0)
12213                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
12214         else
12215                 _res_constr.data = NULL;
12216         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12217         for (size_t l = 0; l < _res_constr.datalen; l++) {
12218                 int64_t _res_conv_11 = _res_vals[l];
12219                 LDKRouteHint _res_conv_11_conv;
12220                 _res_conv_11_conv.inner = (void*)(_res_conv_11 & (~1));
12221                 _res_conv_11_conv.is_owned = (_res_conv_11 & 1) || (_res_conv_11 == 0);
12222                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_11_conv);
12223                 _res_constr.data[l] = _res_conv_11_conv;
12224         }
12225         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12226         CVec_RouteHintZ_free(_res_constr);
12227 }
12228
12229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1some(JNIEnv *env, jclass clz, int64_t o) {
12230         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12231         *ret_copy = COption_u64Z_some(o);
12232         uint64_t ret_ref = (uint64_t)ret_copy;
12233         return ret_ref;
12234 }
12235
12236 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1none(JNIEnv *env, jclass clz) {
12237         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12238         *ret_copy = COption_u64Z_none();
12239         uint64_t ret_ref = (uint64_t)ret_copy;
12240         return ret_ref;
12241 }
12242
12243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
12244         if ((_res & 1) != 0) return;
12245         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12246         CHECK_ACCESS(_res_ptr);
12247         LDKCOption_u64Z _res_conv = *(LDKCOption_u64Z*)(_res_ptr);
12248         FREE((void*)_res);
12249         COption_u64Z_free(_res_conv);
12250 }
12251
12252 static inline uint64_t COption_u64Z_clone_ptr(LDKCOption_u64Z *NONNULL_PTR arg) {
12253         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12254         *ret_copy = COption_u64Z_clone(arg);
12255 uint64_t ret_ref = (uint64_t)ret_copy;
12256         return ret_ref;
12257 }
12258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12259         LDKCOption_u64Z* arg_conv = (LDKCOption_u64Z*)arg;
12260         int64_t ret_val = COption_u64Z_clone_ptr(arg_conv);
12261         return ret_val;
12262 }
12263
12264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u64Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12265         LDKCOption_u64Z* orig_conv = (LDKCOption_u64Z*)orig;
12266         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
12267         *ret_copy = COption_u64Z_clone(orig_conv);
12268         uint64_t ret_ref = (uint64_t)ret_copy;
12269         return ret_ref;
12270 }
12271
12272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12273         LDKPayee o_conv;
12274         o_conv.inner = (void*)(o & (~1));
12275         o_conv.is_owned = (o & 1) || (o == 0);
12276         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12277         o_conv = Payee_clone(&o_conv);
12278         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12279         *ret_conv = CResult_PayeeDecodeErrorZ_ok(o_conv);
12280         return (uint64_t)ret_conv;
12281 }
12282
12283 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12284         LDKDecodeError e_conv;
12285         e_conv.inner = (void*)(e & (~1));
12286         e_conv.is_owned = (e & 1) || (e == 0);
12287         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12288         e_conv = DecodeError_clone(&e_conv);
12289         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12290         *ret_conv = CResult_PayeeDecodeErrorZ_err(e_conv);
12291         return (uint64_t)ret_conv;
12292 }
12293
12294 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12295         LDKCResult_PayeeDecodeErrorZ* o_conv = (LDKCResult_PayeeDecodeErrorZ*)(o & ~1);
12296         jboolean ret_val = CResult_PayeeDecodeErrorZ_is_ok(o_conv);
12297         return ret_val;
12298 }
12299
12300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12301         if ((_res & 1) != 0) return;
12302         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12303         CHECK_ACCESS(_res_ptr);
12304         LDKCResult_PayeeDecodeErrorZ _res_conv = *(LDKCResult_PayeeDecodeErrorZ*)(_res_ptr);
12305         FREE((void*)_res);
12306         CResult_PayeeDecodeErrorZ_free(_res_conv);
12307 }
12308
12309 static inline uint64_t CResult_PayeeDecodeErrorZ_clone_ptr(LDKCResult_PayeeDecodeErrorZ *NONNULL_PTR arg) {
12310         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12311         *ret_conv = CResult_PayeeDecodeErrorZ_clone(arg);
12312         return (uint64_t)ret_conv;
12313 }
12314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12315         LDKCResult_PayeeDecodeErrorZ* arg_conv = (LDKCResult_PayeeDecodeErrorZ*)(arg & ~1);
12316         int64_t ret_val = CResult_PayeeDecodeErrorZ_clone_ptr(arg_conv);
12317         return ret_val;
12318 }
12319
12320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12321         LDKCResult_PayeeDecodeErrorZ* orig_conv = (LDKCResult_PayeeDecodeErrorZ*)(orig & ~1);
12322         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
12323         *ret_conv = CResult_PayeeDecodeErrorZ_clone(orig_conv);
12324         return (uint64_t)ret_conv;
12325 }
12326
12327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1RouteHintHopZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12328         LDKCVec_RouteHintHopZ _res_constr;
12329         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12330         if (_res_constr.datalen > 0)
12331                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
12332         else
12333                 _res_constr.data = NULL;
12334         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12335         for (size_t o = 0; o < _res_constr.datalen; o++) {
12336                 int64_t _res_conv_14 = _res_vals[o];
12337                 LDKRouteHintHop _res_conv_14_conv;
12338                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
12339                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
12340                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
12341                 _res_constr.data[o] = _res_conv_14_conv;
12342         }
12343         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12344         CVec_RouteHintHopZ_free(_res_constr);
12345 }
12346
12347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12348         LDKRouteHint o_conv;
12349         o_conv.inner = (void*)(o & (~1));
12350         o_conv.is_owned = (o & 1) || (o == 0);
12351         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12352         o_conv = RouteHint_clone(&o_conv);
12353         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12354         *ret_conv = CResult_RouteHintDecodeErrorZ_ok(o_conv);
12355         return (uint64_t)ret_conv;
12356 }
12357
12358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12359         LDKDecodeError e_conv;
12360         e_conv.inner = (void*)(e & (~1));
12361         e_conv.is_owned = (e & 1) || (e == 0);
12362         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12363         e_conv = DecodeError_clone(&e_conv);
12364         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12365         *ret_conv = CResult_RouteHintDecodeErrorZ_err(e_conv);
12366         return (uint64_t)ret_conv;
12367 }
12368
12369 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12370         LDKCResult_RouteHintDecodeErrorZ* o_conv = (LDKCResult_RouteHintDecodeErrorZ*)(o & ~1);
12371         jboolean ret_val = CResult_RouteHintDecodeErrorZ_is_ok(o_conv);
12372         return ret_val;
12373 }
12374
12375 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12376         if ((_res & 1) != 0) return;
12377         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12378         CHECK_ACCESS(_res_ptr);
12379         LDKCResult_RouteHintDecodeErrorZ _res_conv = *(LDKCResult_RouteHintDecodeErrorZ*)(_res_ptr);
12380         FREE((void*)_res);
12381         CResult_RouteHintDecodeErrorZ_free(_res_conv);
12382 }
12383
12384 static inline uint64_t CResult_RouteHintDecodeErrorZ_clone_ptr(LDKCResult_RouteHintDecodeErrorZ *NONNULL_PTR arg) {
12385         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12386         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(arg);
12387         return (uint64_t)ret_conv;
12388 }
12389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12390         LDKCResult_RouteHintDecodeErrorZ* arg_conv = (LDKCResult_RouteHintDecodeErrorZ*)(arg & ~1);
12391         int64_t ret_val = CResult_RouteHintDecodeErrorZ_clone_ptr(arg_conv);
12392         return ret_val;
12393 }
12394
12395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12396         LDKCResult_RouteHintDecodeErrorZ* orig_conv = (LDKCResult_RouteHintDecodeErrorZ*)(orig & ~1);
12397         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
12398         *ret_conv = CResult_RouteHintDecodeErrorZ_clone(orig_conv);
12399         return (uint64_t)ret_conv;
12400 }
12401
12402 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12403         LDKRouteHintHop o_conv;
12404         o_conv.inner = (void*)(o & (~1));
12405         o_conv.is_owned = (o & 1) || (o == 0);
12406         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12407         o_conv = RouteHintHop_clone(&o_conv);
12408         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12409         *ret_conv = CResult_RouteHintHopDecodeErrorZ_ok(o_conv);
12410         return (uint64_t)ret_conv;
12411 }
12412
12413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12414         LDKDecodeError e_conv;
12415         e_conv.inner = (void*)(e & (~1));
12416         e_conv.is_owned = (e & 1) || (e == 0);
12417         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12418         e_conv = DecodeError_clone(&e_conv);
12419         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12420         *ret_conv = CResult_RouteHintHopDecodeErrorZ_err(e_conv);
12421         return (uint64_t)ret_conv;
12422 }
12423
12424 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12425         LDKCResult_RouteHintHopDecodeErrorZ* o_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(o & ~1);
12426         jboolean ret_val = CResult_RouteHintHopDecodeErrorZ_is_ok(o_conv);
12427         return ret_val;
12428 }
12429
12430 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12431         if ((_res & 1) != 0) return;
12432         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12433         CHECK_ACCESS(_res_ptr);
12434         LDKCResult_RouteHintHopDecodeErrorZ _res_conv = *(LDKCResult_RouteHintHopDecodeErrorZ*)(_res_ptr);
12435         FREE((void*)_res);
12436         CResult_RouteHintHopDecodeErrorZ_free(_res_conv);
12437 }
12438
12439 static inline uint64_t CResult_RouteHintHopDecodeErrorZ_clone_ptr(LDKCResult_RouteHintHopDecodeErrorZ *NONNULL_PTR arg) {
12440         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12441         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(arg);
12442         return (uint64_t)ret_conv;
12443 }
12444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12445         LDKCResult_RouteHintHopDecodeErrorZ* arg_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(arg & ~1);
12446         int64_t ret_val = CResult_RouteHintHopDecodeErrorZ_clone_ptr(arg_conv);
12447         return ret_val;
12448 }
12449
12450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteHintHopDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12451         LDKCResult_RouteHintHopDecodeErrorZ* orig_conv = (LDKCResult_RouteHintHopDecodeErrorZ*)(orig & ~1);
12452         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
12453         *ret_conv = CResult_RouteHintHopDecodeErrorZ_clone(orig_conv);
12454         return (uint64_t)ret_conv;
12455 }
12456
12457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelDetailsZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12458         LDKCVec_ChannelDetailsZ _res_constr;
12459         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12460         if (_res_constr.datalen > 0)
12461                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
12462         else
12463                 _res_constr.data = NULL;
12464         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12465         for (size_t q = 0; q < _res_constr.datalen; q++) {
12466                 int64_t _res_conv_16 = _res_vals[q];
12467                 LDKChannelDetails _res_conv_16_conv;
12468                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
12469                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
12470                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
12471                 _res_constr.data[q] = _res_conv_16_conv;
12472         }
12473         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12474         CVec_ChannelDetailsZ_free(_res_constr);
12475 }
12476
12477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12478         LDKRoute o_conv;
12479         o_conv.inner = (void*)(o & (~1));
12480         o_conv.is_owned = (o & 1) || (o == 0);
12481         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
12482         o_conv = Route_clone(&o_conv);
12483         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12484         *ret_conv = CResult_RouteLightningErrorZ_ok(o_conv);
12485         return (uint64_t)ret_conv;
12486 }
12487
12488 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12489         LDKLightningError e_conv;
12490         e_conv.inner = (void*)(e & (~1));
12491         e_conv.is_owned = (e & 1) || (e == 0);
12492         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12493         e_conv = LightningError_clone(&e_conv);
12494         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12495         *ret_conv = CResult_RouteLightningErrorZ_err(e_conv);
12496         return (uint64_t)ret_conv;
12497 }
12498
12499 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12500         LDKCResult_RouteLightningErrorZ* o_conv = (LDKCResult_RouteLightningErrorZ*)(o & ~1);
12501         jboolean ret_val = CResult_RouteLightningErrorZ_is_ok(o_conv);
12502         return ret_val;
12503 }
12504
12505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12506         if ((_res & 1) != 0) return;
12507         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12508         CHECK_ACCESS(_res_ptr);
12509         LDKCResult_RouteLightningErrorZ _res_conv = *(LDKCResult_RouteLightningErrorZ*)(_res_ptr);
12510         FREE((void*)_res);
12511         CResult_RouteLightningErrorZ_free(_res_conv);
12512 }
12513
12514 static inline uint64_t CResult_RouteLightningErrorZ_clone_ptr(LDKCResult_RouteLightningErrorZ *NONNULL_PTR arg) {
12515         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12516         *ret_conv = CResult_RouteLightningErrorZ_clone(arg);
12517         return (uint64_t)ret_conv;
12518 }
12519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12520         LDKCResult_RouteLightningErrorZ* arg_conv = (LDKCResult_RouteLightningErrorZ*)(arg & ~1);
12521         int64_t ret_val = CResult_RouteLightningErrorZ_clone_ptr(arg_conv);
12522         return ret_val;
12523 }
12524
12525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RouteLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12526         LDKCResult_RouteLightningErrorZ* orig_conv = (LDKCResult_RouteLightningErrorZ*)(orig & ~1);
12527         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
12528         *ret_conv = CResult_RouteLightningErrorZ_clone(orig_conv);
12529         return (uint64_t)ret_conv;
12530 }
12531
12532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12533         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12534         CHECK_ACCESS(o_ptr);
12535         LDKTxOut o_conv = *(LDKTxOut*)(o_ptr);
12536         o_conv = TxOut_clone((LDKTxOut*)(((uint64_t)o) & ~1));
12537         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12538         *ret_conv = CResult_TxOutAccessErrorZ_ok(o_conv);
12539         return (uint64_t)ret_conv;
12540 }
12541
12542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
12543         LDKAccessError e_conv = LDKAccessError_from_java(env, e);
12544         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12545         *ret_conv = CResult_TxOutAccessErrorZ_err(e_conv);
12546         return (uint64_t)ret_conv;
12547 }
12548
12549 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12550         LDKCResult_TxOutAccessErrorZ* o_conv = (LDKCResult_TxOutAccessErrorZ*)(o & ~1);
12551         jboolean ret_val = CResult_TxOutAccessErrorZ_is_ok(o_conv);
12552         return ret_val;
12553 }
12554
12555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12556         if ((_res & 1) != 0) return;
12557         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12558         CHECK_ACCESS(_res_ptr);
12559         LDKCResult_TxOutAccessErrorZ _res_conv = *(LDKCResult_TxOutAccessErrorZ*)(_res_ptr);
12560         FREE((void*)_res);
12561         CResult_TxOutAccessErrorZ_free(_res_conv);
12562 }
12563
12564 static inline uint64_t CResult_TxOutAccessErrorZ_clone_ptr(LDKCResult_TxOutAccessErrorZ *NONNULL_PTR arg) {
12565         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12566         *ret_conv = CResult_TxOutAccessErrorZ_clone(arg);
12567         return (uint64_t)ret_conv;
12568 }
12569 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12570         LDKCResult_TxOutAccessErrorZ* arg_conv = (LDKCResult_TxOutAccessErrorZ*)(arg & ~1);
12571         int64_t ret_val = CResult_TxOutAccessErrorZ_clone_ptr(arg_conv);
12572         return ret_val;
12573 }
12574
12575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TxOutAccessErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12576         LDKCResult_TxOutAccessErrorZ* orig_conv = (LDKCResult_TxOutAccessErrorZ*)(orig & ~1);
12577         LDKCResult_TxOutAccessErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxOutAccessErrorZ), "LDKCResult_TxOutAccessErrorZ");
12578         *ret_conv = CResult_TxOutAccessErrorZ_clone(orig_conv);
12579         return (uint64_t)ret_conv;
12580 }
12581
12582 static inline uint64_t C2Tuple_usizeTransactionZ_clone_ptr(LDKC2Tuple_usizeTransactionZ *NONNULL_PTR arg) {
12583         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12584         *ret_conv = C2Tuple_usizeTransactionZ_clone(arg);
12585         return ((uint64_t)ret_conv);
12586 }
12587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12588         LDKC2Tuple_usizeTransactionZ* arg_conv = (LDKC2Tuple_usizeTransactionZ*)(arg & ~1);
12589         int64_t ret_val = C2Tuple_usizeTransactionZ_clone_ptr(arg_conv);
12590         return ret_val;
12591 }
12592
12593 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12594         LDKC2Tuple_usizeTransactionZ* orig_conv = (LDKC2Tuple_usizeTransactionZ*)(orig & ~1);
12595         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12596         *ret_conv = C2Tuple_usizeTransactionZ_clone(orig_conv);
12597         return ((uint64_t)ret_conv);
12598 }
12599
12600 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
12601         LDKTransaction b_ref;
12602         b_ref.datalen = (*env)->GetArrayLength(env, b);
12603         b_ref.data = MALLOC(b_ref.datalen, "LDKTransaction Bytes");
12604         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
12605         b_ref.data_is_owned = true;
12606         LDKC2Tuple_usizeTransactionZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_usizeTransactionZ), "LDKC2Tuple_usizeTransactionZ");
12607         *ret_conv = C2Tuple_usizeTransactionZ_new(a, b_ref);
12608         return ((uint64_t)ret_conv);
12609 }
12610
12611 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1usizeTransactionZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12612         if ((_res & 1) != 0) return;
12613         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12614         CHECK_ACCESS(_res_ptr);
12615         LDKC2Tuple_usizeTransactionZ _res_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_ptr);
12616         FREE((void*)_res);
12617         C2Tuple_usizeTransactionZ_free(_res_conv);
12618 }
12619
12620 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12621         LDKCVec_C2Tuple_usizeTransactionZZ _res_constr;
12622         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12623         if (_res_constr.datalen > 0)
12624                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
12625         else
12626                 _res_constr.data = NULL;
12627         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12628         for (size_t c = 0; c < _res_constr.datalen; c++) {
12629                 int64_t _res_conv_28 = _res_vals[c];
12630                 void* _res_conv_28_ptr = (void*)(((uint64_t)_res_conv_28) & ~1);
12631                 CHECK_ACCESS(_res_conv_28_ptr);
12632                 LDKC2Tuple_usizeTransactionZ _res_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(_res_conv_28_ptr);
12633                 FREE((void*)_res_conv_28);
12634                 _res_constr.data[c] = _res_conv_28_conv;
12635         }
12636         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12637         CVec_C2Tuple_usizeTransactionZZ_free(_res_constr);
12638 }
12639
12640 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxidZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
12641         LDKCVec_TxidZ _res_constr;
12642         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12643         if (_res_constr.datalen > 0)
12644                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKThirtyTwoBytes), "LDKCVec_TxidZ Elements");
12645         else
12646                 _res_constr.data = NULL;
12647         for (size_t i = 0; i < _res_constr.datalen; i++) {
12648                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
12649                 LDKThirtyTwoBytes _res_conv_8_ref;
12650                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 32);
12651                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 32, _res_conv_8_ref.data);
12652                 _res_constr.data[i] = _res_conv_8_ref;
12653         }
12654         CVec_TxidZ_free(_res_constr);
12655 }
12656
12657 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1ok(JNIEnv *env, jclass clz) {
12658         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12659         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_ok();
12660         return (uint64_t)ret_conv;
12661 }
12662
12663 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1err(JNIEnv *env, jclass clz, jclass e) {
12664         LDKChannelMonitorUpdateErr e_conv = LDKChannelMonitorUpdateErr_from_java(env, e);
12665         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12666         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_err(e_conv);
12667         return (uint64_t)ret_conv;
12668 }
12669
12670 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12671         LDKCResult_NoneChannelMonitorUpdateErrZ* o_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(o & ~1);
12672         jboolean ret_val = CResult_NoneChannelMonitorUpdateErrZ_is_ok(o_conv);
12673         return ret_val;
12674 }
12675
12676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12677         if ((_res & 1) != 0) return;
12678         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12679         CHECK_ACCESS(_res_ptr);
12680         LDKCResult_NoneChannelMonitorUpdateErrZ _res_conv = *(LDKCResult_NoneChannelMonitorUpdateErrZ*)(_res_ptr);
12681         FREE((void*)_res);
12682         CResult_NoneChannelMonitorUpdateErrZ_free(_res_conv);
12683 }
12684
12685 static inline uint64_t CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(LDKCResult_NoneChannelMonitorUpdateErrZ *NONNULL_PTR arg) {
12686         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12687         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(arg);
12688         return (uint64_t)ret_conv;
12689 }
12690 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12691         LDKCResult_NoneChannelMonitorUpdateErrZ* arg_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(arg & ~1);
12692         int64_t ret_val = CResult_NoneChannelMonitorUpdateErrZ_clone_ptr(arg_conv);
12693         return ret_val;
12694 }
12695
12696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneChannelMonitorUpdateErrZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12697         LDKCResult_NoneChannelMonitorUpdateErrZ* orig_conv = (LDKCResult_NoneChannelMonitorUpdateErrZ*)(orig & ~1);
12698         LDKCResult_NoneChannelMonitorUpdateErrZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneChannelMonitorUpdateErrZ), "LDKCResult_NoneChannelMonitorUpdateErrZ");
12699         *ret_conv = CResult_NoneChannelMonitorUpdateErrZ_clone(orig_conv);
12700         return (uint64_t)ret_conv;
12701 }
12702
12703 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12704         LDKCVec_MonitorEventZ _res_constr;
12705         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12706         if (_res_constr.datalen > 0)
12707                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMonitorEvent), "LDKCVec_MonitorEventZ Elements");
12708         else
12709                 _res_constr.data = NULL;
12710         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12711         for (size_t o = 0; o < _res_constr.datalen; o++) {
12712                 int64_t _res_conv_14 = _res_vals[o];
12713                 void* _res_conv_14_ptr = (void*)(((uint64_t)_res_conv_14) & ~1);
12714                 CHECK_ACCESS(_res_conv_14_ptr);
12715                 LDKMonitorEvent _res_conv_14_conv = *(LDKMonitorEvent*)(_res_conv_14_ptr);
12716                 FREE((void*)_res_conv_14);
12717                 _res_constr.data[o] = _res_conv_14_conv;
12718         }
12719         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12720         CVec_MonitorEventZ_free(_res_constr);
12721 }
12722
12723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12724         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12725         CHECK_ACCESS(o_ptr);
12726         LDKC2Tuple_usizeTransactionZ o_conv = *(LDKC2Tuple_usizeTransactionZ*)(o_ptr);
12727         o_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)o) & ~1));
12728         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12729         *ret_copy = COption_C2Tuple_usizeTransactionZZ_some(o_conv);
12730         uint64_t ret_ref = (uint64_t)ret_copy;
12731         return ret_ref;
12732 }
12733
12734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1none(JNIEnv *env, jclass clz) {
12735         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12736         *ret_copy = COption_C2Tuple_usizeTransactionZZ_none();
12737         uint64_t ret_ref = (uint64_t)ret_copy;
12738         return ret_ref;
12739 }
12740
12741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12742         if ((_res & 1) != 0) return;
12743         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12744         CHECK_ACCESS(_res_ptr);
12745         LDKCOption_C2Tuple_usizeTransactionZZ _res_conv = *(LDKCOption_C2Tuple_usizeTransactionZZ*)(_res_ptr);
12746         FREE((void*)_res);
12747         COption_C2Tuple_usizeTransactionZZ_free(_res_conv);
12748 }
12749
12750 static inline uint64_t COption_C2Tuple_usizeTransactionZZ_clone_ptr(LDKCOption_C2Tuple_usizeTransactionZZ *NONNULL_PTR arg) {
12751         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12752         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(arg);
12753 uint64_t ret_ref = (uint64_t)ret_copy;
12754         return ret_ref;
12755 }
12756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12757         LDKCOption_C2Tuple_usizeTransactionZZ* arg_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)arg;
12758         int64_t ret_val = COption_C2Tuple_usizeTransactionZZ_clone_ptr(arg_conv);
12759         return ret_val;
12760 }
12761
12762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1C2Tuple_1usizeTransactionZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12763         LDKCOption_C2Tuple_usizeTransactionZZ* orig_conv = (LDKCOption_C2Tuple_usizeTransactionZZ*)orig;
12764         LDKCOption_C2Tuple_usizeTransactionZZ *ret_copy = MALLOC(sizeof(LDKCOption_C2Tuple_usizeTransactionZZ), "LDKCOption_C2Tuple_usizeTransactionZZ");
12765         *ret_copy = COption_C2Tuple_usizeTransactionZZ_clone(orig_conv);
12766         uint64_t ret_ref = (uint64_t)ret_copy;
12767         return ret_ref;
12768 }
12769
12770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12771         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12772         CHECK_ACCESS(o_ptr);
12773         LDKClosureReason o_conv = *(LDKClosureReason*)(o_ptr);
12774         o_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)o) & ~1));
12775         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12776         *ret_copy = COption_ClosureReasonZ_some(o_conv);
12777         uint64_t ret_ref = (uint64_t)ret_copy;
12778         return ret_ref;
12779 }
12780
12781 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1none(JNIEnv *env, jclass clz) {
12782         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12783         *ret_copy = COption_ClosureReasonZ_none();
12784         uint64_t ret_ref = (uint64_t)ret_copy;
12785         return ret_ref;
12786 }
12787
12788 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12789         if ((_res & 1) != 0) return;
12790         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12791         CHECK_ACCESS(_res_ptr);
12792         LDKCOption_ClosureReasonZ _res_conv = *(LDKCOption_ClosureReasonZ*)(_res_ptr);
12793         FREE((void*)_res);
12794         COption_ClosureReasonZ_free(_res_conv);
12795 }
12796
12797 static inline uint64_t COption_ClosureReasonZ_clone_ptr(LDKCOption_ClosureReasonZ *NONNULL_PTR arg) {
12798         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12799         *ret_copy = COption_ClosureReasonZ_clone(arg);
12800 uint64_t ret_ref = (uint64_t)ret_copy;
12801         return ret_ref;
12802 }
12803 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12804         LDKCOption_ClosureReasonZ* arg_conv = (LDKCOption_ClosureReasonZ*)arg;
12805         int64_t ret_val = COption_ClosureReasonZ_clone_ptr(arg_conv);
12806         return ret_val;
12807 }
12808
12809 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1ClosureReasonZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12810         LDKCOption_ClosureReasonZ* orig_conv = (LDKCOption_ClosureReasonZ*)orig;
12811         LDKCOption_ClosureReasonZ *ret_copy = MALLOC(sizeof(LDKCOption_ClosureReasonZ), "LDKCOption_ClosureReasonZ");
12812         *ret_copy = COption_ClosureReasonZ_clone(orig_conv);
12813         uint64_t ret_ref = (uint64_t)ret_copy;
12814         return ret_ref;
12815 }
12816
12817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12818         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12819         CHECK_ACCESS(o_ptr);
12820         LDKCOption_ClosureReasonZ o_conv = *(LDKCOption_ClosureReasonZ*)(o_ptr);
12821         o_conv = COption_ClosureReasonZ_clone((LDKCOption_ClosureReasonZ*)(((uint64_t)o) & ~1));
12822         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12823         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_ok(o_conv);
12824         return (uint64_t)ret_conv;
12825 }
12826
12827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12828         LDKDecodeError e_conv;
12829         e_conv.inner = (void*)(e & (~1));
12830         e_conv.is_owned = (e & 1) || (e == 0);
12831         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
12832         e_conv = DecodeError_clone(&e_conv);
12833         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12834         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_err(e_conv);
12835         return (uint64_t)ret_conv;
12836 }
12837
12838 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
12839         LDKCResult_COption_ClosureReasonZDecodeErrorZ* o_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(o & ~1);
12840         jboolean ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_is_ok(o_conv);
12841         return ret_val;
12842 }
12843
12844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12845         if ((_res & 1) != 0) return;
12846         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12847         CHECK_ACCESS(_res_ptr);
12848         LDKCResult_COption_ClosureReasonZDecodeErrorZ _res_conv = *(LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(_res_ptr);
12849         FREE((void*)_res);
12850         CResult_COption_ClosureReasonZDecodeErrorZ_free(_res_conv);
12851 }
12852
12853 static inline uint64_t CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(LDKCResult_COption_ClosureReasonZDecodeErrorZ *NONNULL_PTR arg) {
12854         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12855         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(arg);
12856         return (uint64_t)ret_conv;
12857 }
12858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12859         LDKCResult_COption_ClosureReasonZDecodeErrorZ* arg_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(arg & ~1);
12860         int64_t ret_val = CResult_COption_ClosureReasonZDecodeErrorZ_clone_ptr(arg_conv);
12861         return ret_val;
12862 }
12863
12864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1ClosureReasonZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12865         LDKCResult_COption_ClosureReasonZDecodeErrorZ* orig_conv = (LDKCResult_COption_ClosureReasonZDecodeErrorZ*)(orig & ~1);
12866         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
12867         *ret_conv = CResult_COption_ClosureReasonZDecodeErrorZ_clone(orig_conv);
12868         return (uint64_t)ret_conv;
12869 }
12870
12871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12872         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12873         CHECK_ACCESS(o_ptr);
12874         LDKNetworkUpdate o_conv = *(LDKNetworkUpdate*)(o_ptr);
12875         o_conv = NetworkUpdate_clone((LDKNetworkUpdate*)(((uint64_t)o) & ~1));
12876         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12877         *ret_copy = COption_NetworkUpdateZ_some(o_conv);
12878         uint64_t ret_ref = (uint64_t)ret_copy;
12879         return ret_ref;
12880 }
12881
12882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1none(JNIEnv *env, jclass clz) {
12883         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12884         *ret_copy = COption_NetworkUpdateZ_none();
12885         uint64_t ret_ref = (uint64_t)ret_copy;
12886         return ret_ref;
12887 }
12888
12889 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12890         if ((_res & 1) != 0) return;
12891         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12892         CHECK_ACCESS(_res_ptr);
12893         LDKCOption_NetworkUpdateZ _res_conv = *(LDKCOption_NetworkUpdateZ*)(_res_ptr);
12894         FREE((void*)_res);
12895         COption_NetworkUpdateZ_free(_res_conv);
12896 }
12897
12898 static inline uint64_t COption_NetworkUpdateZ_clone_ptr(LDKCOption_NetworkUpdateZ *NONNULL_PTR arg) {
12899         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12900         *ret_copy = COption_NetworkUpdateZ_clone(arg);
12901 uint64_t ret_ref = (uint64_t)ret_copy;
12902         return ret_ref;
12903 }
12904 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12905         LDKCOption_NetworkUpdateZ* arg_conv = (LDKCOption_NetworkUpdateZ*)arg;
12906         int64_t ret_val = COption_NetworkUpdateZ_clone_ptr(arg_conv);
12907         return ret_val;
12908 }
12909
12910 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1NetworkUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12911         LDKCOption_NetworkUpdateZ* orig_conv = (LDKCOption_NetworkUpdateZ*)orig;
12912         LDKCOption_NetworkUpdateZ *ret_copy = MALLOC(sizeof(LDKCOption_NetworkUpdateZ), "LDKCOption_NetworkUpdateZ");
12913         *ret_copy = COption_NetworkUpdateZ_clone(orig_conv);
12914         uint64_t ret_ref = (uint64_t)ret_copy;
12915         return ret_ref;
12916 }
12917
12918 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1SpendableOutputDescriptorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
12919         LDKCVec_SpendableOutputDescriptorZ _res_constr;
12920         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
12921         if (_res_constr.datalen > 0)
12922                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
12923         else
12924                 _res_constr.data = NULL;
12925         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
12926         for (size_t b = 0; b < _res_constr.datalen; b++) {
12927                 int64_t _res_conv_27 = _res_vals[b];
12928                 void* _res_conv_27_ptr = (void*)(((uint64_t)_res_conv_27) & ~1);
12929                 CHECK_ACCESS(_res_conv_27_ptr);
12930                 LDKSpendableOutputDescriptor _res_conv_27_conv = *(LDKSpendableOutputDescriptor*)(_res_conv_27_ptr);
12931                 FREE((void*)_res_conv_27);
12932                 _res_constr.data[b] = _res_conv_27_conv;
12933         }
12934         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
12935         CVec_SpendableOutputDescriptorZ_free(_res_constr);
12936 }
12937
12938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
12939         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12940         CHECK_ACCESS(o_ptr);
12941         LDKEvent o_conv = *(LDKEvent*)(o_ptr);
12942         o_conv = Event_clone((LDKEvent*)(((uint64_t)o) & ~1));
12943         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12944         *ret_copy = COption_EventZ_some(o_conv);
12945         uint64_t ret_ref = (uint64_t)ret_copy;
12946         return ret_ref;
12947 }
12948
12949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1none(JNIEnv *env, jclass clz) {
12950         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12951         *ret_copy = COption_EventZ_none();
12952         uint64_t ret_ref = (uint64_t)ret_copy;
12953         return ret_ref;
12954 }
12955
12956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
12957         if ((_res & 1) != 0) return;
12958         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
12959         CHECK_ACCESS(_res_ptr);
12960         LDKCOption_EventZ _res_conv = *(LDKCOption_EventZ*)(_res_ptr);
12961         FREE((void*)_res);
12962         COption_EventZ_free(_res_conv);
12963 }
12964
12965 static inline uint64_t COption_EventZ_clone_ptr(LDKCOption_EventZ *NONNULL_PTR arg) {
12966         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12967         *ret_copy = COption_EventZ_clone(arg);
12968 uint64_t ret_ref = (uint64_t)ret_copy;
12969         return ret_ref;
12970 }
12971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
12972         LDKCOption_EventZ* arg_conv = (LDKCOption_EventZ*)arg;
12973         int64_t ret_val = COption_EventZ_clone_ptr(arg_conv);
12974         return ret_val;
12975 }
12976
12977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1EventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
12978         LDKCOption_EventZ* orig_conv = (LDKCOption_EventZ*)orig;
12979         LDKCOption_EventZ *ret_copy = MALLOC(sizeof(LDKCOption_EventZ), "LDKCOption_EventZ");
12980         *ret_copy = COption_EventZ_clone(orig_conv);
12981         uint64_t ret_ref = (uint64_t)ret_copy;
12982         return ret_ref;
12983 }
12984
12985 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
12986         void* o_ptr = (void*)(((uint64_t)o) & ~1);
12987         CHECK_ACCESS(o_ptr);
12988         LDKCOption_EventZ o_conv = *(LDKCOption_EventZ*)(o_ptr);
12989         o_conv = COption_EventZ_clone((LDKCOption_EventZ*)(((uint64_t)o) & ~1));
12990         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
12991         *ret_conv = CResult_COption_EventZDecodeErrorZ_ok(o_conv);
12992         return (uint64_t)ret_conv;
12993 }
12994
12995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
12996         LDKDecodeError e_conv;
12997         e_conv.inner = (void*)(e & (~1));
12998         e_conv.is_owned = (e & 1) || (e == 0);
12999         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13000         e_conv = DecodeError_clone(&e_conv);
13001         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13002         *ret_conv = CResult_COption_EventZDecodeErrorZ_err(e_conv);
13003         return (uint64_t)ret_conv;
13004 }
13005
13006 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13007         LDKCResult_COption_EventZDecodeErrorZ* o_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(o & ~1);
13008         jboolean ret_val = CResult_COption_EventZDecodeErrorZ_is_ok(o_conv);
13009         return ret_val;
13010 }
13011
13012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13013         if ((_res & 1) != 0) return;
13014         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13015         CHECK_ACCESS(_res_ptr);
13016         LDKCResult_COption_EventZDecodeErrorZ _res_conv = *(LDKCResult_COption_EventZDecodeErrorZ*)(_res_ptr);
13017         FREE((void*)_res);
13018         CResult_COption_EventZDecodeErrorZ_free(_res_conv);
13019 }
13020
13021 static inline uint64_t CResult_COption_EventZDecodeErrorZ_clone_ptr(LDKCResult_COption_EventZDecodeErrorZ *NONNULL_PTR arg) {
13022         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13023         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(arg);
13024         return (uint64_t)ret_conv;
13025 }
13026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13027         LDKCResult_COption_EventZDecodeErrorZ* arg_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(arg & ~1);
13028         int64_t ret_val = CResult_COption_EventZDecodeErrorZ_clone_ptr(arg_conv);
13029         return ret_val;
13030 }
13031
13032 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1EventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13033         LDKCResult_COption_EventZDecodeErrorZ* orig_conv = (LDKCResult_COption_EventZDecodeErrorZ*)(orig & ~1);
13034         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
13035         *ret_conv = CResult_COption_EventZDecodeErrorZ_clone(orig_conv);
13036         return (uint64_t)ret_conv;
13037 }
13038
13039 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1MessageSendEventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13040         LDKCVec_MessageSendEventZ _res_constr;
13041         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13042         if (_res_constr.datalen > 0)
13043                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKMessageSendEvent), "LDKCVec_MessageSendEventZ Elements");
13044         else
13045                 _res_constr.data = NULL;
13046         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13047         for (size_t s = 0; s < _res_constr.datalen; s++) {
13048                 int64_t _res_conv_18 = _res_vals[s];
13049                 void* _res_conv_18_ptr = (void*)(((uint64_t)_res_conv_18) & ~1);
13050                 CHECK_ACCESS(_res_conv_18_ptr);
13051                 LDKMessageSendEvent _res_conv_18_conv = *(LDKMessageSendEvent*)(_res_conv_18_ptr);
13052                 FREE((void*)_res_conv_18);
13053                 _res_constr.data[s] = _res_conv_18_conv;
13054         }
13055         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13056         CVec_MessageSendEventZ_free(_res_constr);
13057 }
13058
13059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13060         LDKInitFeatures o_conv;
13061         o_conv.inner = (void*)(o & (~1));
13062         o_conv.is_owned = (o & 1) || (o == 0);
13063         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13064         o_conv = InitFeatures_clone(&o_conv);
13065         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13066         *ret_conv = CResult_InitFeaturesDecodeErrorZ_ok(o_conv);
13067         return (uint64_t)ret_conv;
13068 }
13069
13070 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13071         LDKDecodeError e_conv;
13072         e_conv.inner = (void*)(e & (~1));
13073         e_conv.is_owned = (e & 1) || (e == 0);
13074         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13075         e_conv = DecodeError_clone(&e_conv);
13076         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
13077         *ret_conv = CResult_InitFeaturesDecodeErrorZ_err(e_conv);
13078         return (uint64_t)ret_conv;
13079 }
13080
13081 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13082         LDKCResult_InitFeaturesDecodeErrorZ* o_conv = (LDKCResult_InitFeaturesDecodeErrorZ*)(o & ~1);
13083         jboolean ret_val = CResult_InitFeaturesDecodeErrorZ_is_ok(o_conv);
13084         return ret_val;
13085 }
13086
13087 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13088         if ((_res & 1) != 0) return;
13089         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13090         CHECK_ACCESS(_res_ptr);
13091         LDKCResult_InitFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InitFeaturesDecodeErrorZ*)(_res_ptr);
13092         FREE((void*)_res);
13093         CResult_InitFeaturesDecodeErrorZ_free(_res_conv);
13094 }
13095
13096 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13097         LDKNodeFeatures o_conv;
13098         o_conv.inner = (void*)(o & (~1));
13099         o_conv.is_owned = (o & 1) || (o == 0);
13100         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13101         o_conv = NodeFeatures_clone(&o_conv);
13102         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13103         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_ok(o_conv);
13104         return (uint64_t)ret_conv;
13105 }
13106
13107 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13108         LDKDecodeError e_conv;
13109         e_conv.inner = (void*)(e & (~1));
13110         e_conv.is_owned = (e & 1) || (e == 0);
13111         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13112         e_conv = DecodeError_clone(&e_conv);
13113         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
13114         *ret_conv = CResult_NodeFeaturesDecodeErrorZ_err(e_conv);
13115         return (uint64_t)ret_conv;
13116 }
13117
13118 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13119         LDKCResult_NodeFeaturesDecodeErrorZ* o_conv = (LDKCResult_NodeFeaturesDecodeErrorZ*)(o & ~1);
13120         jboolean ret_val = CResult_NodeFeaturesDecodeErrorZ_is_ok(o_conv);
13121         return ret_val;
13122 }
13123
13124 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13125         if ((_res & 1) != 0) return;
13126         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13127         CHECK_ACCESS(_res_ptr);
13128         LDKCResult_NodeFeaturesDecodeErrorZ _res_conv = *(LDKCResult_NodeFeaturesDecodeErrorZ*)(_res_ptr);
13129         FREE((void*)_res);
13130         CResult_NodeFeaturesDecodeErrorZ_free(_res_conv);
13131 }
13132
13133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13134         LDKChannelFeatures o_conv;
13135         o_conv.inner = (void*)(o & (~1));
13136         o_conv.is_owned = (o & 1) || (o == 0);
13137         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13138         o_conv = ChannelFeatures_clone(&o_conv);
13139         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13140         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_ok(o_conv);
13141         return (uint64_t)ret_conv;
13142 }
13143
13144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13145         LDKDecodeError e_conv;
13146         e_conv.inner = (void*)(e & (~1));
13147         e_conv.is_owned = (e & 1) || (e == 0);
13148         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13149         e_conv = DecodeError_clone(&e_conv);
13150         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
13151         *ret_conv = CResult_ChannelFeaturesDecodeErrorZ_err(e_conv);
13152         return (uint64_t)ret_conv;
13153 }
13154
13155 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13156         LDKCResult_ChannelFeaturesDecodeErrorZ* o_conv = (LDKCResult_ChannelFeaturesDecodeErrorZ*)(o & ~1);
13157         jboolean ret_val = CResult_ChannelFeaturesDecodeErrorZ_is_ok(o_conv);
13158         return ret_val;
13159 }
13160
13161 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13162         if ((_res & 1) != 0) return;
13163         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13164         CHECK_ACCESS(_res_ptr);
13165         LDKCResult_ChannelFeaturesDecodeErrorZ _res_conv = *(LDKCResult_ChannelFeaturesDecodeErrorZ*)(_res_ptr);
13166         FREE((void*)_res);
13167         CResult_ChannelFeaturesDecodeErrorZ_free(_res_conv);
13168 }
13169
13170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13171         LDKInvoiceFeatures o_conv;
13172         o_conv.inner = (void*)(o & (~1));
13173         o_conv.is_owned = (o & 1) || (o == 0);
13174         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13175         o_conv = InvoiceFeatures_clone(&o_conv);
13176         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13177         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_ok(o_conv);
13178         return (uint64_t)ret_conv;
13179 }
13180
13181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13182         LDKDecodeError e_conv;
13183         e_conv.inner = (void*)(e & (~1));
13184         e_conv.is_owned = (e & 1) || (e == 0);
13185         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13186         e_conv = DecodeError_clone(&e_conv);
13187         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
13188         *ret_conv = CResult_InvoiceFeaturesDecodeErrorZ_err(e_conv);
13189         return (uint64_t)ret_conv;
13190 }
13191
13192 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13193         LDKCResult_InvoiceFeaturesDecodeErrorZ* o_conv = (LDKCResult_InvoiceFeaturesDecodeErrorZ*)(o & ~1);
13194         jboolean ret_val = CResult_InvoiceFeaturesDecodeErrorZ_is_ok(o_conv);
13195         return ret_val;
13196 }
13197
13198 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceFeaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13199         if ((_res & 1) != 0) return;
13200         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13201         CHECK_ACCESS(_res_ptr);
13202         LDKCResult_InvoiceFeaturesDecodeErrorZ _res_conv = *(LDKCResult_InvoiceFeaturesDecodeErrorZ*)(_res_ptr);
13203         FREE((void*)_res);
13204         CResult_InvoiceFeaturesDecodeErrorZ_free(_res_conv);
13205 }
13206
13207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13208         LDKScoringParameters o_conv;
13209         o_conv.inner = (void*)(o & (~1));
13210         o_conv.is_owned = (o & 1) || (o == 0);
13211         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13212         // Warning: we need a move here but no clone is available for LDKScoringParameters
13213         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
13214         *ret_conv = CResult_ScoringParametersDecodeErrorZ_ok(o_conv);
13215         return (uint64_t)ret_conv;
13216 }
13217
13218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13219         LDKDecodeError e_conv;
13220         e_conv.inner = (void*)(e & (~1));
13221         e_conv.is_owned = (e & 1) || (e == 0);
13222         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13223         e_conv = DecodeError_clone(&e_conv);
13224         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
13225         *ret_conv = CResult_ScoringParametersDecodeErrorZ_err(e_conv);
13226         return (uint64_t)ret_conv;
13227 }
13228
13229 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13230         LDKCResult_ScoringParametersDecodeErrorZ* o_conv = (LDKCResult_ScoringParametersDecodeErrorZ*)(o & ~1);
13231         jboolean ret_val = CResult_ScoringParametersDecodeErrorZ_is_ok(o_conv);
13232         return ret_val;
13233 }
13234
13235 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScoringParametersDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13236         if ((_res & 1) != 0) return;
13237         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13238         CHECK_ACCESS(_res_ptr);
13239         LDKCResult_ScoringParametersDecodeErrorZ _res_conv = *(LDKCResult_ScoringParametersDecodeErrorZ*)(_res_ptr);
13240         FREE((void*)_res);
13241         CResult_ScoringParametersDecodeErrorZ_free(_res_conv);
13242 }
13243
13244 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13245         LDKScorer o_conv;
13246         o_conv.inner = (void*)(o & (~1));
13247         o_conv.is_owned = (o & 1) || (o == 0);
13248         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13249         // Warning: we need a move here but no clone is available for LDKScorer
13250         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
13251         *ret_conv = CResult_ScorerDecodeErrorZ_ok(o_conv);
13252         return (uint64_t)ret_conv;
13253 }
13254
13255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13256         LDKDecodeError e_conv;
13257         e_conv.inner = (void*)(e & (~1));
13258         e_conv.is_owned = (e & 1) || (e == 0);
13259         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13260         e_conv = DecodeError_clone(&e_conv);
13261         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
13262         *ret_conv = CResult_ScorerDecodeErrorZ_err(e_conv);
13263         return (uint64_t)ret_conv;
13264 }
13265
13266 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13267         LDKCResult_ScorerDecodeErrorZ* o_conv = (LDKCResult_ScorerDecodeErrorZ*)(o & ~1);
13268         jboolean ret_val = CResult_ScorerDecodeErrorZ_is_ok(o_conv);
13269         return ret_val;
13270 }
13271
13272 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ScorerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13273         if ((_res & 1) != 0) return;
13274         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13275         CHECK_ACCESS(_res_ptr);
13276         LDKCResult_ScorerDecodeErrorZ _res_conv = *(LDKCResult_ScorerDecodeErrorZ*)(_res_ptr);
13277         FREE((void*)_res);
13278         CResult_ScorerDecodeErrorZ_free(_res_conv);
13279 }
13280
13281 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13282         LDKDelayedPaymentOutputDescriptor o_conv;
13283         o_conv.inner = (void*)(o & (~1));
13284         o_conv.is_owned = (o & 1) || (o == 0);
13285         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13286         o_conv = DelayedPaymentOutputDescriptor_clone(&o_conv);
13287         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13288         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13289         return (uint64_t)ret_conv;
13290 }
13291
13292 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13293         LDKDecodeError e_conv;
13294         e_conv.inner = (void*)(e & (~1));
13295         e_conv.is_owned = (e & 1) || (e == 0);
13296         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13297         e_conv = DecodeError_clone(&e_conv);
13298         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13299         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13300         return (uint64_t)ret_conv;
13301 }
13302
13303 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13304         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13305         jboolean ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13306         return ret_val;
13307 }
13308
13309 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13310         if ((_res & 1) != 0) return;
13311         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13312         CHECK_ACCESS(_res_ptr);
13313         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13314         FREE((void*)_res);
13315         CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13316 }
13317
13318 static inline uint64_t CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13319         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13320         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13321         return (uint64_t)ret_conv;
13322 }
13323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13324         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13325         int64_t ret_val = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13326         return ret_val;
13327 }
13328
13329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DelayedPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13330         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13331         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
13332         *ret_conv = CResult_DelayedPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13333         return (uint64_t)ret_conv;
13334 }
13335
13336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13337         LDKStaticPaymentOutputDescriptor o_conv;
13338         o_conv.inner = (void*)(o & (~1));
13339         o_conv.is_owned = (o & 1) || (o == 0);
13340         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13341         o_conv = StaticPaymentOutputDescriptor_clone(&o_conv);
13342         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13343         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_ok(o_conv);
13344         return (uint64_t)ret_conv;
13345 }
13346
13347 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13348         LDKDecodeError e_conv;
13349         e_conv.inner = (void*)(e & (~1));
13350         e_conv.is_owned = (e & 1) || (e == 0);
13351         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13352         e_conv = DecodeError_clone(&e_conv);
13353         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13354         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_err(e_conv);
13355         return (uint64_t)ret_conv;
13356 }
13357
13358 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13359         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(o & ~1);
13360         jboolean ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13361         return ret_val;
13362 }
13363
13364 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13365         if ((_res & 1) != 0) return;
13366         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13367         CHECK_ACCESS(_res_ptr);
13368         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(_res_ptr);
13369         FREE((void*)_res);
13370         CResult_StaticPaymentOutputDescriptorDecodeErrorZ_free(_res_conv);
13371 }
13372
13373 static inline uint64_t CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13374         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13375         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(arg);
13376         return (uint64_t)ret_conv;
13377 }
13378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13379         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(arg & ~1);
13380         int64_t ret_val = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13381         return ret_val;
13382 }
13383
13384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StaticPaymentOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13385         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ*)(orig & ~1);
13386         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
13387         *ret_conv = CResult_StaticPaymentOutputDescriptorDecodeErrorZ_clone(orig_conv);
13388         return (uint64_t)ret_conv;
13389 }
13390
13391 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13392         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13393         CHECK_ACCESS(o_ptr);
13394         LDKSpendableOutputDescriptor o_conv = *(LDKSpendableOutputDescriptor*)(o_ptr);
13395         o_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)o) & ~1));
13396         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13397         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_ok(o_conv);
13398         return (uint64_t)ret_conv;
13399 }
13400
13401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13402         LDKDecodeError e_conv;
13403         e_conv.inner = (void*)(e & (~1));
13404         e_conv.is_owned = (e & 1) || (e == 0);
13405         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13406         e_conv = DecodeError_clone(&e_conv);
13407         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13408         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_err(e_conv);
13409         return (uint64_t)ret_conv;
13410 }
13411
13412 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13413         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* o_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(o & ~1);
13414         jboolean ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_is_ok(o_conv);
13415         return ret_val;
13416 }
13417
13418 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13419         if ((_res & 1) != 0) return;
13420         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13421         CHECK_ACCESS(_res_ptr);
13422         LDKCResult_SpendableOutputDescriptorDecodeErrorZ _res_conv = *(LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(_res_ptr);
13423         FREE((void*)_res);
13424         CResult_SpendableOutputDescriptorDecodeErrorZ_free(_res_conv);
13425 }
13426
13427 static inline uint64_t CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(LDKCResult_SpendableOutputDescriptorDecodeErrorZ *NONNULL_PTR arg) {
13428         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13429         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(arg);
13430         return (uint64_t)ret_conv;
13431 }
13432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13433         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* arg_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(arg & ~1);
13434         int64_t ret_val = CResult_SpendableOutputDescriptorDecodeErrorZ_clone_ptr(arg_conv);
13435         return ret_val;
13436 }
13437
13438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SpendableOutputDescriptorDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13439         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* orig_conv = (LDKCResult_SpendableOutputDescriptorDecodeErrorZ*)(orig & ~1);
13440         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
13441         *ret_conv = CResult_SpendableOutputDescriptorDecodeErrorZ_clone(orig_conv);
13442         return (uint64_t)ret_conv;
13443 }
13444
13445 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1ok(JNIEnv *env, jclass clz) {
13446         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13447         *ret_conv = CResult_NoneNoneZ_ok();
13448         return (uint64_t)ret_conv;
13449 }
13450
13451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1err(JNIEnv *env, jclass clz) {
13452         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13453         *ret_conv = CResult_NoneNoneZ_err();
13454         return (uint64_t)ret_conv;
13455 }
13456
13457 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13458         LDKCResult_NoneNoneZ* o_conv = (LDKCResult_NoneNoneZ*)(o & ~1);
13459         jboolean ret_val = CResult_NoneNoneZ_is_ok(o_conv);
13460         return ret_val;
13461 }
13462
13463 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13464         if ((_res & 1) != 0) return;
13465         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13466         CHECK_ACCESS(_res_ptr);
13467         LDKCResult_NoneNoneZ _res_conv = *(LDKCResult_NoneNoneZ*)(_res_ptr);
13468         FREE((void*)_res);
13469         CResult_NoneNoneZ_free(_res_conv);
13470 }
13471
13472 static inline uint64_t CResult_NoneNoneZ_clone_ptr(LDKCResult_NoneNoneZ *NONNULL_PTR arg) {
13473         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13474         *ret_conv = CResult_NoneNoneZ_clone(arg);
13475         return (uint64_t)ret_conv;
13476 }
13477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13478         LDKCResult_NoneNoneZ* arg_conv = (LDKCResult_NoneNoneZ*)(arg & ~1);
13479         int64_t ret_val = CResult_NoneNoneZ_clone_ptr(arg_conv);
13480         return ret_val;
13481 }
13482
13483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13484         LDKCResult_NoneNoneZ* orig_conv = (LDKCResult_NoneNoneZ*)(orig & ~1);
13485         LDKCResult_NoneNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneNoneZ), "LDKCResult_NoneNoneZ");
13486         *ret_conv = CResult_NoneNoneZ_clone(orig_conv);
13487         return (uint64_t)ret_conv;
13488 }
13489
13490 static inline uint64_t C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(LDKC2Tuple_SignatureCVec_SignatureZZ *NONNULL_PTR arg) {
13491         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13492         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(arg);
13493         return ((uint64_t)ret_conv);
13494 }
13495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13496         LDKC2Tuple_SignatureCVec_SignatureZZ* arg_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(arg & ~1);
13497         int64_t ret_val = C2Tuple_SignatureCVec_SignatureZZ_clone_ptr(arg_conv);
13498         return ret_val;
13499 }
13500
13501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13502         LDKC2Tuple_SignatureCVec_SignatureZZ* orig_conv = (LDKC2Tuple_SignatureCVec_SignatureZZ*)(orig & ~1);
13503         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13504         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_clone(orig_conv);
13505         return ((uint64_t)ret_conv);
13506 }
13507
13508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, jobjectArray b) {
13509         LDKSignature a_ref;
13510         CHECK((*env)->GetArrayLength(env, a) == 64);
13511         (*env)->GetByteArrayRegion(env, a, 0, 64, a_ref.compact_form);
13512         LDKCVec_SignatureZ b_constr;
13513         b_constr.datalen = (*env)->GetArrayLength(env, b);
13514         if (b_constr.datalen > 0)
13515                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
13516         else
13517                 b_constr.data = NULL;
13518         for (size_t i = 0; i < b_constr.datalen; i++) {
13519                 int8_tArray b_conv_8 = (*env)->GetObjectArrayElement(env, b, i);
13520                 LDKSignature b_conv_8_ref;
13521                 CHECK((*env)->GetArrayLength(env, b_conv_8) == 64);
13522                 (*env)->GetByteArrayRegion(env, b_conv_8, 0, 64, b_conv_8_ref.compact_form);
13523                 b_constr.data[i] = b_conv_8_ref;
13524         }
13525         LDKC2Tuple_SignatureCVec_SignatureZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_SignatureCVec_SignatureZZ), "LDKC2Tuple_SignatureCVec_SignatureZZ");
13526         *ret_conv = C2Tuple_SignatureCVec_SignatureZZ_new(a_ref, b_constr);
13527         return ((uint64_t)ret_conv);
13528 }
13529
13530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1SignatureCVec_1SignatureZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13531         if ((_res & 1) != 0) return;
13532         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13533         CHECK_ACCESS(_res_ptr);
13534         LDKC2Tuple_SignatureCVec_SignatureZZ _res_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(_res_ptr);
13535         FREE((void*)_res);
13536         C2Tuple_SignatureCVec_SignatureZZ_free(_res_conv);
13537 }
13538
13539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13540         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13541         CHECK_ACCESS(o_ptr);
13542         LDKC2Tuple_SignatureCVec_SignatureZZ o_conv = *(LDKC2Tuple_SignatureCVec_SignatureZZ*)(o_ptr);
13543         o_conv = C2Tuple_SignatureCVec_SignatureZZ_clone((LDKC2Tuple_SignatureCVec_SignatureZZ*)(((uint64_t)o) & ~1));
13544         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13545         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_ok(o_conv);
13546         return (uint64_t)ret_conv;
13547 }
13548
13549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1err(JNIEnv *env, jclass clz) {
13550         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13551         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_err();
13552         return (uint64_t)ret_conv;
13553 }
13554
13555 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13556         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* o_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(o & ~1);
13557         jboolean ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_is_ok(o_conv);
13558         return ret_val;
13559 }
13560
13561 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13562         if ((_res & 1) != 0) return;
13563         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13564         CHECK_ACCESS(_res_ptr);
13565         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ _res_conv = *(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(_res_ptr);
13566         FREE((void*)_res);
13567         CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_free(_res_conv);
13568 }
13569
13570 static inline uint64_t CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ *NONNULL_PTR arg) {
13571         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13572         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(arg);
13573         return (uint64_t)ret_conv;
13574 }
13575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13576         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* arg_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(arg & ~1);
13577         int64_t ret_val = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone_ptr(arg_conv);
13578         return ret_val;
13579 }
13580
13581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1SignatureCVec_1SignatureZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13582         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* orig_conv = (LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ*)(orig & ~1);
13583         LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ), "LDKCResult_C2Tuple_SignatureCVec_SignatureZZNoneZ");
13584         *ret_conv = CResult_C2Tuple_SignatureCVec_SignatureZZNoneZ_clone(orig_conv);
13585         return (uint64_t)ret_conv;
13586 }
13587
13588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13589         LDKSignature o_ref;
13590         CHECK((*env)->GetArrayLength(env, o) == 64);
13591         (*env)->GetByteArrayRegion(env, o, 0, 64, o_ref.compact_form);
13592         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13593         *ret_conv = CResult_SignatureNoneZ_ok(o_ref);
13594         return (uint64_t)ret_conv;
13595 }
13596
13597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1err(JNIEnv *env, jclass clz) {
13598         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13599         *ret_conv = CResult_SignatureNoneZ_err();
13600         return (uint64_t)ret_conv;
13601 }
13602
13603 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13604         LDKCResult_SignatureNoneZ* o_conv = (LDKCResult_SignatureNoneZ*)(o & ~1);
13605         jboolean ret_val = CResult_SignatureNoneZ_is_ok(o_conv);
13606         return ret_val;
13607 }
13608
13609 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13610         if ((_res & 1) != 0) return;
13611         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13612         CHECK_ACCESS(_res_ptr);
13613         LDKCResult_SignatureNoneZ _res_conv = *(LDKCResult_SignatureNoneZ*)(_res_ptr);
13614         FREE((void*)_res);
13615         CResult_SignatureNoneZ_free(_res_conv);
13616 }
13617
13618 static inline uint64_t CResult_SignatureNoneZ_clone_ptr(LDKCResult_SignatureNoneZ *NONNULL_PTR arg) {
13619         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13620         *ret_conv = CResult_SignatureNoneZ_clone(arg);
13621         return (uint64_t)ret_conv;
13622 }
13623 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13624         LDKCResult_SignatureNoneZ* arg_conv = (LDKCResult_SignatureNoneZ*)(arg & ~1);
13625         int64_t ret_val = CResult_SignatureNoneZ_clone_ptr(arg_conv);
13626         return ret_val;
13627 }
13628
13629 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13630         LDKCResult_SignatureNoneZ* orig_conv = (LDKCResult_SignatureNoneZ*)(orig & ~1);
13631         LDKCResult_SignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignatureNoneZ), "LDKCResult_SignatureNoneZ");
13632         *ret_conv = CResult_SignatureNoneZ_clone(orig_conv);
13633         return (uint64_t)ret_conv;
13634 }
13635
13636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13637         void* o_ptr = (void*)(((uint64_t)o) & ~1);
13638         CHECK_ACCESS(o_ptr);
13639         LDKSign o_conv = *(LDKSign*)(o_ptr);
13640         if (o_conv.free == LDKSign_JCalls_free) {
13641                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
13642                 LDKSign_JCalls_cloned(&o_conv);
13643         }
13644         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13645         *ret_conv = CResult_SignDecodeErrorZ_ok(o_conv);
13646         return (uint64_t)ret_conv;
13647 }
13648
13649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13650         LDKDecodeError e_conv;
13651         e_conv.inner = (void*)(e & (~1));
13652         e_conv.is_owned = (e & 1) || (e == 0);
13653         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13654         e_conv = DecodeError_clone(&e_conv);
13655         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13656         *ret_conv = CResult_SignDecodeErrorZ_err(e_conv);
13657         return (uint64_t)ret_conv;
13658 }
13659
13660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13661         LDKCResult_SignDecodeErrorZ* o_conv = (LDKCResult_SignDecodeErrorZ*)(o & ~1);
13662         jboolean ret_val = CResult_SignDecodeErrorZ_is_ok(o_conv);
13663         return ret_val;
13664 }
13665
13666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13667         if ((_res & 1) != 0) return;
13668         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13669         CHECK_ACCESS(_res_ptr);
13670         LDKCResult_SignDecodeErrorZ _res_conv = *(LDKCResult_SignDecodeErrorZ*)(_res_ptr);
13671         FREE((void*)_res);
13672         CResult_SignDecodeErrorZ_free(_res_conv);
13673 }
13674
13675 static inline uint64_t CResult_SignDecodeErrorZ_clone_ptr(LDKCResult_SignDecodeErrorZ *NONNULL_PTR arg) {
13676         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13677         *ret_conv = CResult_SignDecodeErrorZ_clone(arg);
13678         return (uint64_t)ret_conv;
13679 }
13680 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13681         LDKCResult_SignDecodeErrorZ* arg_conv = (LDKCResult_SignDecodeErrorZ*)(arg & ~1);
13682         int64_t ret_val = CResult_SignDecodeErrorZ_clone_ptr(arg_conv);
13683         return ret_val;
13684 }
13685
13686 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13687         LDKCResult_SignDecodeErrorZ* orig_conv = (LDKCResult_SignDecodeErrorZ*)(orig & ~1);
13688         LDKCResult_SignDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SignDecodeErrorZ), "LDKCResult_SignDecodeErrorZ");
13689         *ret_conv = CResult_SignDecodeErrorZ_clone(orig_conv);
13690         return (uint64_t)ret_conv;
13691 }
13692
13693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u8Z_1free(JNIEnv *env, jclass clz, int8_tArray _res) {
13694         LDKCVec_u8Z _res_ref;
13695         _res_ref.datalen = (*env)->GetArrayLength(env, _res);
13696         _res_ref.data = MALLOC(_res_ref.datalen, "LDKCVec_u8Z Bytes");
13697         (*env)->GetByteArrayRegion(env, _res, 0, _res_ref.datalen, _res_ref.data);
13698         CVec_u8Z_free(_res_ref);
13699 }
13700
13701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray arg) {
13702         LDKRecoverableSignature arg_ref;
13703         CHECK((*env)->GetArrayLength(env, arg) == 68);
13704         (*env)->GetByteArrayRegion(env, arg, 0, 68, arg_ref.serialized_form);
13705         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13706         *ret_conv = CResult_RecoverableSignatureNoneZ_ok(arg_ref);
13707         return (uint64_t)ret_conv;
13708 }
13709
13710 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1err(JNIEnv *env, jclass clz) {
13711         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13712         *ret_conv = CResult_RecoverableSignatureNoneZ_err();
13713         return (uint64_t)ret_conv;
13714 }
13715
13716 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13717         LDKCResult_RecoverableSignatureNoneZ* o_conv = (LDKCResult_RecoverableSignatureNoneZ*)(o & ~1);
13718         jboolean ret_val = CResult_RecoverableSignatureNoneZ_is_ok(o_conv);
13719         return ret_val;
13720 }
13721
13722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13723         if ((_res & 1) != 0) return;
13724         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13725         CHECK_ACCESS(_res_ptr);
13726         LDKCResult_RecoverableSignatureNoneZ _res_conv = *(LDKCResult_RecoverableSignatureNoneZ*)(_res_ptr);
13727         FREE((void*)_res);
13728         CResult_RecoverableSignatureNoneZ_free(_res_conv);
13729 }
13730
13731 static inline uint64_t CResult_RecoverableSignatureNoneZ_clone_ptr(LDKCResult_RecoverableSignatureNoneZ *NONNULL_PTR arg) {
13732         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13733         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(arg);
13734         return (uint64_t)ret_conv;
13735 }
13736 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13737         LDKCResult_RecoverableSignatureNoneZ* arg_conv = (LDKCResult_RecoverableSignatureNoneZ*)(arg & ~1);
13738         int64_t ret_val = CResult_RecoverableSignatureNoneZ_clone_ptr(arg_conv);
13739         return ret_val;
13740 }
13741
13742 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RecoverableSignatureNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13743         LDKCResult_RecoverableSignatureNoneZ* orig_conv = (LDKCResult_RecoverableSignatureNoneZ*)(orig & ~1);
13744         LDKCResult_RecoverableSignatureNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_RecoverableSignatureNoneZ), "LDKCResult_RecoverableSignatureNoneZ");
13745         *ret_conv = CResult_RecoverableSignatureNoneZ_clone(orig_conv);
13746         return (uint64_t)ret_conv;
13747 }
13748
13749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CVec_1u8ZZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
13750         LDKCVec_CVec_u8ZZ _res_constr;
13751         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13752         if (_res_constr.datalen > 0)
13753                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13754         else
13755                 _res_constr.data = NULL;
13756         for (size_t i = 0; i < _res_constr.datalen; i++) {
13757                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
13758                 LDKCVec_u8Z _res_conv_8_ref;
13759                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
13760                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
13761                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
13762                 _res_constr.data[i] = _res_conv_8_ref;
13763         }
13764         CVec_CVec_u8ZZ_free(_res_constr);
13765 }
13766
13767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1ok(JNIEnv *env, jclass clz, jobjectArray o) {
13768         LDKCVec_CVec_u8ZZ o_constr;
13769         o_constr.datalen = (*env)->GetArrayLength(env, o);
13770         if (o_constr.datalen > 0)
13771                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKCVec_u8Z), "LDKCVec_CVec_u8ZZ Elements");
13772         else
13773                 o_constr.data = NULL;
13774         for (size_t i = 0; i < o_constr.datalen; i++) {
13775                 int8_tArray o_conv_8 = (*env)->GetObjectArrayElement(env, o, i);
13776                 LDKCVec_u8Z o_conv_8_ref;
13777                 o_conv_8_ref.datalen = (*env)->GetArrayLength(env, o_conv_8);
13778                 o_conv_8_ref.data = MALLOC(o_conv_8_ref.datalen, "LDKCVec_u8Z Bytes");
13779                 (*env)->GetByteArrayRegion(env, o_conv_8, 0, o_conv_8_ref.datalen, o_conv_8_ref.data);
13780                 o_constr.data[i] = o_conv_8_ref;
13781         }
13782         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13783         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_ok(o_constr);
13784         return (uint64_t)ret_conv;
13785 }
13786
13787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1err(JNIEnv *env, jclass clz) {
13788         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13789         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_err();
13790         return (uint64_t)ret_conv;
13791 }
13792
13793 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13794         LDKCResult_CVec_CVec_u8ZZNoneZ* o_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(o & ~1);
13795         jboolean ret_val = CResult_CVec_CVec_u8ZZNoneZ_is_ok(o_conv);
13796         return ret_val;
13797 }
13798
13799 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13800         if ((_res & 1) != 0) return;
13801         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13802         CHECK_ACCESS(_res_ptr);
13803         LDKCResult_CVec_CVec_u8ZZNoneZ _res_conv = *(LDKCResult_CVec_CVec_u8ZZNoneZ*)(_res_ptr);
13804         FREE((void*)_res);
13805         CResult_CVec_CVec_u8ZZNoneZ_free(_res_conv);
13806 }
13807
13808 static inline uint64_t CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(LDKCResult_CVec_CVec_u8ZZNoneZ *NONNULL_PTR arg) {
13809         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13810         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(arg);
13811         return (uint64_t)ret_conv;
13812 }
13813 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13814         LDKCResult_CVec_CVec_u8ZZNoneZ* arg_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(arg & ~1);
13815         int64_t ret_val = CResult_CVec_CVec_u8ZZNoneZ_clone_ptr(arg_conv);
13816         return ret_val;
13817 }
13818
13819 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1CVec_1u8ZZNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13820         LDKCResult_CVec_CVec_u8ZZNoneZ* orig_conv = (LDKCResult_CVec_CVec_u8ZZNoneZ*)(orig & ~1);
13821         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
13822         *ret_conv = CResult_CVec_CVec_u8ZZNoneZ_clone(orig_conv);
13823         return (uint64_t)ret_conv;
13824 }
13825
13826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
13827         LDKInMemorySigner o_conv;
13828         o_conv.inner = (void*)(o & (~1));
13829         o_conv.is_owned = (o & 1) || (o == 0);
13830         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
13831         o_conv = InMemorySigner_clone(&o_conv);
13832         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13833         *ret_conv = CResult_InMemorySignerDecodeErrorZ_ok(o_conv);
13834         return (uint64_t)ret_conv;
13835 }
13836
13837 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
13838         LDKDecodeError e_conv;
13839         e_conv.inner = (void*)(e & (~1));
13840         e_conv.is_owned = (e & 1) || (e == 0);
13841         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
13842         e_conv = DecodeError_clone(&e_conv);
13843         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13844         *ret_conv = CResult_InMemorySignerDecodeErrorZ_err(e_conv);
13845         return (uint64_t)ret_conv;
13846 }
13847
13848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13849         LDKCResult_InMemorySignerDecodeErrorZ* o_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(o & ~1);
13850         jboolean ret_val = CResult_InMemorySignerDecodeErrorZ_is_ok(o_conv);
13851         return ret_val;
13852 }
13853
13854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13855         if ((_res & 1) != 0) return;
13856         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13857         CHECK_ACCESS(_res_ptr);
13858         LDKCResult_InMemorySignerDecodeErrorZ _res_conv = *(LDKCResult_InMemorySignerDecodeErrorZ*)(_res_ptr);
13859         FREE((void*)_res);
13860         CResult_InMemorySignerDecodeErrorZ_free(_res_conv);
13861 }
13862
13863 static inline uint64_t CResult_InMemorySignerDecodeErrorZ_clone_ptr(LDKCResult_InMemorySignerDecodeErrorZ *NONNULL_PTR arg) {
13864         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13865         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(arg);
13866         return (uint64_t)ret_conv;
13867 }
13868 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13869         LDKCResult_InMemorySignerDecodeErrorZ* arg_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(arg & ~1);
13870         int64_t ret_val = CResult_InMemorySignerDecodeErrorZ_clone_ptr(arg_conv);
13871         return ret_val;
13872 }
13873
13874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InMemorySignerDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13875         LDKCResult_InMemorySignerDecodeErrorZ* orig_conv = (LDKCResult_InMemorySignerDecodeErrorZ*)(orig & ~1);
13876         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
13877         *ret_conv = CResult_InMemorySignerDecodeErrorZ_clone(orig_conv);
13878         return (uint64_t)ret_conv;
13879 }
13880
13881 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TxOutZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13882         LDKCVec_TxOutZ _res_constr;
13883         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13884         if (_res_constr.datalen > 0)
13885                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
13886         else
13887                 _res_constr.data = NULL;
13888         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
13889         for (size_t h = 0; h < _res_constr.datalen; h++) {
13890                 int64_t _res_conv_7 = _res_vals[h];
13891                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
13892                 CHECK_ACCESS(_res_conv_7_ptr);
13893                 LDKTxOut _res_conv_7_conv = *(LDKTxOut*)(_res_conv_7_ptr);
13894                 FREE((void*)_res_conv_7);
13895                 _res_constr.data[h] = _res_conv_7_conv;
13896         }
13897         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
13898         CVec_TxOutZ_free(_res_constr);
13899 }
13900
13901 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
13902         LDKTransaction o_ref;
13903         o_ref.datalen = (*env)->GetArrayLength(env, o);
13904         o_ref.data = MALLOC(o_ref.datalen, "LDKTransaction Bytes");
13905         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
13906         o_ref.data_is_owned = true;
13907         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13908         *ret_conv = CResult_TransactionNoneZ_ok(o_ref);
13909         return (uint64_t)ret_conv;
13910 }
13911
13912 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1err(JNIEnv *env, jclass clz) {
13913         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13914         *ret_conv = CResult_TransactionNoneZ_err();
13915         return (uint64_t)ret_conv;
13916 }
13917
13918 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
13919         LDKCResult_TransactionNoneZ* o_conv = (LDKCResult_TransactionNoneZ*)(o & ~1);
13920         jboolean ret_val = CResult_TransactionNoneZ_is_ok(o_conv);
13921         return ret_val;
13922 }
13923
13924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13925         if ((_res & 1) != 0) return;
13926         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13927         CHECK_ACCESS(_res_ptr);
13928         LDKCResult_TransactionNoneZ _res_conv = *(LDKCResult_TransactionNoneZ*)(_res_ptr);
13929         FREE((void*)_res);
13930         CResult_TransactionNoneZ_free(_res_conv);
13931 }
13932
13933 static inline uint64_t CResult_TransactionNoneZ_clone_ptr(LDKCResult_TransactionNoneZ *NONNULL_PTR arg) {
13934         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13935         *ret_conv = CResult_TransactionNoneZ_clone(arg);
13936         return (uint64_t)ret_conv;
13937 }
13938 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13939         LDKCResult_TransactionNoneZ* arg_conv = (LDKCResult_TransactionNoneZ*)(arg & ~1);
13940         int64_t ret_val = CResult_TransactionNoneZ_clone_ptr(arg_conv);
13941         return ret_val;
13942 }
13943
13944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1TransactionNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13945         LDKCResult_TransactionNoneZ* orig_conv = (LDKCResult_TransactionNoneZ*)(orig & ~1);
13946         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
13947         *ret_conv = CResult_TransactionNoneZ_clone(orig_conv);
13948         return (uint64_t)ret_conv;
13949 }
13950
13951 static inline uint64_t C2Tuple_BlockHashChannelMonitorZ_clone_ptr(LDKC2Tuple_BlockHashChannelMonitorZ *NONNULL_PTR arg) {
13952         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
13953         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(arg);
13954         return ((uint64_t)ret_conv);
13955 }
13956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
13957         LDKC2Tuple_BlockHashChannelMonitorZ* arg_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(arg & ~1);
13958         int64_t ret_val = C2Tuple_BlockHashChannelMonitorZ_clone_ptr(arg_conv);
13959         return ret_val;
13960 }
13961
13962 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
13963         LDKC2Tuple_BlockHashChannelMonitorZ* orig_conv = (LDKC2Tuple_BlockHashChannelMonitorZ*)(orig & ~1);
13964         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
13965         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_clone(orig_conv);
13966         return ((uint64_t)ret_conv);
13967 }
13968
13969 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
13970         LDKThirtyTwoBytes a_ref;
13971         CHECK((*env)->GetArrayLength(env, a) == 32);
13972         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
13973         LDKChannelMonitor b_conv;
13974         b_conv.inner = (void*)(b & (~1));
13975         b_conv.is_owned = (b & 1) || (b == 0);
13976         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
13977         b_conv = ChannelMonitor_clone(&b_conv);
13978         LDKC2Tuple_BlockHashChannelMonitorZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKC2Tuple_BlockHashChannelMonitorZ");
13979         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_new(a_ref, b_conv);
13980         return ((uint64_t)ret_conv);
13981 }
13982
13983 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
13984         if ((_res & 1) != 0) return;
13985         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
13986         CHECK_ACCESS(_res_ptr);
13987         LDKC2Tuple_BlockHashChannelMonitorZ _res_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_ptr);
13988         FREE((void*)_res);
13989         C2Tuple_BlockHashChannelMonitorZ_free(_res_conv);
13990 }
13991
13992 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1BlockHashChannelMonitorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
13993         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ _res_constr;
13994         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
13995         if (_res_constr.datalen > 0)
13996                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
13997         else
13998                 _res_constr.data = NULL;
13999         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14000         for (size_t j = 0; j < _res_constr.datalen; j++) {
14001                 int64_t _res_conv_35 = _res_vals[j];
14002                 void* _res_conv_35_ptr = (void*)(((uint64_t)_res_conv_35) & ~1);
14003                 CHECK_ACCESS(_res_conv_35_ptr);
14004                 LDKC2Tuple_BlockHashChannelMonitorZ _res_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(_res_conv_35_ptr);
14005                 FREE((void*)_res_conv_35);
14006                 _res_constr.data[j] = _res_conv_35_conv;
14007         }
14008         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14009         CVec_C2Tuple_BlockHashChannelMonitorZZ_free(_res_constr);
14010 }
14011
14012 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1ok(JNIEnv *env, jclass clz, int64_tArray o) {
14013         LDKCVec_C2Tuple_BlockHashChannelMonitorZZ o_constr;
14014         o_constr.datalen = (*env)->GetArrayLength(env, o);
14015         if (o_constr.datalen > 0)
14016                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKC2Tuple_BlockHashChannelMonitorZ), "LDKCVec_C2Tuple_BlockHashChannelMonitorZZ Elements");
14017         else
14018                 o_constr.data = NULL;
14019         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
14020         for (size_t j = 0; j < o_constr.datalen; j++) {
14021                 int64_t o_conv_35 = o_vals[j];
14022                 void* o_conv_35_ptr = (void*)(((uint64_t)o_conv_35) & ~1);
14023                 CHECK_ACCESS(o_conv_35_ptr);
14024                 LDKC2Tuple_BlockHashChannelMonitorZ o_conv_35_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_conv_35_ptr);
14025                 o_conv_35_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o_conv_35) & ~1));
14026                 o_constr.data[j] = o_conv_35_conv;
14027         }
14028         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
14029         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14030         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_ok(o_constr);
14031         return (uint64_t)ret_conv;
14032 }
14033
14034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
14035         LDKIOError e_conv = LDKIOError_from_java(env, e);
14036         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14037         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_err(e_conv);
14038         return (uint64_t)ret_conv;
14039 }
14040
14041 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14042         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* o_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(o & ~1);
14043         jboolean ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_is_ok(o_conv);
14044         return ret_val;
14045 }
14046
14047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14048         if ((_res & 1) != 0) return;
14049         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14050         CHECK_ACCESS(_res_ptr);
14051         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ _res_conv = *(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(_res_ptr);
14052         FREE((void*)_res);
14053         CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_free(_res_conv);
14054 }
14055
14056 static inline uint64_t CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ *NONNULL_PTR arg) {
14057         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14058         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(arg);
14059         return (uint64_t)ret_conv;
14060 }
14061 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14062         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* arg_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(arg & ~1);
14063         int64_t ret_val = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone_ptr(arg_conv);
14064         return ret_val;
14065 }
14066
14067 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1C2Tuple_1BlockHashChannelMonitorZZErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14068         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* orig_conv = (LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ*)(orig & ~1);
14069         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
14070         *ret_conv = CResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ_clone(orig_conv);
14071         return (uint64_t)ret_conv;
14072 }
14073
14074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1some(JNIEnv *env, jclass clz, int16_t o) {
14075         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14076         *ret_copy = COption_u16Z_some(o);
14077         uint64_t ret_ref = (uint64_t)ret_copy;
14078         return ret_ref;
14079 }
14080
14081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1none(JNIEnv *env, jclass clz) {
14082         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14083         *ret_copy = COption_u16Z_none();
14084         uint64_t ret_ref = (uint64_t)ret_copy;
14085         return ret_ref;
14086 }
14087
14088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1free(JNIEnv *env, jclass clz, int64_t _res) {
14089         if ((_res & 1) != 0) return;
14090         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14091         CHECK_ACCESS(_res_ptr);
14092         LDKCOption_u16Z _res_conv = *(LDKCOption_u16Z*)(_res_ptr);
14093         FREE((void*)_res);
14094         COption_u16Z_free(_res_conv);
14095 }
14096
14097 static inline uint64_t COption_u16Z_clone_ptr(LDKCOption_u16Z *NONNULL_PTR arg) {
14098         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14099         *ret_copy = COption_u16Z_clone(arg);
14100 uint64_t ret_ref = (uint64_t)ret_copy;
14101         return ret_ref;
14102 }
14103 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14104         LDKCOption_u16Z* arg_conv = (LDKCOption_u16Z*)arg;
14105         int64_t ret_val = COption_u16Z_clone_ptr(arg_conv);
14106         return ret_val;
14107 }
14108
14109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1u16Z_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14110         LDKCOption_u16Z* orig_conv = (LDKCOption_u16Z*)orig;
14111         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
14112         *ret_copy = COption_u16Z_clone(orig_conv);
14113         uint64_t ret_ref = (uint64_t)ret_copy;
14114         return ret_ref;
14115 }
14116
14117 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1ok(JNIEnv *env, jclass clz) {
14118         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14119         *ret_conv = CResult_NoneAPIErrorZ_ok();
14120         return (uint64_t)ret_conv;
14121 }
14122
14123 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14124         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14125         CHECK_ACCESS(e_ptr);
14126         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14127         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
14128         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14129         *ret_conv = CResult_NoneAPIErrorZ_err(e_conv);
14130         return (uint64_t)ret_conv;
14131 }
14132
14133 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14134         LDKCResult_NoneAPIErrorZ* o_conv = (LDKCResult_NoneAPIErrorZ*)(o & ~1);
14135         jboolean ret_val = CResult_NoneAPIErrorZ_is_ok(o_conv);
14136         return ret_val;
14137 }
14138
14139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14140         if ((_res & 1) != 0) return;
14141         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14142         CHECK_ACCESS(_res_ptr);
14143         LDKCResult_NoneAPIErrorZ _res_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_ptr);
14144         FREE((void*)_res);
14145         CResult_NoneAPIErrorZ_free(_res_conv);
14146 }
14147
14148 static inline uint64_t CResult_NoneAPIErrorZ_clone_ptr(LDKCResult_NoneAPIErrorZ *NONNULL_PTR arg) {
14149         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14150         *ret_conv = CResult_NoneAPIErrorZ_clone(arg);
14151         return (uint64_t)ret_conv;
14152 }
14153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14154         LDKCResult_NoneAPIErrorZ* arg_conv = (LDKCResult_NoneAPIErrorZ*)(arg & ~1);
14155         int64_t ret_val = CResult_NoneAPIErrorZ_clone_ptr(arg_conv);
14156         return ret_val;
14157 }
14158
14159 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14160         LDKCResult_NoneAPIErrorZ* orig_conv = (LDKCResult_NoneAPIErrorZ*)(orig & ~1);
14161         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
14162         *ret_conv = CResult_NoneAPIErrorZ_clone(orig_conv);
14163         return (uint64_t)ret_conv;
14164 }
14165
14166 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1CResult_1NoneAPIErrorZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14167         LDKCVec_CResult_NoneAPIErrorZZ _res_constr;
14168         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14169         if (_res_constr.datalen > 0)
14170                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
14171         else
14172                 _res_constr.data = NULL;
14173         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14174         for (size_t w = 0; w < _res_constr.datalen; w++) {
14175                 int64_t _res_conv_22 = _res_vals[w];
14176                 void* _res_conv_22_ptr = (void*)(((uint64_t)_res_conv_22) & ~1);
14177                 CHECK_ACCESS(_res_conv_22_ptr);
14178                 LDKCResult_NoneAPIErrorZ _res_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(_res_conv_22_ptr);
14179                 FREE((void*)_res_conv_22);
14180                 _res_constr.data[w] = _res_conv_22_conv;
14181         }
14182         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14183         CVec_CResult_NoneAPIErrorZZ_free(_res_constr);
14184 }
14185
14186 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1APIErrorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14187         LDKCVec_APIErrorZ _res_constr;
14188         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14189         if (_res_constr.datalen > 0)
14190                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
14191         else
14192                 _res_constr.data = NULL;
14193         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14194         for (size_t k = 0; k < _res_constr.datalen; k++) {
14195                 int64_t _res_conv_10 = _res_vals[k];
14196                 void* _res_conv_10_ptr = (void*)(((uint64_t)_res_conv_10) & ~1);
14197                 CHECK_ACCESS(_res_conv_10_ptr);
14198                 LDKAPIError _res_conv_10_conv = *(LDKAPIError*)(_res_conv_10_ptr);
14199                 FREE((void*)_res_conv_10);
14200                 _res_constr.data[k] = _res_conv_10_conv;
14201         }
14202         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14203         CVec_APIErrorZ_free(_res_constr);
14204 }
14205
14206 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14207         LDKThirtyTwoBytes o_ref;
14208         CHECK((*env)->GetArrayLength(env, o) == 32);
14209         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14210         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14211         *ret_conv = CResult__u832APIErrorZ_ok(o_ref);
14212         return (uint64_t)ret_conv;
14213 }
14214
14215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14216         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14217         CHECK_ACCESS(e_ptr);
14218         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14219         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
14220         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14221         *ret_conv = CResult__u832APIErrorZ_err(e_conv);
14222         return (uint64_t)ret_conv;
14223 }
14224
14225 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14226         LDKCResult__u832APIErrorZ* o_conv = (LDKCResult__u832APIErrorZ*)(o & ~1);
14227         jboolean ret_val = CResult__u832APIErrorZ_is_ok(o_conv);
14228         return ret_val;
14229 }
14230
14231 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14232         if ((_res & 1) != 0) return;
14233         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14234         CHECK_ACCESS(_res_ptr);
14235         LDKCResult__u832APIErrorZ _res_conv = *(LDKCResult__u832APIErrorZ*)(_res_ptr);
14236         FREE((void*)_res);
14237         CResult__u832APIErrorZ_free(_res_conv);
14238 }
14239
14240 static inline uint64_t CResult__u832APIErrorZ_clone_ptr(LDKCResult__u832APIErrorZ *NONNULL_PTR arg) {
14241         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14242         *ret_conv = CResult__u832APIErrorZ_clone(arg);
14243         return (uint64_t)ret_conv;
14244 }
14245 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14246         LDKCResult__u832APIErrorZ* arg_conv = (LDKCResult__u832APIErrorZ*)(arg & ~1);
14247         int64_t ret_val = CResult__u832APIErrorZ_clone_ptr(arg_conv);
14248         return ret_val;
14249 }
14250
14251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1_1u832APIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14252         LDKCResult__u832APIErrorZ* orig_conv = (LDKCResult__u832APIErrorZ*)(orig & ~1);
14253         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
14254         *ret_conv = CResult__u832APIErrorZ_clone(orig_conv);
14255         return (uint64_t)ret_conv;
14256 }
14257
14258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14259         LDKThirtyTwoBytes o_ref;
14260         CHECK((*env)->GetArrayLength(env, o) == 32);
14261         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14262         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14263         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_ok(o_ref);
14264         return (uint64_t)ret_conv;
14265 }
14266
14267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14268         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14269         CHECK_ACCESS(e_ptr);
14270         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14271         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14272         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14273         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_err(e_conv);
14274         return (uint64_t)ret_conv;
14275 }
14276
14277 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14278         LDKCResult_PaymentIdPaymentSendFailureZ* o_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(o & ~1);
14279         jboolean ret_val = CResult_PaymentIdPaymentSendFailureZ_is_ok(o_conv);
14280         return ret_val;
14281 }
14282
14283 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14284         if ((_res & 1) != 0) return;
14285         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14286         CHECK_ACCESS(_res_ptr);
14287         LDKCResult_PaymentIdPaymentSendFailureZ _res_conv = *(LDKCResult_PaymentIdPaymentSendFailureZ*)(_res_ptr);
14288         FREE((void*)_res);
14289         CResult_PaymentIdPaymentSendFailureZ_free(_res_conv);
14290 }
14291
14292 static inline uint64_t CResult_PaymentIdPaymentSendFailureZ_clone_ptr(LDKCResult_PaymentIdPaymentSendFailureZ *NONNULL_PTR arg) {
14293         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14294         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(arg);
14295         return (uint64_t)ret_conv;
14296 }
14297 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14298         LDKCResult_PaymentIdPaymentSendFailureZ* arg_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(arg & ~1);
14299         int64_t ret_val = CResult_PaymentIdPaymentSendFailureZ_clone_ptr(arg_conv);
14300         return ret_val;
14301 }
14302
14303 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14304         LDKCResult_PaymentIdPaymentSendFailureZ* orig_conv = (LDKCResult_PaymentIdPaymentSendFailureZ*)(orig & ~1);
14305         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
14306         *ret_conv = CResult_PaymentIdPaymentSendFailureZ_clone(orig_conv);
14307         return (uint64_t)ret_conv;
14308 }
14309
14310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1ok(JNIEnv *env, jclass clz) {
14311         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14312         *ret_conv = CResult_NonePaymentSendFailureZ_ok();
14313         return (uint64_t)ret_conv;
14314 }
14315
14316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14317         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14318         CHECK_ACCESS(e_ptr);
14319         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14320         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14321         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14322         *ret_conv = CResult_NonePaymentSendFailureZ_err(e_conv);
14323         return (uint64_t)ret_conv;
14324 }
14325
14326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14327         LDKCResult_NonePaymentSendFailureZ* o_conv = (LDKCResult_NonePaymentSendFailureZ*)(o & ~1);
14328         jboolean ret_val = CResult_NonePaymentSendFailureZ_is_ok(o_conv);
14329         return ret_val;
14330 }
14331
14332 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14333         if ((_res & 1) != 0) return;
14334         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14335         CHECK_ACCESS(_res_ptr);
14336         LDKCResult_NonePaymentSendFailureZ _res_conv = *(LDKCResult_NonePaymentSendFailureZ*)(_res_ptr);
14337         FREE((void*)_res);
14338         CResult_NonePaymentSendFailureZ_free(_res_conv);
14339 }
14340
14341 static inline uint64_t CResult_NonePaymentSendFailureZ_clone_ptr(LDKCResult_NonePaymentSendFailureZ *NONNULL_PTR arg) {
14342         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14343         *ret_conv = CResult_NonePaymentSendFailureZ_clone(arg);
14344         return (uint64_t)ret_conv;
14345 }
14346 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14347         LDKCResult_NonePaymentSendFailureZ* arg_conv = (LDKCResult_NonePaymentSendFailureZ*)(arg & ~1);
14348         int64_t ret_val = CResult_NonePaymentSendFailureZ_clone_ptr(arg_conv);
14349         return ret_val;
14350 }
14351
14352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14353         LDKCResult_NonePaymentSendFailureZ* orig_conv = (LDKCResult_NonePaymentSendFailureZ*)(orig & ~1);
14354         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
14355         *ret_conv = CResult_NonePaymentSendFailureZ_clone(orig_conv);
14356         return (uint64_t)ret_conv;
14357 }
14358
14359 static inline uint64_t C2Tuple_PaymentHashPaymentIdZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentIdZ *NONNULL_PTR arg) {
14360         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14361         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(arg);
14362         return ((uint64_t)ret_conv);
14363 }
14364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14365         LDKC2Tuple_PaymentHashPaymentIdZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(arg & ~1);
14366         int64_t ret_val = C2Tuple_PaymentHashPaymentIdZ_clone_ptr(arg_conv);
14367         return ret_val;
14368 }
14369
14370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14371         LDKC2Tuple_PaymentHashPaymentIdZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentIdZ*)(orig & ~1);
14372         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14373         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_clone(orig_conv);
14374         return ((uint64_t)ret_conv);
14375 }
14376
14377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
14378         LDKThirtyTwoBytes a_ref;
14379         CHECK((*env)->GetArrayLength(env, a) == 32);
14380         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14381         LDKThirtyTwoBytes b_ref;
14382         CHECK((*env)->GetArrayLength(env, b) == 32);
14383         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
14384         LDKC2Tuple_PaymentHashPaymentIdZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentIdZ), "LDKC2Tuple_PaymentHashPaymentIdZ");
14385         *ret_conv = C2Tuple_PaymentHashPaymentIdZ_new(a_ref, b_ref);
14386         return ((uint64_t)ret_conv);
14387 }
14388
14389 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentIdZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14390         if ((_res & 1) != 0) return;
14391         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14392         CHECK_ACCESS(_res_ptr);
14393         LDKC2Tuple_PaymentHashPaymentIdZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(_res_ptr);
14394         FREE((void*)_res);
14395         C2Tuple_PaymentHashPaymentIdZ_free(_res_conv);
14396 }
14397
14398 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14399         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14400         CHECK_ACCESS(o_ptr);
14401         LDKC2Tuple_PaymentHashPaymentIdZ o_conv = *(LDKC2Tuple_PaymentHashPaymentIdZ*)(o_ptr);
14402         o_conv = C2Tuple_PaymentHashPaymentIdZ_clone((LDKC2Tuple_PaymentHashPaymentIdZ*)(((uint64_t)o) & ~1));
14403         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14404         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_ok(o_conv);
14405         return (uint64_t)ret_conv;
14406 }
14407
14408 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14409         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14410         CHECK_ACCESS(e_ptr);
14411         LDKPaymentSendFailure e_conv = *(LDKPaymentSendFailure*)(e_ptr);
14412         e_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)e) & ~1));
14413         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14414         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_err(e_conv);
14415         return (uint64_t)ret_conv;
14416 }
14417
14418 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14419         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* o_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(o & ~1);
14420         jboolean ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_is_ok(o_conv);
14421         return ret_val;
14422 }
14423
14424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14425         if ((_res & 1) != 0) return;
14426         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14427         CHECK_ACCESS(_res_ptr);
14428         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ _res_conv = *(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(_res_ptr);
14429         FREE((void*)_res);
14430         CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_free(_res_conv);
14431 }
14432
14433 static inline uint64_t CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ *NONNULL_PTR arg) {
14434         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14435         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(arg);
14436         return (uint64_t)ret_conv;
14437 }
14438 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14439         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* arg_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(arg & ~1);
14440         int64_t ret_val = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone_ptr(arg_conv);
14441         return ret_val;
14442 }
14443
14444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1PaymentHashPaymentIdZPaymentSendFailureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14445         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* orig_conv = (LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ*)(orig & ~1);
14446         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
14447         *ret_conv = CResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ_clone(orig_conv);
14448         return (uint64_t)ret_conv;
14449 }
14450
14451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NetAddressZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14452         LDKCVec_NetAddressZ _res_constr;
14453         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14454         if (_res_constr.datalen > 0)
14455                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
14456         else
14457                 _res_constr.data = NULL;
14458         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14459         for (size_t m = 0; m < _res_constr.datalen; m++) {
14460                 int64_t _res_conv_12 = _res_vals[m];
14461                 void* _res_conv_12_ptr = (void*)(((uint64_t)_res_conv_12) & ~1);
14462                 CHECK_ACCESS(_res_conv_12_ptr);
14463                 LDKNetAddress _res_conv_12_conv = *(LDKNetAddress*)(_res_conv_12_ptr);
14464                 FREE((void*)_res_conv_12);
14465                 _res_constr.data[m] = _res_conv_12_conv;
14466         }
14467         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14468         CVec_NetAddressZ_free(_res_constr);
14469 }
14470
14471 static inline uint64_t C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(LDKC2Tuple_PaymentHashPaymentSecretZ *NONNULL_PTR arg) {
14472         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14473         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(arg);
14474         return ((uint64_t)ret_conv);
14475 }
14476 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14477         LDKC2Tuple_PaymentHashPaymentSecretZ* arg_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(arg & ~1);
14478         int64_t ret_val = C2Tuple_PaymentHashPaymentSecretZ_clone_ptr(arg_conv);
14479         return ret_val;
14480 }
14481
14482 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14483         LDKC2Tuple_PaymentHashPaymentSecretZ* orig_conv = (LDKC2Tuple_PaymentHashPaymentSecretZ*)(orig & ~1);
14484         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14485         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_clone(orig_conv);
14486         return ((uint64_t)ret_conv);
14487 }
14488
14489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int8_tArray b) {
14490         LDKThirtyTwoBytes a_ref;
14491         CHECK((*env)->GetArrayLength(env, a) == 32);
14492         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14493         LDKThirtyTwoBytes b_ref;
14494         CHECK((*env)->GetArrayLength(env, b) == 32);
14495         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
14496         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
14497         *ret_conv = C2Tuple_PaymentHashPaymentSecretZ_new(a_ref, b_ref);
14498         return ((uint64_t)ret_conv);
14499 }
14500
14501 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PaymentHashPaymentSecretZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14502         if ((_res & 1) != 0) return;
14503         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14504         CHECK_ACCESS(_res_ptr);
14505         LDKC2Tuple_PaymentHashPaymentSecretZ _res_conv = *(LDKC2Tuple_PaymentHashPaymentSecretZ*)(_res_ptr);
14506         FREE((void*)_res);
14507         C2Tuple_PaymentHashPaymentSecretZ_free(_res_conv);
14508 }
14509
14510 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14511         LDKThirtyTwoBytes o_ref;
14512         CHECK((*env)->GetArrayLength(env, o) == 32);
14513         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14514         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14515         *ret_conv = CResult_PaymentSecretAPIErrorZ_ok(o_ref);
14516         return (uint64_t)ret_conv;
14517 }
14518
14519 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14520         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14521         CHECK_ACCESS(e_ptr);
14522         LDKAPIError e_conv = *(LDKAPIError*)(e_ptr);
14523         e_conv = APIError_clone((LDKAPIError*)(((uint64_t)e) & ~1));
14524         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14525         *ret_conv = CResult_PaymentSecretAPIErrorZ_err(e_conv);
14526         return (uint64_t)ret_conv;
14527 }
14528
14529 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14530         LDKCResult_PaymentSecretAPIErrorZ* o_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(o & ~1);
14531         jboolean ret_val = CResult_PaymentSecretAPIErrorZ_is_ok(o_conv);
14532         return ret_val;
14533 }
14534
14535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14536         if ((_res & 1) != 0) return;
14537         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14538         CHECK_ACCESS(_res_ptr);
14539         LDKCResult_PaymentSecretAPIErrorZ _res_conv = *(LDKCResult_PaymentSecretAPIErrorZ*)(_res_ptr);
14540         FREE((void*)_res);
14541         CResult_PaymentSecretAPIErrorZ_free(_res_conv);
14542 }
14543
14544 static inline uint64_t CResult_PaymentSecretAPIErrorZ_clone_ptr(LDKCResult_PaymentSecretAPIErrorZ *NONNULL_PTR arg) {
14545         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14546         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(arg);
14547         return (uint64_t)ret_conv;
14548 }
14549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14550         LDKCResult_PaymentSecretAPIErrorZ* arg_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(arg & ~1);
14551         int64_t ret_val = CResult_PaymentSecretAPIErrorZ_clone_ptr(arg_conv);
14552         return ret_val;
14553 }
14554
14555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentSecretAPIErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14556         LDKCResult_PaymentSecretAPIErrorZ* orig_conv = (LDKCResult_PaymentSecretAPIErrorZ*)(orig & ~1);
14557         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
14558         *ret_conv = CResult_PaymentSecretAPIErrorZ_clone(orig_conv);
14559         return (uint64_t)ret_conv;
14560 }
14561
14562 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1ChannelMonitorZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
14563         LDKCVec_ChannelMonitorZ _res_constr;
14564         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
14565         if (_res_constr.datalen > 0)
14566                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
14567         else
14568                 _res_constr.data = NULL;
14569         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
14570         for (size_t q = 0; q < _res_constr.datalen; q++) {
14571                 int64_t _res_conv_16 = _res_vals[q];
14572                 LDKChannelMonitor _res_conv_16_conv;
14573                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
14574                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
14575                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
14576                 _res_constr.data[q] = _res_conv_16_conv;
14577         }
14578         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
14579         CVec_ChannelMonitorZ_free(_res_constr);
14580 }
14581
14582 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
14583         LDKThirtyTwoBytes a_ref;
14584         CHECK((*env)->GetArrayLength(env, a) == 32);
14585         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
14586         LDKChannelManager b_conv;
14587         b_conv.inner = (void*)(b & (~1));
14588         b_conv.is_owned = (b & 1) || (b == 0);
14589         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
14590         // Warning: we need a move here but no clone is available for LDKChannelManager
14591         LDKC2Tuple_BlockHashChannelManagerZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_BlockHashChannelManagerZ), "LDKC2Tuple_BlockHashChannelManagerZ");
14592         *ret_conv = C2Tuple_BlockHashChannelManagerZ_new(a_ref, b_conv);
14593         return ((uint64_t)ret_conv);
14594 }
14595
14596 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14597         if ((_res & 1) != 0) return;
14598         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14599         CHECK_ACCESS(_res_ptr);
14600         LDKC2Tuple_BlockHashChannelManagerZ _res_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(_res_ptr);
14601         FREE((void*)_res);
14602         C2Tuple_BlockHashChannelManagerZ_free(_res_conv);
14603 }
14604
14605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14606         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14607         CHECK_ACCESS(o_ptr);
14608         LDKC2Tuple_BlockHashChannelManagerZ o_conv = *(LDKC2Tuple_BlockHashChannelManagerZ*)(o_ptr);
14609         // Warning: we may need a move here but no clone is available for LDKC2Tuple_BlockHashChannelManagerZ
14610         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14611         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_ok(o_conv);
14612         return (uint64_t)ret_conv;
14613 }
14614
14615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14616         LDKDecodeError e_conv;
14617         e_conv.inner = (void*)(e & (~1));
14618         e_conv.is_owned = (e & 1) || (e == 0);
14619         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14620         e_conv = DecodeError_clone(&e_conv);
14621         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
14622         *ret_conv = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_err(e_conv);
14623         return (uint64_t)ret_conv;
14624 }
14625
14626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14627         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(o & ~1);
14628         jboolean ret_val = CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_is_ok(o_conv);
14629         return ret_val;
14630 }
14631
14632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelManagerZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14633         if ((_res & 1) != 0) return;
14634         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14635         CHECK_ACCESS(_res_ptr);
14636         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ*)(_res_ptr);
14637         FREE((void*)_res);
14638         CResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ_free(_res_conv);
14639 }
14640
14641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14642         LDKChannelConfig o_conv;
14643         o_conv.inner = (void*)(o & (~1));
14644         o_conv.is_owned = (o & 1) || (o == 0);
14645         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14646         o_conv = ChannelConfig_clone(&o_conv);
14647         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14648         *ret_conv = CResult_ChannelConfigDecodeErrorZ_ok(o_conv);
14649         return (uint64_t)ret_conv;
14650 }
14651
14652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14653         LDKDecodeError e_conv;
14654         e_conv.inner = (void*)(e & (~1));
14655         e_conv.is_owned = (e & 1) || (e == 0);
14656         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14657         e_conv = DecodeError_clone(&e_conv);
14658         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14659         *ret_conv = CResult_ChannelConfigDecodeErrorZ_err(e_conv);
14660         return (uint64_t)ret_conv;
14661 }
14662
14663 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14664         LDKCResult_ChannelConfigDecodeErrorZ* o_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(o & ~1);
14665         jboolean ret_val = CResult_ChannelConfigDecodeErrorZ_is_ok(o_conv);
14666         return ret_val;
14667 }
14668
14669 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14670         if ((_res & 1) != 0) return;
14671         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14672         CHECK_ACCESS(_res_ptr);
14673         LDKCResult_ChannelConfigDecodeErrorZ _res_conv = *(LDKCResult_ChannelConfigDecodeErrorZ*)(_res_ptr);
14674         FREE((void*)_res);
14675         CResult_ChannelConfigDecodeErrorZ_free(_res_conv);
14676 }
14677
14678 static inline uint64_t CResult_ChannelConfigDecodeErrorZ_clone_ptr(LDKCResult_ChannelConfigDecodeErrorZ *NONNULL_PTR arg) {
14679         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14680         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(arg);
14681         return (uint64_t)ret_conv;
14682 }
14683 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14684         LDKCResult_ChannelConfigDecodeErrorZ* arg_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(arg & ~1);
14685         int64_t ret_val = CResult_ChannelConfigDecodeErrorZ_clone_ptr(arg_conv);
14686         return ret_val;
14687 }
14688
14689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelConfigDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14690         LDKCResult_ChannelConfigDecodeErrorZ* orig_conv = (LDKCResult_ChannelConfigDecodeErrorZ*)(orig & ~1);
14691         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
14692         *ret_conv = CResult_ChannelConfigDecodeErrorZ_clone(orig_conv);
14693         return (uint64_t)ret_conv;
14694 }
14695
14696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14697         LDKOutPoint o_conv;
14698         o_conv.inner = (void*)(o & (~1));
14699         o_conv.is_owned = (o & 1) || (o == 0);
14700         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14701         o_conv = OutPoint_clone(&o_conv);
14702         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14703         *ret_conv = CResult_OutPointDecodeErrorZ_ok(o_conv);
14704         return (uint64_t)ret_conv;
14705 }
14706
14707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14708         LDKDecodeError e_conv;
14709         e_conv.inner = (void*)(e & (~1));
14710         e_conv.is_owned = (e & 1) || (e == 0);
14711         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14712         e_conv = DecodeError_clone(&e_conv);
14713         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14714         *ret_conv = CResult_OutPointDecodeErrorZ_err(e_conv);
14715         return (uint64_t)ret_conv;
14716 }
14717
14718 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14719         LDKCResult_OutPointDecodeErrorZ* o_conv = (LDKCResult_OutPointDecodeErrorZ*)(o & ~1);
14720         jboolean ret_val = CResult_OutPointDecodeErrorZ_is_ok(o_conv);
14721         return ret_val;
14722 }
14723
14724 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14725         if ((_res & 1) != 0) return;
14726         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14727         CHECK_ACCESS(_res_ptr);
14728         LDKCResult_OutPointDecodeErrorZ _res_conv = *(LDKCResult_OutPointDecodeErrorZ*)(_res_ptr);
14729         FREE((void*)_res);
14730         CResult_OutPointDecodeErrorZ_free(_res_conv);
14731 }
14732
14733 static inline uint64_t CResult_OutPointDecodeErrorZ_clone_ptr(LDKCResult_OutPointDecodeErrorZ *NONNULL_PTR arg) {
14734         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14735         *ret_conv = CResult_OutPointDecodeErrorZ_clone(arg);
14736         return (uint64_t)ret_conv;
14737 }
14738 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14739         LDKCResult_OutPointDecodeErrorZ* arg_conv = (LDKCResult_OutPointDecodeErrorZ*)(arg & ~1);
14740         int64_t ret_val = CResult_OutPointDecodeErrorZ_clone_ptr(arg_conv);
14741         return ret_val;
14742 }
14743
14744 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OutPointDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14745         LDKCResult_OutPointDecodeErrorZ* orig_conv = (LDKCResult_OutPointDecodeErrorZ*)(orig & ~1);
14746         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
14747         *ret_conv = CResult_OutPointDecodeErrorZ_clone(orig_conv);
14748         return (uint64_t)ret_conv;
14749 }
14750
14751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1some(JNIEnv *env, jclass clz, int64_t o) {
14752         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14753         CHECK_ACCESS(o_ptr);
14754         LDKType o_conv = *(LDKType*)(o_ptr);
14755         if (o_conv.free == LDKType_JCalls_free) {
14756                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
14757                 LDKType_JCalls_cloned(&o_conv);
14758         }
14759         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14760         *ret_copy = COption_TypeZ_some(o_conv);
14761         uint64_t ret_ref = (uint64_t)ret_copy;
14762         return ret_ref;
14763 }
14764
14765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1none(JNIEnv *env, jclass clz) {
14766         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14767         *ret_copy = COption_TypeZ_none();
14768         uint64_t ret_ref = (uint64_t)ret_copy;
14769         return ret_ref;
14770 }
14771
14772 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14773         if ((_res & 1) != 0) return;
14774         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14775         CHECK_ACCESS(_res_ptr);
14776         LDKCOption_TypeZ _res_conv = *(LDKCOption_TypeZ*)(_res_ptr);
14777         FREE((void*)_res);
14778         COption_TypeZ_free(_res_conv);
14779 }
14780
14781 static inline uint64_t COption_TypeZ_clone_ptr(LDKCOption_TypeZ *NONNULL_PTR arg) {
14782         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14783         *ret_copy = COption_TypeZ_clone(arg);
14784 uint64_t ret_ref = (uint64_t)ret_copy;
14785         return ret_ref;
14786 }
14787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14788         LDKCOption_TypeZ* arg_conv = (LDKCOption_TypeZ*)arg;
14789         int64_t ret_val = COption_TypeZ_clone_ptr(arg_conv);
14790         return ret_val;
14791 }
14792
14793 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1TypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14794         LDKCOption_TypeZ* orig_conv = (LDKCOption_TypeZ*)orig;
14795         LDKCOption_TypeZ *ret_copy = MALLOC(sizeof(LDKCOption_TypeZ), "LDKCOption_TypeZ");
14796         *ret_copy = COption_TypeZ_clone(orig_conv);
14797         uint64_t ret_ref = (uint64_t)ret_copy;
14798         return ret_ref;
14799 }
14800
14801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14802         void* o_ptr = (void*)(((uint64_t)o) & ~1);
14803         CHECK_ACCESS(o_ptr);
14804         LDKCOption_TypeZ o_conv = *(LDKCOption_TypeZ*)(o_ptr);
14805         o_conv = COption_TypeZ_clone((LDKCOption_TypeZ*)(((uint64_t)o) & ~1));
14806         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14807         *ret_conv = CResult_COption_TypeZDecodeErrorZ_ok(o_conv);
14808         return (uint64_t)ret_conv;
14809 }
14810
14811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14812         LDKDecodeError e_conv;
14813         e_conv.inner = (void*)(e & (~1));
14814         e_conv.is_owned = (e & 1) || (e == 0);
14815         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
14816         e_conv = DecodeError_clone(&e_conv);
14817         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14818         *ret_conv = CResult_COption_TypeZDecodeErrorZ_err(e_conv);
14819         return (uint64_t)ret_conv;
14820 }
14821
14822 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14823         LDKCResult_COption_TypeZDecodeErrorZ* o_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(o & ~1);
14824         jboolean ret_val = CResult_COption_TypeZDecodeErrorZ_is_ok(o_conv);
14825         return ret_val;
14826 }
14827
14828 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14829         if ((_res & 1) != 0) return;
14830         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14831         CHECK_ACCESS(_res_ptr);
14832         LDKCResult_COption_TypeZDecodeErrorZ _res_conv = *(LDKCResult_COption_TypeZDecodeErrorZ*)(_res_ptr);
14833         FREE((void*)_res);
14834         CResult_COption_TypeZDecodeErrorZ_free(_res_conv);
14835 }
14836
14837 static inline uint64_t CResult_COption_TypeZDecodeErrorZ_clone_ptr(LDKCResult_COption_TypeZDecodeErrorZ *NONNULL_PTR arg) {
14838         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14839         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(arg);
14840         return (uint64_t)ret_conv;
14841 }
14842 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14843         LDKCResult_COption_TypeZDecodeErrorZ* arg_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(arg & ~1);
14844         int64_t ret_val = CResult_COption_TypeZDecodeErrorZ_clone_ptr(arg_conv);
14845         return ret_val;
14846 }
14847
14848 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1TypeZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14849         LDKCResult_COption_TypeZDecodeErrorZ* orig_conv = (LDKCResult_COption_TypeZDecodeErrorZ*)(orig & ~1);
14850         LDKCResult_COption_TypeZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_TypeZDecodeErrorZ), "LDKCResult_COption_TypeZDecodeErrorZ");
14851         *ret_conv = CResult_COption_TypeZDecodeErrorZ_clone(orig_conv);
14852         return (uint64_t)ret_conv;
14853 }
14854
14855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
14856         LDKThirtyTwoBytes o_ref;
14857         CHECK((*env)->GetArrayLength(env, o) == 32);
14858         (*env)->GetByteArrayRegion(env, o, 0, 32, o_ref.data);
14859         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14860         *ret_conv = CResult_PaymentIdPaymentErrorZ_ok(o_ref);
14861         return (uint64_t)ret_conv;
14862 }
14863
14864 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
14865         void* e_ptr = (void*)(((uint64_t)e) & ~1);
14866         CHECK_ACCESS(e_ptr);
14867         LDKPaymentError e_conv = *(LDKPaymentError*)(e_ptr);
14868         e_conv = PaymentError_clone((LDKPaymentError*)(((uint64_t)e) & ~1));
14869         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14870         *ret_conv = CResult_PaymentIdPaymentErrorZ_err(e_conv);
14871         return (uint64_t)ret_conv;
14872 }
14873
14874 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14875         LDKCResult_PaymentIdPaymentErrorZ* o_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(o & ~1);
14876         jboolean ret_val = CResult_PaymentIdPaymentErrorZ_is_ok(o_conv);
14877         return ret_val;
14878 }
14879
14880 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14881         if ((_res & 1) != 0) return;
14882         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14883         CHECK_ACCESS(_res_ptr);
14884         LDKCResult_PaymentIdPaymentErrorZ _res_conv = *(LDKCResult_PaymentIdPaymentErrorZ*)(_res_ptr);
14885         FREE((void*)_res);
14886         CResult_PaymentIdPaymentErrorZ_free(_res_conv);
14887 }
14888
14889 static inline uint64_t CResult_PaymentIdPaymentErrorZ_clone_ptr(LDKCResult_PaymentIdPaymentErrorZ *NONNULL_PTR arg) {
14890         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14891         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(arg);
14892         return (uint64_t)ret_conv;
14893 }
14894 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14895         LDKCResult_PaymentIdPaymentErrorZ* arg_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(arg & ~1);
14896         int64_t ret_val = CResult_PaymentIdPaymentErrorZ_clone_ptr(arg_conv);
14897         return ret_val;
14898 }
14899
14900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PaymentIdPaymentErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14901         LDKCResult_PaymentIdPaymentErrorZ* orig_conv = (LDKCResult_PaymentIdPaymentErrorZ*)(orig & ~1);
14902         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
14903         *ret_conv = CResult_PaymentIdPaymentErrorZ_clone(orig_conv);
14904         return (uint64_t)ret_conv;
14905 }
14906
14907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1ok(JNIEnv *env, jclass clz, jclass o) {
14908         LDKSiPrefix o_conv = LDKSiPrefix_from_java(env, o);
14909         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14910         *ret_conv = CResult_SiPrefixNoneZ_ok(o_conv);
14911         return (uint64_t)ret_conv;
14912 }
14913
14914 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1err(JNIEnv *env, jclass clz) {
14915         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14916         *ret_conv = CResult_SiPrefixNoneZ_err();
14917         return (uint64_t)ret_conv;
14918 }
14919
14920 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14921         LDKCResult_SiPrefixNoneZ* o_conv = (LDKCResult_SiPrefixNoneZ*)(o & ~1);
14922         jboolean ret_val = CResult_SiPrefixNoneZ_is_ok(o_conv);
14923         return ret_val;
14924 }
14925
14926 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14927         if ((_res & 1) != 0) return;
14928         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14929         CHECK_ACCESS(_res_ptr);
14930         LDKCResult_SiPrefixNoneZ _res_conv = *(LDKCResult_SiPrefixNoneZ*)(_res_ptr);
14931         FREE((void*)_res);
14932         CResult_SiPrefixNoneZ_free(_res_conv);
14933 }
14934
14935 static inline uint64_t CResult_SiPrefixNoneZ_clone_ptr(LDKCResult_SiPrefixNoneZ *NONNULL_PTR arg) {
14936         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14937         *ret_conv = CResult_SiPrefixNoneZ_clone(arg);
14938         return (uint64_t)ret_conv;
14939 }
14940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14941         LDKCResult_SiPrefixNoneZ* arg_conv = (LDKCResult_SiPrefixNoneZ*)(arg & ~1);
14942         int64_t ret_val = CResult_SiPrefixNoneZ_clone_ptr(arg_conv);
14943         return ret_val;
14944 }
14945
14946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SiPrefixNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14947         LDKCResult_SiPrefixNoneZ* orig_conv = (LDKCResult_SiPrefixNoneZ*)(orig & ~1);
14948         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
14949         *ret_conv = CResult_SiPrefixNoneZ_clone(orig_conv);
14950         return (uint64_t)ret_conv;
14951 }
14952
14953 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
14954         LDKInvoice o_conv;
14955         o_conv.inner = (void*)(o & (~1));
14956         o_conv.is_owned = (o & 1) || (o == 0);
14957         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
14958         o_conv = Invoice_clone(&o_conv);
14959         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14960         *ret_conv = CResult_InvoiceNoneZ_ok(o_conv);
14961         return (uint64_t)ret_conv;
14962 }
14963
14964 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
14965         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14966         *ret_conv = CResult_InvoiceNoneZ_err();
14967         return (uint64_t)ret_conv;
14968 }
14969
14970 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
14971         LDKCResult_InvoiceNoneZ* o_conv = (LDKCResult_InvoiceNoneZ*)(o & ~1);
14972         jboolean ret_val = CResult_InvoiceNoneZ_is_ok(o_conv);
14973         return ret_val;
14974 }
14975
14976 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
14977         if ((_res & 1) != 0) return;
14978         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
14979         CHECK_ACCESS(_res_ptr);
14980         LDKCResult_InvoiceNoneZ _res_conv = *(LDKCResult_InvoiceNoneZ*)(_res_ptr);
14981         FREE((void*)_res);
14982         CResult_InvoiceNoneZ_free(_res_conv);
14983 }
14984
14985 static inline uint64_t CResult_InvoiceNoneZ_clone_ptr(LDKCResult_InvoiceNoneZ *NONNULL_PTR arg) {
14986         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14987         *ret_conv = CResult_InvoiceNoneZ_clone(arg);
14988         return (uint64_t)ret_conv;
14989 }
14990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
14991         LDKCResult_InvoiceNoneZ* arg_conv = (LDKCResult_InvoiceNoneZ*)(arg & ~1);
14992         int64_t ret_val = CResult_InvoiceNoneZ_clone_ptr(arg_conv);
14993         return ret_val;
14994 }
14995
14996 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
14997         LDKCResult_InvoiceNoneZ* orig_conv = (LDKCResult_InvoiceNoneZ*)(orig & ~1);
14998         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
14999         *ret_conv = CResult_InvoiceNoneZ_clone(orig_conv);
15000         return (uint64_t)ret_conv;
15001 }
15002
15003 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15004         LDKSignedRawInvoice o_conv;
15005         o_conv.inner = (void*)(o & (~1));
15006         o_conv.is_owned = (o & 1) || (o == 0);
15007         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15008         o_conv = SignedRawInvoice_clone(&o_conv);
15009         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15010         *ret_conv = CResult_SignedRawInvoiceNoneZ_ok(o_conv);
15011         return (uint64_t)ret_conv;
15012 }
15013
15014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1err(JNIEnv *env, jclass clz) {
15015         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15016         *ret_conv = CResult_SignedRawInvoiceNoneZ_err();
15017         return (uint64_t)ret_conv;
15018 }
15019
15020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15021         LDKCResult_SignedRawInvoiceNoneZ* o_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(o & ~1);
15022         jboolean ret_val = CResult_SignedRawInvoiceNoneZ_is_ok(o_conv);
15023         return ret_val;
15024 }
15025
15026 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15027         if ((_res & 1) != 0) return;
15028         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15029         CHECK_ACCESS(_res_ptr);
15030         LDKCResult_SignedRawInvoiceNoneZ _res_conv = *(LDKCResult_SignedRawInvoiceNoneZ*)(_res_ptr);
15031         FREE((void*)_res);
15032         CResult_SignedRawInvoiceNoneZ_free(_res_conv);
15033 }
15034
15035 static inline uint64_t CResult_SignedRawInvoiceNoneZ_clone_ptr(LDKCResult_SignedRawInvoiceNoneZ *NONNULL_PTR arg) {
15036         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15037         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(arg);
15038         return (uint64_t)ret_conv;
15039 }
15040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15041         LDKCResult_SignedRawInvoiceNoneZ* arg_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(arg & ~1);
15042         int64_t ret_val = CResult_SignedRawInvoiceNoneZ_clone_ptr(arg_conv);
15043         return ret_val;
15044 }
15045
15046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1SignedRawInvoiceNoneZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15047         LDKCResult_SignedRawInvoiceNoneZ* orig_conv = (LDKCResult_SignedRawInvoiceNoneZ*)(orig & ~1);
15048         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
15049         *ret_conv = CResult_SignedRawInvoiceNoneZ_clone(orig_conv);
15050         return (uint64_t)ret_conv;
15051 }
15052
15053 static inline uint64_t C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ *NONNULL_PTR arg) {
15054         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15055         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(arg);
15056         return ((uint64_t)ret_conv);
15057 }
15058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15059         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* arg_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(arg & ~1);
15060         int64_t ret_val = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone_ptr(arg_conv);
15061         return ret_val;
15062 }
15063
15064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15065         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* orig_conv = (LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(orig & ~1);
15066         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15067         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_clone(orig_conv);
15068         return ((uint64_t)ret_conv);
15069 }
15070
15071 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) {
15072         LDKRawInvoice a_conv;
15073         a_conv.inner = (void*)(a & (~1));
15074         a_conv.is_owned = (a & 1) || (a == 0);
15075         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15076         a_conv = RawInvoice_clone(&a_conv);
15077         LDKThirtyTwoBytes b_ref;
15078         CHECK((*env)->GetArrayLength(env, b) == 32);
15079         (*env)->GetByteArrayRegion(env, b, 0, 32, b_ref.data);
15080         LDKInvoiceSignature c_conv;
15081         c_conv.inner = (void*)(c & (~1));
15082         c_conv.is_owned = (c & 1) || (c == 0);
15083         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
15084         c_conv = InvoiceSignature_clone(&c_conv);
15085         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
15086         *ret_conv = C3Tuple_RawInvoice_u832InvoiceSignatureZ_new(a_conv, b_ref, c_conv);
15087         return ((uint64_t)ret_conv);
15088 }
15089
15090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1RawInvoice_1u832InvoiceSignatureZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15091         if ((_res & 1) != 0) return;
15092         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15093         CHECK_ACCESS(_res_ptr);
15094         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ _res_conv = *(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ*)(_res_ptr);
15095         FREE((void*)_res);
15096         C3Tuple_RawInvoice_u832InvoiceSignatureZ_free(_res_conv);
15097 }
15098
15099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15100         LDKPayeePubKey o_conv;
15101         o_conv.inner = (void*)(o & (~1));
15102         o_conv.is_owned = (o & 1) || (o == 0);
15103         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15104         o_conv = PayeePubKey_clone(&o_conv);
15105         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15106         *ret_conv = CResult_PayeePubKeyErrorZ_ok(o_conv);
15107         return (uint64_t)ret_conv;
15108 }
15109
15110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15111         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15112         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15113         *ret_conv = CResult_PayeePubKeyErrorZ_err(e_conv);
15114         return (uint64_t)ret_conv;
15115 }
15116
15117 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15118         LDKCResult_PayeePubKeyErrorZ* o_conv = (LDKCResult_PayeePubKeyErrorZ*)(o & ~1);
15119         jboolean ret_val = CResult_PayeePubKeyErrorZ_is_ok(o_conv);
15120         return ret_val;
15121 }
15122
15123 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15124         if ((_res & 1) != 0) return;
15125         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15126         CHECK_ACCESS(_res_ptr);
15127         LDKCResult_PayeePubKeyErrorZ _res_conv = *(LDKCResult_PayeePubKeyErrorZ*)(_res_ptr);
15128         FREE((void*)_res);
15129         CResult_PayeePubKeyErrorZ_free(_res_conv);
15130 }
15131
15132 static inline uint64_t CResult_PayeePubKeyErrorZ_clone_ptr(LDKCResult_PayeePubKeyErrorZ *NONNULL_PTR arg) {
15133         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15134         *ret_conv = CResult_PayeePubKeyErrorZ_clone(arg);
15135         return (uint64_t)ret_conv;
15136 }
15137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15138         LDKCResult_PayeePubKeyErrorZ* arg_conv = (LDKCResult_PayeePubKeyErrorZ*)(arg & ~1);
15139         int64_t ret_val = CResult_PayeePubKeyErrorZ_clone_ptr(arg_conv);
15140         return ret_val;
15141 }
15142
15143 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PayeePubKeyErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15144         LDKCResult_PayeePubKeyErrorZ* orig_conv = (LDKCResult_PayeePubKeyErrorZ*)(orig & ~1);
15145         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
15146         *ret_conv = CResult_PayeePubKeyErrorZ_clone(orig_conv);
15147         return (uint64_t)ret_conv;
15148 }
15149
15150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PrivateRouteZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15151         LDKCVec_PrivateRouteZ _res_constr;
15152         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15153         if (_res_constr.datalen > 0)
15154                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPrivateRoute), "LDKCVec_PrivateRouteZ Elements");
15155         else
15156                 _res_constr.data = NULL;
15157         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15158         for (size_t o = 0; o < _res_constr.datalen; o++) {
15159                 int64_t _res_conv_14 = _res_vals[o];
15160                 LDKPrivateRoute _res_conv_14_conv;
15161                 _res_conv_14_conv.inner = (void*)(_res_conv_14 & (~1));
15162                 _res_conv_14_conv.is_owned = (_res_conv_14 & 1) || (_res_conv_14 == 0);
15163                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_14_conv);
15164                 _res_constr.data[o] = _res_conv_14_conv;
15165         }
15166         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15167         CVec_PrivateRouteZ_free(_res_constr);
15168 }
15169
15170 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15171         LDKPositiveTimestamp o_conv;
15172         o_conv.inner = (void*)(o & (~1));
15173         o_conv.is_owned = (o & 1) || (o == 0);
15174         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15175         o_conv = PositiveTimestamp_clone(&o_conv);
15176         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15177         *ret_conv = CResult_PositiveTimestampCreationErrorZ_ok(o_conv);
15178         return (uint64_t)ret_conv;
15179 }
15180
15181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15182         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15183         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15184         *ret_conv = CResult_PositiveTimestampCreationErrorZ_err(e_conv);
15185         return (uint64_t)ret_conv;
15186 }
15187
15188 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15189         LDKCResult_PositiveTimestampCreationErrorZ* o_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(o & ~1);
15190         jboolean ret_val = CResult_PositiveTimestampCreationErrorZ_is_ok(o_conv);
15191         return ret_val;
15192 }
15193
15194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15195         if ((_res & 1) != 0) return;
15196         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15197         CHECK_ACCESS(_res_ptr);
15198         LDKCResult_PositiveTimestampCreationErrorZ _res_conv = *(LDKCResult_PositiveTimestampCreationErrorZ*)(_res_ptr);
15199         FREE((void*)_res);
15200         CResult_PositiveTimestampCreationErrorZ_free(_res_conv);
15201 }
15202
15203 static inline uint64_t CResult_PositiveTimestampCreationErrorZ_clone_ptr(LDKCResult_PositiveTimestampCreationErrorZ *NONNULL_PTR arg) {
15204         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15205         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(arg);
15206         return (uint64_t)ret_conv;
15207 }
15208 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15209         LDKCResult_PositiveTimestampCreationErrorZ* arg_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(arg & ~1);
15210         int64_t ret_val = CResult_PositiveTimestampCreationErrorZ_clone_ptr(arg_conv);
15211         return ret_val;
15212 }
15213
15214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PositiveTimestampCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15215         LDKCResult_PositiveTimestampCreationErrorZ* orig_conv = (LDKCResult_PositiveTimestampCreationErrorZ*)(orig & ~1);
15216         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
15217         *ret_conv = CResult_PositiveTimestampCreationErrorZ_clone(orig_conv);
15218         return (uint64_t)ret_conv;
15219 }
15220
15221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1ok(JNIEnv *env, jclass clz) {
15222         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15223         *ret_conv = CResult_NoneSemanticErrorZ_ok();
15224         return (uint64_t)ret_conv;
15225 }
15226
15227 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15228         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
15229         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15230         *ret_conv = CResult_NoneSemanticErrorZ_err(e_conv);
15231         return (uint64_t)ret_conv;
15232 }
15233
15234 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15235         LDKCResult_NoneSemanticErrorZ* o_conv = (LDKCResult_NoneSemanticErrorZ*)(o & ~1);
15236         jboolean ret_val = CResult_NoneSemanticErrorZ_is_ok(o_conv);
15237         return ret_val;
15238 }
15239
15240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15241         if ((_res & 1) != 0) return;
15242         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15243         CHECK_ACCESS(_res_ptr);
15244         LDKCResult_NoneSemanticErrorZ _res_conv = *(LDKCResult_NoneSemanticErrorZ*)(_res_ptr);
15245         FREE((void*)_res);
15246         CResult_NoneSemanticErrorZ_free(_res_conv);
15247 }
15248
15249 static inline uint64_t CResult_NoneSemanticErrorZ_clone_ptr(LDKCResult_NoneSemanticErrorZ *NONNULL_PTR arg) {
15250         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15251         *ret_conv = CResult_NoneSemanticErrorZ_clone(arg);
15252         return (uint64_t)ret_conv;
15253 }
15254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15255         LDKCResult_NoneSemanticErrorZ* arg_conv = (LDKCResult_NoneSemanticErrorZ*)(arg & ~1);
15256         int64_t ret_val = CResult_NoneSemanticErrorZ_clone_ptr(arg_conv);
15257         return ret_val;
15258 }
15259
15260 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15261         LDKCResult_NoneSemanticErrorZ* orig_conv = (LDKCResult_NoneSemanticErrorZ*)(orig & ~1);
15262         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
15263         *ret_conv = CResult_NoneSemanticErrorZ_clone(orig_conv);
15264         return (uint64_t)ret_conv;
15265 }
15266
15267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15268         LDKInvoice o_conv;
15269         o_conv.inner = (void*)(o & (~1));
15270         o_conv.is_owned = (o & 1) || (o == 0);
15271         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15272         o_conv = Invoice_clone(&o_conv);
15273         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15274         *ret_conv = CResult_InvoiceSemanticErrorZ_ok(o_conv);
15275         return (uint64_t)ret_conv;
15276 }
15277
15278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15279         LDKSemanticError e_conv = LDKSemanticError_from_java(env, e);
15280         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15281         *ret_conv = CResult_InvoiceSemanticErrorZ_err(e_conv);
15282         return (uint64_t)ret_conv;
15283 }
15284
15285 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15286         LDKCResult_InvoiceSemanticErrorZ* o_conv = (LDKCResult_InvoiceSemanticErrorZ*)(o & ~1);
15287         jboolean ret_val = CResult_InvoiceSemanticErrorZ_is_ok(o_conv);
15288         return ret_val;
15289 }
15290
15291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15292         if ((_res & 1) != 0) return;
15293         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15294         CHECK_ACCESS(_res_ptr);
15295         LDKCResult_InvoiceSemanticErrorZ _res_conv = *(LDKCResult_InvoiceSemanticErrorZ*)(_res_ptr);
15296         FREE((void*)_res);
15297         CResult_InvoiceSemanticErrorZ_free(_res_conv);
15298 }
15299
15300 static inline uint64_t CResult_InvoiceSemanticErrorZ_clone_ptr(LDKCResult_InvoiceSemanticErrorZ *NONNULL_PTR arg) {
15301         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15302         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(arg);
15303         return (uint64_t)ret_conv;
15304 }
15305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15306         LDKCResult_InvoiceSemanticErrorZ* arg_conv = (LDKCResult_InvoiceSemanticErrorZ*)(arg & ~1);
15307         int64_t ret_val = CResult_InvoiceSemanticErrorZ_clone_ptr(arg_conv);
15308         return ret_val;
15309 }
15310
15311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSemanticErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15312         LDKCResult_InvoiceSemanticErrorZ* orig_conv = (LDKCResult_InvoiceSemanticErrorZ*)(orig & ~1);
15313         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
15314         *ret_conv = CResult_InvoiceSemanticErrorZ_clone(orig_conv);
15315         return (uint64_t)ret_conv;
15316 }
15317
15318 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15319         LDKDescription o_conv;
15320         o_conv.inner = (void*)(o & (~1));
15321         o_conv.is_owned = (o & 1) || (o == 0);
15322         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15323         o_conv = Description_clone(&o_conv);
15324         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15325         *ret_conv = CResult_DescriptionCreationErrorZ_ok(o_conv);
15326         return (uint64_t)ret_conv;
15327 }
15328
15329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15330         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15331         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15332         *ret_conv = CResult_DescriptionCreationErrorZ_err(e_conv);
15333         return (uint64_t)ret_conv;
15334 }
15335
15336 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15337         LDKCResult_DescriptionCreationErrorZ* o_conv = (LDKCResult_DescriptionCreationErrorZ*)(o & ~1);
15338         jboolean ret_val = CResult_DescriptionCreationErrorZ_is_ok(o_conv);
15339         return ret_val;
15340 }
15341
15342 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15343         if ((_res & 1) != 0) return;
15344         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15345         CHECK_ACCESS(_res_ptr);
15346         LDKCResult_DescriptionCreationErrorZ _res_conv = *(LDKCResult_DescriptionCreationErrorZ*)(_res_ptr);
15347         FREE((void*)_res);
15348         CResult_DescriptionCreationErrorZ_free(_res_conv);
15349 }
15350
15351 static inline uint64_t CResult_DescriptionCreationErrorZ_clone_ptr(LDKCResult_DescriptionCreationErrorZ *NONNULL_PTR arg) {
15352         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15353         *ret_conv = CResult_DescriptionCreationErrorZ_clone(arg);
15354         return (uint64_t)ret_conv;
15355 }
15356 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15357         LDKCResult_DescriptionCreationErrorZ* arg_conv = (LDKCResult_DescriptionCreationErrorZ*)(arg & ~1);
15358         int64_t ret_val = CResult_DescriptionCreationErrorZ_clone_ptr(arg_conv);
15359         return ret_val;
15360 }
15361
15362 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DescriptionCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15363         LDKCResult_DescriptionCreationErrorZ* orig_conv = (LDKCResult_DescriptionCreationErrorZ*)(orig & ~1);
15364         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
15365         *ret_conv = CResult_DescriptionCreationErrorZ_clone(orig_conv);
15366         return (uint64_t)ret_conv;
15367 }
15368
15369 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15370         LDKExpiryTime o_conv;
15371         o_conv.inner = (void*)(o & (~1));
15372         o_conv.is_owned = (o & 1) || (o == 0);
15373         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15374         o_conv = ExpiryTime_clone(&o_conv);
15375         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
15376         *ret_conv = CResult_ExpiryTimeCreationErrorZ_ok(o_conv);
15377         return (uint64_t)ret_conv;
15378 }
15379
15380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15381         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15382         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
15383         *ret_conv = CResult_ExpiryTimeCreationErrorZ_err(e_conv);
15384         return (uint64_t)ret_conv;
15385 }
15386
15387 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15388         LDKCResult_ExpiryTimeCreationErrorZ* o_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(o & ~1);
15389         jboolean ret_val = CResult_ExpiryTimeCreationErrorZ_is_ok(o_conv);
15390         return ret_val;
15391 }
15392
15393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15394         if ((_res & 1) != 0) return;
15395         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15396         CHECK_ACCESS(_res_ptr);
15397         LDKCResult_ExpiryTimeCreationErrorZ _res_conv = *(LDKCResult_ExpiryTimeCreationErrorZ*)(_res_ptr);
15398         FREE((void*)_res);
15399         CResult_ExpiryTimeCreationErrorZ_free(_res_conv);
15400 }
15401
15402 static inline uint64_t CResult_ExpiryTimeCreationErrorZ_clone_ptr(LDKCResult_ExpiryTimeCreationErrorZ *NONNULL_PTR arg) {
15403         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
15404         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(arg);
15405         return (uint64_t)ret_conv;
15406 }
15407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15408         LDKCResult_ExpiryTimeCreationErrorZ* arg_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(arg & ~1);
15409         int64_t ret_val = CResult_ExpiryTimeCreationErrorZ_clone_ptr(arg_conv);
15410         return ret_val;
15411 }
15412
15413 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ExpiryTimeCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15414         LDKCResult_ExpiryTimeCreationErrorZ* orig_conv = (LDKCResult_ExpiryTimeCreationErrorZ*)(orig & ~1);
15415         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
15416         *ret_conv = CResult_ExpiryTimeCreationErrorZ_clone(orig_conv);
15417         return (uint64_t)ret_conv;
15418 }
15419
15420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15421         LDKPrivateRoute o_conv;
15422         o_conv.inner = (void*)(o & (~1));
15423         o_conv.is_owned = (o & 1) || (o == 0);
15424         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15425         o_conv = PrivateRoute_clone(&o_conv);
15426         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15427         *ret_conv = CResult_PrivateRouteCreationErrorZ_ok(o_conv);
15428         return (uint64_t)ret_conv;
15429 }
15430
15431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15432         LDKCreationError e_conv = LDKCreationError_from_java(env, e);
15433         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15434         *ret_conv = CResult_PrivateRouteCreationErrorZ_err(e_conv);
15435         return (uint64_t)ret_conv;
15436 }
15437
15438 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15439         LDKCResult_PrivateRouteCreationErrorZ* o_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(o & ~1);
15440         jboolean ret_val = CResult_PrivateRouteCreationErrorZ_is_ok(o_conv);
15441         return ret_val;
15442 }
15443
15444 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15445         if ((_res & 1) != 0) return;
15446         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15447         CHECK_ACCESS(_res_ptr);
15448         LDKCResult_PrivateRouteCreationErrorZ _res_conv = *(LDKCResult_PrivateRouteCreationErrorZ*)(_res_ptr);
15449         FREE((void*)_res);
15450         CResult_PrivateRouteCreationErrorZ_free(_res_conv);
15451 }
15452
15453 static inline uint64_t CResult_PrivateRouteCreationErrorZ_clone_ptr(LDKCResult_PrivateRouteCreationErrorZ *NONNULL_PTR arg) {
15454         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15455         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(arg);
15456         return (uint64_t)ret_conv;
15457 }
15458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15459         LDKCResult_PrivateRouteCreationErrorZ* arg_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(arg & ~1);
15460         int64_t ret_val = CResult_PrivateRouteCreationErrorZ_clone_ptr(arg_conv);
15461         return ret_val;
15462 }
15463
15464 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PrivateRouteCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15465         LDKCResult_PrivateRouteCreationErrorZ* orig_conv = (LDKCResult_PrivateRouteCreationErrorZ*)(orig & ~1);
15466         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
15467         *ret_conv = CResult_PrivateRouteCreationErrorZ_clone(orig_conv);
15468         return (uint64_t)ret_conv;
15469 }
15470
15471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1ok(JNIEnv *env, jclass clz, jstring o) {
15472         LDKStr o_conv = java_to_owned_str(env, o);
15473         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15474         *ret_conv = CResult_StringErrorZ_ok(o_conv);
15475         return (uint64_t)ret_conv;
15476 }
15477
15478 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1err(JNIEnv *env, jclass clz, jclass e) {
15479         LDKSecp256k1Error e_conv = LDKSecp256k1Error_from_java(env, e);
15480         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
15481         *ret_conv = CResult_StringErrorZ_err(e_conv);
15482         return (uint64_t)ret_conv;
15483 }
15484
15485 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15486         LDKCResult_StringErrorZ* o_conv = (LDKCResult_StringErrorZ*)(o & ~1);
15487         jboolean ret_val = CResult_StringErrorZ_is_ok(o_conv);
15488         return ret_val;
15489 }
15490
15491 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1StringErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15492         if ((_res & 1) != 0) return;
15493         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15494         CHECK_ACCESS(_res_ptr);
15495         LDKCResult_StringErrorZ _res_conv = *(LDKCResult_StringErrorZ*)(_res_ptr);
15496         FREE((void*)_res);
15497         CResult_StringErrorZ_free(_res_conv);
15498 }
15499
15500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15501         LDKChannelMonitorUpdate o_conv;
15502         o_conv.inner = (void*)(o & (~1));
15503         o_conv.is_owned = (o & 1) || (o == 0);
15504         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15505         o_conv = ChannelMonitorUpdate_clone(&o_conv);
15506         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15507         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_ok(o_conv);
15508         return (uint64_t)ret_conv;
15509 }
15510
15511 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15512         LDKDecodeError e_conv;
15513         e_conv.inner = (void*)(e & (~1));
15514         e_conv.is_owned = (e & 1) || (e == 0);
15515         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15516         e_conv = DecodeError_clone(&e_conv);
15517         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15518         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_err(e_conv);
15519         return (uint64_t)ret_conv;
15520 }
15521
15522 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15523         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(o & ~1);
15524         jboolean ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_is_ok(o_conv);
15525         return ret_val;
15526 }
15527
15528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15529         if ((_res & 1) != 0) return;
15530         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15531         CHECK_ACCESS(_res_ptr);
15532         LDKCResult_ChannelMonitorUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(_res_ptr);
15533         FREE((void*)_res);
15534         CResult_ChannelMonitorUpdateDecodeErrorZ_free(_res_conv);
15535 }
15536
15537 static inline uint64_t CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelMonitorUpdateDecodeErrorZ *NONNULL_PTR arg) {
15538         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15539         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(arg);
15540         return (uint64_t)ret_conv;
15541 }
15542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15543         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(arg & ~1);
15544         int64_t ret_val = CResult_ChannelMonitorUpdateDecodeErrorZ_clone_ptr(arg_conv);
15545         return ret_val;
15546 }
15547
15548 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelMonitorUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15549         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelMonitorUpdateDecodeErrorZ*)(orig & ~1);
15550         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
15551         *ret_conv = CResult_ChannelMonitorUpdateDecodeErrorZ_clone(orig_conv);
15552         return (uint64_t)ret_conv;
15553 }
15554
15555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1some(JNIEnv *env, jclass clz, int64_t o) {
15556         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15557         CHECK_ACCESS(o_ptr);
15558         LDKMonitorEvent o_conv = *(LDKMonitorEvent*)(o_ptr);
15559         o_conv = MonitorEvent_clone((LDKMonitorEvent*)(((uint64_t)o) & ~1));
15560         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15561         *ret_copy = COption_MonitorEventZ_some(o_conv);
15562         uint64_t ret_ref = (uint64_t)ret_copy;
15563         return ret_ref;
15564 }
15565
15566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1none(JNIEnv *env, jclass clz) {
15567         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15568         *ret_copy = COption_MonitorEventZ_none();
15569         uint64_t ret_ref = (uint64_t)ret_copy;
15570         return ret_ref;
15571 }
15572
15573 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15574         if ((_res & 1) != 0) return;
15575         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15576         CHECK_ACCESS(_res_ptr);
15577         LDKCOption_MonitorEventZ _res_conv = *(LDKCOption_MonitorEventZ*)(_res_ptr);
15578         FREE((void*)_res);
15579         COption_MonitorEventZ_free(_res_conv);
15580 }
15581
15582 static inline uint64_t COption_MonitorEventZ_clone_ptr(LDKCOption_MonitorEventZ *NONNULL_PTR arg) {
15583         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15584         *ret_copy = COption_MonitorEventZ_clone(arg);
15585 uint64_t ret_ref = (uint64_t)ret_copy;
15586         return ret_ref;
15587 }
15588 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15589         LDKCOption_MonitorEventZ* arg_conv = (LDKCOption_MonitorEventZ*)arg;
15590         int64_t ret_val = COption_MonitorEventZ_clone_ptr(arg_conv);
15591         return ret_val;
15592 }
15593
15594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1MonitorEventZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15595         LDKCOption_MonitorEventZ* orig_conv = (LDKCOption_MonitorEventZ*)orig;
15596         LDKCOption_MonitorEventZ *ret_copy = MALLOC(sizeof(LDKCOption_MonitorEventZ), "LDKCOption_MonitorEventZ");
15597         *ret_copy = COption_MonitorEventZ_clone(orig_conv);
15598         uint64_t ret_ref = (uint64_t)ret_copy;
15599         return ret_ref;
15600 }
15601
15602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15603         void* o_ptr = (void*)(((uint64_t)o) & ~1);
15604         CHECK_ACCESS(o_ptr);
15605         LDKCOption_MonitorEventZ o_conv = *(LDKCOption_MonitorEventZ*)(o_ptr);
15606         o_conv = COption_MonitorEventZ_clone((LDKCOption_MonitorEventZ*)(((uint64_t)o) & ~1));
15607         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15608         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_ok(o_conv);
15609         return (uint64_t)ret_conv;
15610 }
15611
15612 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15613         LDKDecodeError e_conv;
15614         e_conv.inner = (void*)(e & (~1));
15615         e_conv.is_owned = (e & 1) || (e == 0);
15616         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15617         e_conv = DecodeError_clone(&e_conv);
15618         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15619         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_err(e_conv);
15620         return (uint64_t)ret_conv;
15621 }
15622
15623 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15624         LDKCResult_COption_MonitorEventZDecodeErrorZ* o_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(o & ~1);
15625         jboolean ret_val = CResult_COption_MonitorEventZDecodeErrorZ_is_ok(o_conv);
15626         return ret_val;
15627 }
15628
15629 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15630         if ((_res & 1) != 0) return;
15631         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15632         CHECK_ACCESS(_res_ptr);
15633         LDKCResult_COption_MonitorEventZDecodeErrorZ _res_conv = *(LDKCResult_COption_MonitorEventZDecodeErrorZ*)(_res_ptr);
15634         FREE((void*)_res);
15635         CResult_COption_MonitorEventZDecodeErrorZ_free(_res_conv);
15636 }
15637
15638 static inline uint64_t CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(LDKCResult_COption_MonitorEventZDecodeErrorZ *NONNULL_PTR arg) {
15639         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15640         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(arg);
15641         return (uint64_t)ret_conv;
15642 }
15643 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15644         LDKCResult_COption_MonitorEventZDecodeErrorZ* arg_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(arg & ~1);
15645         int64_t ret_val = CResult_COption_MonitorEventZDecodeErrorZ_clone_ptr(arg_conv);
15646         return ret_val;
15647 }
15648
15649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1MonitorEventZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15650         LDKCResult_COption_MonitorEventZDecodeErrorZ* orig_conv = (LDKCResult_COption_MonitorEventZDecodeErrorZ*)(orig & ~1);
15651         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
15652         *ret_conv = CResult_COption_MonitorEventZDecodeErrorZ_clone(orig_conv);
15653         return (uint64_t)ret_conv;
15654 }
15655
15656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
15657         LDKHTLCUpdate o_conv;
15658         o_conv.inner = (void*)(o & (~1));
15659         o_conv.is_owned = (o & 1) || (o == 0);
15660         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
15661         o_conv = HTLCUpdate_clone(&o_conv);
15662         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15663         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_ok(o_conv);
15664         return (uint64_t)ret_conv;
15665 }
15666
15667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15668         LDKDecodeError e_conv;
15669         e_conv.inner = (void*)(e & (~1));
15670         e_conv.is_owned = (e & 1) || (e == 0);
15671         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15672         e_conv = DecodeError_clone(&e_conv);
15673         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15674         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_err(e_conv);
15675         return (uint64_t)ret_conv;
15676 }
15677
15678 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15679         LDKCResult_HTLCUpdateDecodeErrorZ* o_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(o & ~1);
15680         jboolean ret_val = CResult_HTLCUpdateDecodeErrorZ_is_ok(o_conv);
15681         return ret_val;
15682 }
15683
15684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15685         if ((_res & 1) != 0) return;
15686         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15687         CHECK_ACCESS(_res_ptr);
15688         LDKCResult_HTLCUpdateDecodeErrorZ _res_conv = *(LDKCResult_HTLCUpdateDecodeErrorZ*)(_res_ptr);
15689         FREE((void*)_res);
15690         CResult_HTLCUpdateDecodeErrorZ_free(_res_conv);
15691 }
15692
15693 static inline uint64_t CResult_HTLCUpdateDecodeErrorZ_clone_ptr(LDKCResult_HTLCUpdateDecodeErrorZ *NONNULL_PTR arg) {
15694         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15695         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(arg);
15696         return (uint64_t)ret_conv;
15697 }
15698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15699         LDKCResult_HTLCUpdateDecodeErrorZ* arg_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(arg & ~1);
15700         int64_t ret_val = CResult_HTLCUpdateDecodeErrorZ_clone_ptr(arg_conv);
15701         return ret_val;
15702 }
15703
15704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1HTLCUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15705         LDKCResult_HTLCUpdateDecodeErrorZ* orig_conv = (LDKCResult_HTLCUpdateDecodeErrorZ*)(orig & ~1);
15706         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
15707         *ret_conv = CResult_HTLCUpdateDecodeErrorZ_clone(orig_conv);
15708         return (uint64_t)ret_conv;
15709 }
15710
15711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1ok(JNIEnv *env, jclass clz) {
15712         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15713         *ret_conv = CResult_NoneMonitorUpdateErrorZ_ok();
15714         return (uint64_t)ret_conv;
15715 }
15716
15717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
15718         LDKMonitorUpdateError e_conv;
15719         e_conv.inner = (void*)(e & (~1));
15720         e_conv.is_owned = (e & 1) || (e == 0);
15721         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
15722         e_conv = MonitorUpdateError_clone(&e_conv);
15723         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15724         *ret_conv = CResult_NoneMonitorUpdateErrorZ_err(e_conv);
15725         return (uint64_t)ret_conv;
15726 }
15727
15728 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
15729         LDKCResult_NoneMonitorUpdateErrorZ* o_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(o & ~1);
15730         jboolean ret_val = CResult_NoneMonitorUpdateErrorZ_is_ok(o_conv);
15731         return ret_val;
15732 }
15733
15734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15735         if ((_res & 1) != 0) return;
15736         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15737         CHECK_ACCESS(_res_ptr);
15738         LDKCResult_NoneMonitorUpdateErrorZ _res_conv = *(LDKCResult_NoneMonitorUpdateErrorZ*)(_res_ptr);
15739         FREE((void*)_res);
15740         CResult_NoneMonitorUpdateErrorZ_free(_res_conv);
15741 }
15742
15743 static inline uint64_t CResult_NoneMonitorUpdateErrorZ_clone_ptr(LDKCResult_NoneMonitorUpdateErrorZ *NONNULL_PTR arg) {
15744         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15745         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(arg);
15746         return (uint64_t)ret_conv;
15747 }
15748 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15749         LDKCResult_NoneMonitorUpdateErrorZ* arg_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(arg & ~1);
15750         int64_t ret_val = CResult_NoneMonitorUpdateErrorZ_clone_ptr(arg_conv);
15751         return ret_val;
15752 }
15753
15754 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneMonitorUpdateErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15755         LDKCResult_NoneMonitorUpdateErrorZ* orig_conv = (LDKCResult_NoneMonitorUpdateErrorZ*)(orig & ~1);
15756         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
15757         *ret_conv = CResult_NoneMonitorUpdateErrorZ_clone(orig_conv);
15758         return (uint64_t)ret_conv;
15759 }
15760
15761 static inline uint64_t C2Tuple_OutPointScriptZ_clone_ptr(LDKC2Tuple_OutPointScriptZ *NONNULL_PTR arg) {
15762         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15763         *ret_conv = C2Tuple_OutPointScriptZ_clone(arg);
15764         return ((uint64_t)ret_conv);
15765 }
15766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15767         LDKC2Tuple_OutPointScriptZ* arg_conv = (LDKC2Tuple_OutPointScriptZ*)(arg & ~1);
15768         int64_t ret_val = C2Tuple_OutPointScriptZ_clone_ptr(arg_conv);
15769         return ret_val;
15770 }
15771
15772 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15773         LDKC2Tuple_OutPointScriptZ* orig_conv = (LDKC2Tuple_OutPointScriptZ*)(orig & ~1);
15774         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15775         *ret_conv = C2Tuple_OutPointScriptZ_clone(orig_conv);
15776         return ((uint64_t)ret_conv);
15777 }
15778
15779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1new(JNIEnv *env, jclass clz, int64_t a, int8_tArray b) {
15780         LDKOutPoint a_conv;
15781         a_conv.inner = (void*)(a & (~1));
15782         a_conv.is_owned = (a & 1) || (a == 0);
15783         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
15784         a_conv = OutPoint_clone(&a_conv);
15785         LDKCVec_u8Z b_ref;
15786         b_ref.datalen = (*env)->GetArrayLength(env, b);
15787         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15788         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15789         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
15790         *ret_conv = C2Tuple_OutPointScriptZ_new(a_conv, b_ref);
15791         return ((uint64_t)ret_conv);
15792 }
15793
15794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1OutPointScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15795         if ((_res & 1) != 0) return;
15796         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15797         CHECK_ACCESS(_res_ptr);
15798         LDKC2Tuple_OutPointScriptZ _res_conv = *(LDKC2Tuple_OutPointScriptZ*)(_res_ptr);
15799         FREE((void*)_res);
15800         C2Tuple_OutPointScriptZ_free(_res_conv);
15801 }
15802
15803 static inline uint64_t C2Tuple_u32ScriptZ_clone_ptr(LDKC2Tuple_u32ScriptZ *NONNULL_PTR arg) {
15804         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15805         *ret_conv = C2Tuple_u32ScriptZ_clone(arg);
15806         return ((uint64_t)ret_conv);
15807 }
15808 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15809         LDKC2Tuple_u32ScriptZ* arg_conv = (LDKC2Tuple_u32ScriptZ*)(arg & ~1);
15810         int64_t ret_val = C2Tuple_u32ScriptZ_clone_ptr(arg_conv);
15811         return ret_val;
15812 }
15813
15814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15815         LDKC2Tuple_u32ScriptZ* orig_conv = (LDKC2Tuple_u32ScriptZ*)(orig & ~1);
15816         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15817         *ret_conv = C2Tuple_u32ScriptZ_clone(orig_conv);
15818         return ((uint64_t)ret_conv);
15819 }
15820
15821 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1new(JNIEnv *env, jclass clz, int32_t a, int8_tArray b) {
15822         LDKCVec_u8Z b_ref;
15823         b_ref.datalen = (*env)->GetArrayLength(env, b);
15824         b_ref.data = MALLOC(b_ref.datalen, "LDKCVec_u8Z Bytes");
15825         (*env)->GetByteArrayRegion(env, b, 0, b_ref.datalen, b_ref.data);
15826         LDKC2Tuple_u32ScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32ScriptZ), "LDKC2Tuple_u32ScriptZ");
15827         *ret_conv = C2Tuple_u32ScriptZ_new(a, b_ref);
15828         return ((uint64_t)ret_conv);
15829 }
15830
15831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32ScriptZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15832         if ((_res & 1) != 0) return;
15833         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15834         CHECK_ACCESS(_res_ptr);
15835         LDKC2Tuple_u32ScriptZ _res_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_ptr);
15836         FREE((void*)_res);
15837         C2Tuple_u32ScriptZ_free(_res_conv);
15838 }
15839
15840 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32ScriptZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15841         LDKCVec_C2Tuple_u32ScriptZZ _res_constr;
15842         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15843         if (_res_constr.datalen > 0)
15844                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15845         else
15846                 _res_constr.data = NULL;
15847         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15848         for (size_t v = 0; v < _res_constr.datalen; v++) {
15849                 int64_t _res_conv_21 = _res_vals[v];
15850                 void* _res_conv_21_ptr = (void*)(((uint64_t)_res_conv_21) & ~1);
15851                 CHECK_ACCESS(_res_conv_21_ptr);
15852                 LDKC2Tuple_u32ScriptZ _res_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(_res_conv_21_ptr);
15853                 FREE((void*)_res_conv_21);
15854                 _res_constr.data[v] = _res_conv_21_conv;
15855         }
15856         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15857         CVec_C2Tuple_u32ScriptZZ_free(_res_constr);
15858 }
15859
15860 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ *NONNULL_PTR arg) {
15861         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15862         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(arg);
15863         return ((uint64_t)ret_conv);
15864 }
15865 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15866         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(arg & ~1);
15867         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone_ptr(arg_conv);
15868         return ret_val;
15869 }
15870
15871 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15872         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(orig & ~1);
15873         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15874         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_clone(orig_conv);
15875         return ((uint64_t)ret_conv);
15876 }
15877
15878 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
15879         LDKThirtyTwoBytes a_ref;
15880         CHECK((*env)->GetArrayLength(env, a) == 32);
15881         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
15882         LDKCVec_C2Tuple_u32ScriptZZ b_constr;
15883         b_constr.datalen = (*env)->GetArrayLength(env, b);
15884         if (b_constr.datalen > 0)
15885                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32ScriptZ), "LDKCVec_C2Tuple_u32ScriptZZ Elements");
15886         else
15887                 b_constr.data = NULL;
15888         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
15889         for (size_t v = 0; v < b_constr.datalen; v++) {
15890                 int64_t b_conv_21 = b_vals[v];
15891                 void* b_conv_21_ptr = (void*)(((uint64_t)b_conv_21) & ~1);
15892                 CHECK_ACCESS(b_conv_21_ptr);
15893                 LDKC2Tuple_u32ScriptZ b_conv_21_conv = *(LDKC2Tuple_u32ScriptZ*)(b_conv_21_ptr);
15894                 b_conv_21_conv = C2Tuple_u32ScriptZ_clone((LDKC2Tuple_u32ScriptZ*)(((uint64_t)b_conv_21) & ~1));
15895                 b_constr.data[v] = b_conv_21_conv;
15896         }
15897         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
15898         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
15899         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_new(a_ref, b_constr);
15900         return ((uint64_t)ret_conv);
15901 }
15902
15903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
15904         if ((_res & 1) != 0) return;
15905         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
15906         CHECK_ACCESS(_res_ptr);
15907         LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_ptr);
15908         FREE((void*)_res);
15909         C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ_free(_res_conv);
15910 }
15911
15912 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32ScriptZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15913         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ _res_constr;
15914         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15915         if (_res_constr.datalen > 0)
15916                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ Elements");
15917         else
15918                 _res_constr.data = NULL;
15919         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15920         for (size_t o = 0; o < _res_constr.datalen; o++) {
15921                 int64_t _res_conv_40 = _res_vals[o];
15922                 void* _res_conv_40_ptr = (void*)(((uint64_t)_res_conv_40) & ~1);
15923                 CHECK_ACCESS(_res_conv_40_ptr);
15924                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ _res_conv_40_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ*)(_res_conv_40_ptr);
15925                 FREE((void*)_res_conv_40);
15926                 _res_constr.data[o] = _res_conv_40_conv;
15927         }
15928         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15929         CVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ_free(_res_constr);
15930 }
15931
15932 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1EventZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
15933         LDKCVec_EventZ _res_constr;
15934         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15935         if (_res_constr.datalen > 0)
15936                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKEvent), "LDKCVec_EventZ Elements");
15937         else
15938                 _res_constr.data = NULL;
15939         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
15940         for (size_t h = 0; h < _res_constr.datalen; h++) {
15941                 int64_t _res_conv_7 = _res_vals[h];
15942                 void* _res_conv_7_ptr = (void*)(((uint64_t)_res_conv_7) & ~1);
15943                 CHECK_ACCESS(_res_conv_7_ptr);
15944                 LDKEvent _res_conv_7_conv = *(LDKEvent*)(_res_conv_7_ptr);
15945                 FREE((void*)_res_conv_7);
15946                 _res_constr.data[h] = _res_conv_7_conv;
15947         }
15948         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
15949         CVec_EventZ_free(_res_constr);
15950 }
15951
15952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1TransactionZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
15953         LDKCVec_TransactionZ _res_constr;
15954         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
15955         if (_res_constr.datalen > 0)
15956                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKTransaction), "LDKCVec_TransactionZ Elements");
15957         else
15958                 _res_constr.data = NULL;
15959         for (size_t i = 0; i < _res_constr.datalen; i++) {
15960                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
15961                 LDKTransaction _res_conv_8_ref;
15962                 _res_conv_8_ref.datalen = (*env)->GetArrayLength(env, _res_conv_8);
15963                 _res_conv_8_ref.data = MALLOC(_res_conv_8_ref.datalen, "LDKTransaction Bytes");
15964                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, _res_conv_8_ref.datalen, _res_conv_8_ref.data);
15965                 _res_conv_8_ref.data_is_owned = true;
15966                 _res_constr.data[i] = _res_conv_8_ref;
15967         }
15968         CVec_TransactionZ_free(_res_constr);
15969 }
15970
15971 static inline uint64_t C2Tuple_u32TxOutZ_clone_ptr(LDKC2Tuple_u32TxOutZ *NONNULL_PTR arg) {
15972         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15973         *ret_conv = C2Tuple_u32TxOutZ_clone(arg);
15974         return ((uint64_t)ret_conv);
15975 }
15976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
15977         LDKC2Tuple_u32TxOutZ* arg_conv = (LDKC2Tuple_u32TxOutZ*)(arg & ~1);
15978         int64_t ret_val = C2Tuple_u32TxOutZ_clone_ptr(arg_conv);
15979         return ret_val;
15980 }
15981
15982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
15983         LDKC2Tuple_u32TxOutZ* orig_conv = (LDKC2Tuple_u32TxOutZ*)(orig & ~1);
15984         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15985         *ret_conv = C2Tuple_u32TxOutZ_clone(orig_conv);
15986         return ((uint64_t)ret_conv);
15987 }
15988
15989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1new(JNIEnv *env, jclass clz, int32_t a, int64_t b) {
15990         void* b_ptr = (void*)(((uint64_t)b) & ~1);
15991         CHECK_ACCESS(b_ptr);
15992         LDKTxOut b_conv = *(LDKTxOut*)(b_ptr);
15993         b_conv = TxOut_clone((LDKTxOut*)(((uint64_t)b) & ~1));
15994         LDKC2Tuple_u32TxOutZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_u32TxOutZ), "LDKC2Tuple_u32TxOutZ");
15995         *ret_conv = C2Tuple_u32TxOutZ_new(a, b_conv);
15996         return ((uint64_t)ret_conv);
15997 }
15998
15999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1u32TxOutZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16000         if ((_res & 1) != 0) return;
16001         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16002         CHECK_ACCESS(_res_ptr);
16003         LDKC2Tuple_u32TxOutZ _res_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_ptr);
16004         FREE((void*)_res);
16005         C2Tuple_u32TxOutZ_free(_res_conv);
16006 }
16007
16008 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1u32TxOutZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16009         LDKCVec_C2Tuple_u32TxOutZZ _res_constr;
16010         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16011         if (_res_constr.datalen > 0)
16012                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16013         else
16014                 _res_constr.data = NULL;
16015         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16016         for (size_t u = 0; u < _res_constr.datalen; u++) {
16017                 int64_t _res_conv_20 = _res_vals[u];
16018                 void* _res_conv_20_ptr = (void*)(((uint64_t)_res_conv_20) & ~1);
16019                 CHECK_ACCESS(_res_conv_20_ptr);
16020                 LDKC2Tuple_u32TxOutZ _res_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(_res_conv_20_ptr);
16021                 FREE((void*)_res_conv_20);
16022                 _res_constr.data[u] = _res_conv_20_conv;
16023         }
16024         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16025         CVec_C2Tuple_u32TxOutZZ_free(_res_constr);
16026 }
16027
16028 static inline uint64_t C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ *NONNULL_PTR arg) {
16029         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16030         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(arg);
16031         return ((uint64_t)ret_conv);
16032 }
16033 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16034         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* arg_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(arg & ~1);
16035         int64_t ret_val = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone_ptr(arg_conv);
16036         return ret_val;
16037 }
16038
16039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16040         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* orig_conv = (LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(orig & ~1);
16041         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16042         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_clone(orig_conv);
16043         return ((uint64_t)ret_conv);
16044 }
16045
16046 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_tArray b) {
16047         LDKThirtyTwoBytes a_ref;
16048         CHECK((*env)->GetArrayLength(env, a) == 32);
16049         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
16050         LDKCVec_C2Tuple_u32TxOutZZ b_constr;
16051         b_constr.datalen = (*env)->GetArrayLength(env, b);
16052         if (b_constr.datalen > 0)
16053                 b_constr.data = MALLOC(b_constr.datalen * sizeof(LDKC2Tuple_u32TxOutZ), "LDKCVec_C2Tuple_u32TxOutZZ Elements");
16054         else
16055                 b_constr.data = NULL;
16056         int64_t* b_vals = (*env)->GetLongArrayElements (env, b, NULL);
16057         for (size_t u = 0; u < b_constr.datalen; u++) {
16058                 int64_t b_conv_20 = b_vals[u];
16059                 void* b_conv_20_ptr = (void*)(((uint64_t)b_conv_20) & ~1);
16060                 CHECK_ACCESS(b_conv_20_ptr);
16061                 LDKC2Tuple_u32TxOutZ b_conv_20_conv = *(LDKC2Tuple_u32TxOutZ*)(b_conv_20_ptr);
16062                 b_conv_20_conv = C2Tuple_u32TxOutZ_clone((LDKC2Tuple_u32TxOutZ*)(((uint64_t)b_conv_20) & ~1));
16063                 b_constr.data[u] = b_conv_20_conv;
16064         }
16065         (*env)->ReleaseLongArrayElements(env, b, b_vals, 0);
16066         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
16067         *ret_conv = C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_new(a_ref, b_constr);
16068         return ((uint64_t)ret_conv);
16069 }
16070
16071 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16072         if ((_res & 1) != 0) return;
16073         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16074         CHECK_ACCESS(_res_ptr);
16075         LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_ptr);
16076         FREE((void*)_res);
16077         C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ_free(_res_conv);
16078 }
16079
16080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1TxidCVec_1C2Tuple_1u32TxOutZZZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16081         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ _res_constr;
16082         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16083         if (_res_constr.datalen > 0)
16084                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ Elements");
16085         else
16086                 _res_constr.data = NULL;
16087         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16088         for (size_t n = 0; n < _res_constr.datalen; n++) {
16089                 int64_t _res_conv_39 = _res_vals[n];
16090                 void* _res_conv_39_ptr = (void*)(((uint64_t)_res_conv_39) & ~1);
16091                 CHECK_ACCESS(_res_conv_39_ptr);
16092                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ _res_conv_39_conv = *(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ*)(_res_conv_39_ptr);
16093                 FREE((void*)_res_conv_39);
16094                 _res_constr.data[n] = _res_conv_39_conv;
16095         }
16096         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16097         CVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ_free(_res_constr);
16098 }
16099
16100 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1BalanceZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16101         LDKCVec_BalanceZ _res_constr;
16102         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16103         if (_res_constr.datalen > 0)
16104                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKBalance), "LDKCVec_BalanceZ Elements");
16105         else
16106                 _res_constr.data = NULL;
16107         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16108         for (size_t j = 0; j < _res_constr.datalen; j++) {
16109                 int64_t _res_conv_9 = _res_vals[j];
16110                 void* _res_conv_9_ptr = (void*)(((uint64_t)_res_conv_9) & ~1);
16111                 CHECK_ACCESS(_res_conv_9_ptr);
16112                 LDKBalance _res_conv_9_conv = *(LDKBalance*)(_res_conv_9_ptr);
16113                 FREE((void*)_res_conv_9);
16114                 _res_constr.data[j] = _res_conv_9_conv;
16115         }
16116         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16117         CVec_BalanceZ_free(_res_constr);
16118 }
16119
16120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16121         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16122         CHECK_ACCESS(o_ptr);
16123         LDKC2Tuple_BlockHashChannelMonitorZ o_conv = *(LDKC2Tuple_BlockHashChannelMonitorZ*)(o_ptr);
16124         o_conv = C2Tuple_BlockHashChannelMonitorZ_clone((LDKC2Tuple_BlockHashChannelMonitorZ*)(((uint64_t)o) & ~1));
16125         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16126         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_ok(o_conv);
16127         return (uint64_t)ret_conv;
16128 }
16129
16130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16131         LDKDecodeError e_conv;
16132         e_conv.inner = (void*)(e & (~1));
16133         e_conv.is_owned = (e & 1) || (e == 0);
16134         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16135         e_conv = DecodeError_clone(&e_conv);
16136         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16137         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_err(e_conv);
16138         return (uint64_t)ret_conv;
16139 }
16140
16141 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16142         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* o_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(o & ~1);
16143         jboolean ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_is_ok(o_conv);
16144         return ret_val;
16145 }
16146
16147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16148         if ((_res & 1) != 0) return;
16149         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16150         CHECK_ACCESS(_res_ptr);
16151         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ _res_conv = *(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(_res_ptr);
16152         FREE((void*)_res);
16153         CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_free(_res_conv);
16154 }
16155
16156 static inline uint64_t CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ *NONNULL_PTR arg) {
16157         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16158         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(arg);
16159         return (uint64_t)ret_conv;
16160 }
16161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16162         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* arg_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(arg & ~1);
16163         int64_t ret_val = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone_ptr(arg_conv);
16164         return ret_val;
16165 }
16166
16167 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1C2Tuple_1BlockHashChannelMonitorZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16168         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* orig_conv = (LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ*)(orig & ~1);
16169         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
16170         *ret_conv = CResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ_clone(orig_conv);
16171         return (uint64_t)ret_conv;
16172 }
16173
16174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1ok(JNIEnv *env, jclass clz) {
16175         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16176         *ret_conv = CResult_NoneLightningErrorZ_ok();
16177         return (uint64_t)ret_conv;
16178 }
16179
16180 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16181         LDKLightningError e_conv;
16182         e_conv.inner = (void*)(e & (~1));
16183         e_conv.is_owned = (e & 1) || (e == 0);
16184         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16185         e_conv = LightningError_clone(&e_conv);
16186         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16187         *ret_conv = CResult_NoneLightningErrorZ_err(e_conv);
16188         return (uint64_t)ret_conv;
16189 }
16190
16191 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16192         LDKCResult_NoneLightningErrorZ* o_conv = (LDKCResult_NoneLightningErrorZ*)(o & ~1);
16193         jboolean ret_val = CResult_NoneLightningErrorZ_is_ok(o_conv);
16194         return ret_val;
16195 }
16196
16197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16198         if ((_res & 1) != 0) return;
16199         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16200         CHECK_ACCESS(_res_ptr);
16201         LDKCResult_NoneLightningErrorZ _res_conv = *(LDKCResult_NoneLightningErrorZ*)(_res_ptr);
16202         FREE((void*)_res);
16203         CResult_NoneLightningErrorZ_free(_res_conv);
16204 }
16205
16206 static inline uint64_t CResult_NoneLightningErrorZ_clone_ptr(LDKCResult_NoneLightningErrorZ *NONNULL_PTR arg) {
16207         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16208         *ret_conv = CResult_NoneLightningErrorZ_clone(arg);
16209         return (uint64_t)ret_conv;
16210 }
16211 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16212         LDKCResult_NoneLightningErrorZ* arg_conv = (LDKCResult_NoneLightningErrorZ*)(arg & ~1);
16213         int64_t ret_val = CResult_NoneLightningErrorZ_clone_ptr(arg_conv);
16214         return ret_val;
16215 }
16216
16217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NoneLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16218         LDKCResult_NoneLightningErrorZ* orig_conv = (LDKCResult_NoneLightningErrorZ*)(orig & ~1);
16219         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
16220         *ret_conv = CResult_NoneLightningErrorZ_clone(orig_conv);
16221         return (uint64_t)ret_conv;
16222 }
16223
16224 static inline uint64_t C2Tuple_PublicKeyTypeZ_clone_ptr(LDKC2Tuple_PublicKeyTypeZ *NONNULL_PTR arg) {
16225         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16226         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(arg);
16227         return ((uint64_t)ret_conv);
16228 }
16229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16230         LDKC2Tuple_PublicKeyTypeZ* arg_conv = (LDKC2Tuple_PublicKeyTypeZ*)(arg & ~1);
16231         int64_t ret_val = C2Tuple_PublicKeyTypeZ_clone_ptr(arg_conv);
16232         return ret_val;
16233 }
16234
16235 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16236         LDKC2Tuple_PublicKeyTypeZ* orig_conv = (LDKC2Tuple_PublicKeyTypeZ*)(orig & ~1);
16237         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16238         *ret_conv = C2Tuple_PublicKeyTypeZ_clone(orig_conv);
16239         return ((uint64_t)ret_conv);
16240 }
16241
16242 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1new(JNIEnv *env, jclass clz, int8_tArray a, int64_t b) {
16243         LDKPublicKey a_ref;
16244         CHECK((*env)->GetArrayLength(env, a) == 33);
16245         (*env)->GetByteArrayRegion(env, a, 0, 33, a_ref.compressed_form);
16246         void* b_ptr = (void*)(((uint64_t)b) & ~1);
16247         CHECK_ACCESS(b_ptr);
16248         LDKType b_conv = *(LDKType*)(b_ptr);
16249         if (b_conv.free == LDKType_JCalls_free) {
16250                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16251                 LDKType_JCalls_cloned(&b_conv);
16252         }
16253         LDKC2Tuple_PublicKeyTypeZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKC2Tuple_PublicKeyTypeZ");
16254         *ret_conv = C2Tuple_PublicKeyTypeZ_new(a_ref, b_conv);
16255         return ((uint64_t)ret_conv);
16256 }
16257
16258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C2Tuple_1PublicKeyTypeZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16259         if ((_res & 1) != 0) return;
16260         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16261         CHECK_ACCESS(_res_ptr);
16262         LDKC2Tuple_PublicKeyTypeZ _res_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_ptr);
16263         FREE((void*)_res);
16264         C2Tuple_PublicKeyTypeZ_free(_res_conv);
16265 }
16266
16267 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C2Tuple_1PublicKeyTypeZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16268         LDKCVec_C2Tuple_PublicKeyTypeZZ _res_constr;
16269         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16270         if (_res_constr.datalen > 0)
16271                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC2Tuple_PublicKeyTypeZ), "LDKCVec_C2Tuple_PublicKeyTypeZZ Elements");
16272         else
16273                 _res_constr.data = NULL;
16274         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16275         for (size_t z = 0; z < _res_constr.datalen; z++) {
16276                 int64_t _res_conv_25 = _res_vals[z];
16277                 void* _res_conv_25_ptr = (void*)(((uint64_t)_res_conv_25) & ~1);
16278                 CHECK_ACCESS(_res_conv_25_ptr);
16279                 LDKC2Tuple_PublicKeyTypeZ _res_conv_25_conv = *(LDKC2Tuple_PublicKeyTypeZ*)(_res_conv_25_ptr);
16280                 FREE((void*)_res_conv_25);
16281                 _res_constr.data[z] = _res_conv_25_conv;
16282         }
16283         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16284         CVec_C2Tuple_PublicKeyTypeZZ_free(_res_constr);
16285 }
16286
16287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
16288         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16289         *ret_conv = CResult_boolLightningErrorZ_ok(o);
16290         return (uint64_t)ret_conv;
16291 }
16292
16293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16294         LDKLightningError e_conv;
16295         e_conv.inner = (void*)(e & (~1));
16296         e_conv.is_owned = (e & 1) || (e == 0);
16297         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16298         e_conv = LightningError_clone(&e_conv);
16299         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16300         *ret_conv = CResult_boolLightningErrorZ_err(e_conv);
16301         return (uint64_t)ret_conv;
16302 }
16303
16304 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16305         LDKCResult_boolLightningErrorZ* o_conv = (LDKCResult_boolLightningErrorZ*)(o & ~1);
16306         jboolean ret_val = CResult_boolLightningErrorZ_is_ok(o_conv);
16307         return ret_val;
16308 }
16309
16310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16311         if ((_res & 1) != 0) return;
16312         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16313         CHECK_ACCESS(_res_ptr);
16314         LDKCResult_boolLightningErrorZ _res_conv = *(LDKCResult_boolLightningErrorZ*)(_res_ptr);
16315         FREE((void*)_res);
16316         CResult_boolLightningErrorZ_free(_res_conv);
16317 }
16318
16319 static inline uint64_t CResult_boolLightningErrorZ_clone_ptr(LDKCResult_boolLightningErrorZ *NONNULL_PTR arg) {
16320         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16321         *ret_conv = CResult_boolLightningErrorZ_clone(arg);
16322         return (uint64_t)ret_conv;
16323 }
16324 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16325         LDKCResult_boolLightningErrorZ* arg_conv = (LDKCResult_boolLightningErrorZ*)(arg & ~1);
16326         int64_t ret_val = CResult_boolLightningErrorZ_clone_ptr(arg_conv);
16327         return ret_val;
16328 }
16329
16330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolLightningErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16331         LDKCResult_boolLightningErrorZ* orig_conv = (LDKCResult_boolLightningErrorZ*)(orig & ~1);
16332         LDKCResult_boolLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolLightningErrorZ), "LDKCResult_boolLightningErrorZ");
16333         *ret_conv = CResult_boolLightningErrorZ_clone(orig_conv);
16334         return (uint64_t)ret_conv;
16335 }
16336
16337 static inline uint64_t C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ *NONNULL_PTR arg) {
16338         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16339         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(arg);
16340         return ((uint64_t)ret_conv);
16341 }
16342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16343         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* arg_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(arg & ~1);
16344         int64_t ret_val = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone_ptr(arg_conv);
16345         return ret_val;
16346 }
16347
16348 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16349         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* orig_conv = (LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(orig & ~1);
16350         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16351         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_clone(orig_conv);
16352         return ((uint64_t)ret_conv);
16353 }
16354
16355 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) {
16356         LDKChannelAnnouncement a_conv;
16357         a_conv.inner = (void*)(a & (~1));
16358         a_conv.is_owned = (a & 1) || (a == 0);
16359         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
16360         a_conv = ChannelAnnouncement_clone(&a_conv);
16361         LDKChannelUpdate b_conv;
16362         b_conv.inner = (void*)(b & (~1));
16363         b_conv.is_owned = (b & 1) || (b == 0);
16364         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
16365         b_conv = ChannelUpdate_clone(&b_conv);
16366         LDKChannelUpdate c_conv;
16367         c_conv.inner = (void*)(c & (~1));
16368         c_conv.is_owned = (c & 1) || (c == 0);
16369         CHECK_INNER_FIELD_ACCESS_OR_NULL(c_conv);
16370         c_conv = ChannelUpdate_clone(&c_conv);
16371         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ");
16372         *ret_conv = C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_new(a_conv, b_conv, c_conv);
16373         return ((uint64_t)ret_conv);
16374 }
16375
16376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16377         if ((_res & 1) != 0) return;
16378         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16379         CHECK_ACCESS(_res_ptr);
16380         LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_ptr);
16381         FREE((void*)_res);
16382         C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ_free(_res_conv);
16383 }
16384
16385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1C3Tuple_1ChannelAnnouncementChannelUpdateChannelUpdateZZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16386         LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ _res_constr;
16387         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16388         if (_res_constr.datalen > 0)
16389                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ), "LDKCVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ Elements");
16390         else
16391                 _res_constr.data = NULL;
16392         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16393         for (size_t h = 0; h < _res_constr.datalen; h++) {
16394                 int64_t _res_conv_59 = _res_vals[h];
16395                 void* _res_conv_59_ptr = (void*)(((uint64_t)_res_conv_59) & ~1);
16396                 CHECK_ACCESS(_res_conv_59_ptr);
16397                 LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ _res_conv_59_conv = *(LDKC3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZ*)(_res_conv_59_ptr);
16398                 FREE((void*)_res_conv_59);
16399                 _res_constr.data[h] = _res_conv_59_conv;
16400         }
16401         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16402         CVec_C3Tuple_ChannelAnnouncementChannelUpdateChannelUpdateZZ_free(_res_constr);
16403 }
16404
16405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1NodeAnnouncementZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16406         LDKCVec_NodeAnnouncementZ _res_constr;
16407         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16408         if (_res_constr.datalen > 0)
16409                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKNodeAnnouncement), "LDKCVec_NodeAnnouncementZ Elements");
16410         else
16411                 _res_constr.data = NULL;
16412         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16413         for (size_t s = 0; s < _res_constr.datalen; s++) {
16414                 int64_t _res_conv_18 = _res_vals[s];
16415                 LDKNodeAnnouncement _res_conv_18_conv;
16416                 _res_conv_18_conv.inner = (void*)(_res_conv_18 & (~1));
16417                 _res_conv_18_conv.is_owned = (_res_conv_18 & 1) || (_res_conv_18 == 0);
16418                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_18_conv);
16419                 _res_constr.data[s] = _res_conv_18_conv;
16420         }
16421         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16422         CVec_NodeAnnouncementZ_free(_res_constr);
16423 }
16424
16425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1PublicKeyZ_1free(JNIEnv *env, jclass clz, jobjectArray _res) {
16426         LDKCVec_PublicKeyZ _res_constr;
16427         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16428         if (_res_constr.datalen > 0)
16429                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKPublicKey), "LDKCVec_PublicKeyZ Elements");
16430         else
16431                 _res_constr.data = NULL;
16432         for (size_t i = 0; i < _res_constr.datalen; i++) {
16433                 int8_tArray _res_conv_8 = (*env)->GetObjectArrayElement(env, _res, i);
16434                 LDKPublicKey _res_conv_8_ref;
16435                 CHECK((*env)->GetArrayLength(env, _res_conv_8) == 33);
16436                 (*env)->GetByteArrayRegion(env, _res_conv_8, 0, 33, _res_conv_8_ref.compressed_form);
16437                 _res_constr.data[i] = _res_conv_8_ref;
16438         }
16439         CVec_PublicKeyZ_free(_res_constr);
16440 }
16441
16442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, int8_tArray o) {
16443         LDKCVec_u8Z o_ref;
16444         o_ref.datalen = (*env)->GetArrayLength(env, o);
16445         o_ref.data = MALLOC(o_ref.datalen, "LDKCVec_u8Z Bytes");
16446         (*env)->GetByteArrayRegion(env, o, 0, o_ref.datalen, o_ref.data);
16447         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16448         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_ok(o_ref);
16449         return (uint64_t)ret_conv;
16450 }
16451
16452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16453         LDKPeerHandleError e_conv;
16454         e_conv.inner = (void*)(e & (~1));
16455         e_conv.is_owned = (e & 1) || (e == 0);
16456         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16457         e_conv = PeerHandleError_clone(&e_conv);
16458         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16459         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_err(e_conv);
16460         return (uint64_t)ret_conv;
16461 }
16462
16463 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16464         LDKCResult_CVec_u8ZPeerHandleErrorZ* o_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(o & ~1);
16465         jboolean ret_val = CResult_CVec_u8ZPeerHandleErrorZ_is_ok(o_conv);
16466         return ret_val;
16467 }
16468
16469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16470         if ((_res & 1) != 0) return;
16471         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16472         CHECK_ACCESS(_res_ptr);
16473         LDKCResult_CVec_u8ZPeerHandleErrorZ _res_conv = *(LDKCResult_CVec_u8ZPeerHandleErrorZ*)(_res_ptr);
16474         FREE((void*)_res);
16475         CResult_CVec_u8ZPeerHandleErrorZ_free(_res_conv);
16476 }
16477
16478 static inline uint64_t CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(LDKCResult_CVec_u8ZPeerHandleErrorZ *NONNULL_PTR arg) {
16479         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16480         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(arg);
16481         return (uint64_t)ret_conv;
16482 }
16483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16484         LDKCResult_CVec_u8ZPeerHandleErrorZ* arg_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(arg & ~1);
16485         int64_t ret_val = CResult_CVec_u8ZPeerHandleErrorZ_clone_ptr(arg_conv);
16486         return ret_val;
16487 }
16488
16489 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CVec_1u8ZPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16490         LDKCResult_CVec_u8ZPeerHandleErrorZ* orig_conv = (LDKCResult_CVec_u8ZPeerHandleErrorZ*)(orig & ~1);
16491         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
16492         *ret_conv = CResult_CVec_u8ZPeerHandleErrorZ_clone(orig_conv);
16493         return (uint64_t)ret_conv;
16494 }
16495
16496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1ok(JNIEnv *env, jclass clz) {
16497         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16498         *ret_conv = CResult_NonePeerHandleErrorZ_ok();
16499         return (uint64_t)ret_conv;
16500 }
16501
16502 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16503         LDKPeerHandleError e_conv;
16504         e_conv.inner = (void*)(e & (~1));
16505         e_conv.is_owned = (e & 1) || (e == 0);
16506         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16507         e_conv = PeerHandleError_clone(&e_conv);
16508         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16509         *ret_conv = CResult_NonePeerHandleErrorZ_err(e_conv);
16510         return (uint64_t)ret_conv;
16511 }
16512
16513 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16514         LDKCResult_NonePeerHandleErrorZ* o_conv = (LDKCResult_NonePeerHandleErrorZ*)(o & ~1);
16515         jboolean ret_val = CResult_NonePeerHandleErrorZ_is_ok(o_conv);
16516         return ret_val;
16517 }
16518
16519 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16520         if ((_res & 1) != 0) return;
16521         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16522         CHECK_ACCESS(_res_ptr);
16523         LDKCResult_NonePeerHandleErrorZ _res_conv = *(LDKCResult_NonePeerHandleErrorZ*)(_res_ptr);
16524         FREE((void*)_res);
16525         CResult_NonePeerHandleErrorZ_free(_res_conv);
16526 }
16527
16528 static inline uint64_t CResult_NonePeerHandleErrorZ_clone_ptr(LDKCResult_NonePeerHandleErrorZ *NONNULL_PTR arg) {
16529         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16530         *ret_conv = CResult_NonePeerHandleErrorZ_clone(arg);
16531         return (uint64_t)ret_conv;
16532 }
16533 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16534         LDKCResult_NonePeerHandleErrorZ* arg_conv = (LDKCResult_NonePeerHandleErrorZ*)(arg & ~1);
16535         int64_t ret_val = CResult_NonePeerHandleErrorZ_clone_ptr(arg_conv);
16536         return ret_val;
16537 }
16538
16539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NonePeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16540         LDKCResult_NonePeerHandleErrorZ* orig_conv = (LDKCResult_NonePeerHandleErrorZ*)(orig & ~1);
16541         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
16542         *ret_conv = CResult_NonePeerHandleErrorZ_clone(orig_conv);
16543         return (uint64_t)ret_conv;
16544 }
16545
16546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1ok(JNIEnv *env, jclass clz, jboolean o) {
16547         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16548         *ret_conv = CResult_boolPeerHandleErrorZ_ok(o);
16549         return (uint64_t)ret_conv;
16550 }
16551
16552 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16553         LDKPeerHandleError e_conv;
16554         e_conv.inner = (void*)(e & (~1));
16555         e_conv.is_owned = (e & 1) || (e == 0);
16556         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16557         e_conv = PeerHandleError_clone(&e_conv);
16558         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16559         *ret_conv = CResult_boolPeerHandleErrorZ_err(e_conv);
16560         return (uint64_t)ret_conv;
16561 }
16562
16563 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16564         LDKCResult_boolPeerHandleErrorZ* o_conv = (LDKCResult_boolPeerHandleErrorZ*)(o & ~1);
16565         jboolean ret_val = CResult_boolPeerHandleErrorZ_is_ok(o_conv);
16566         return ret_val;
16567 }
16568
16569 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16570         if ((_res & 1) != 0) return;
16571         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16572         CHECK_ACCESS(_res_ptr);
16573         LDKCResult_boolPeerHandleErrorZ _res_conv = *(LDKCResult_boolPeerHandleErrorZ*)(_res_ptr);
16574         FREE((void*)_res);
16575         CResult_boolPeerHandleErrorZ_free(_res_conv);
16576 }
16577
16578 static inline uint64_t CResult_boolPeerHandleErrorZ_clone_ptr(LDKCResult_boolPeerHandleErrorZ *NONNULL_PTR arg) {
16579         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16580         *ret_conv = CResult_boolPeerHandleErrorZ_clone(arg);
16581         return (uint64_t)ret_conv;
16582 }
16583 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16584         LDKCResult_boolPeerHandleErrorZ* arg_conv = (LDKCResult_boolPeerHandleErrorZ*)(arg & ~1);
16585         int64_t ret_val = CResult_boolPeerHandleErrorZ_clone_ptr(arg_conv);
16586         return ret_val;
16587 }
16588
16589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1boolPeerHandleErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16590         LDKCResult_boolPeerHandleErrorZ* orig_conv = (LDKCResult_boolPeerHandleErrorZ*)(orig & ~1);
16591         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
16592         *ret_conv = CResult_boolPeerHandleErrorZ_clone(orig_conv);
16593         return (uint64_t)ret_conv;
16594 }
16595
16596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16597         LDKNodeId o_conv;
16598         o_conv.inner = (void*)(o & (~1));
16599         o_conv.is_owned = (o & 1) || (o == 0);
16600         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16601         o_conv = NodeId_clone(&o_conv);
16602         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16603         *ret_conv = CResult_NodeIdDecodeErrorZ_ok(o_conv);
16604         return (uint64_t)ret_conv;
16605 }
16606
16607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16608         LDKDecodeError e_conv;
16609         e_conv.inner = (void*)(e & (~1));
16610         e_conv.is_owned = (e & 1) || (e == 0);
16611         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16612         e_conv = DecodeError_clone(&e_conv);
16613         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16614         *ret_conv = CResult_NodeIdDecodeErrorZ_err(e_conv);
16615         return (uint64_t)ret_conv;
16616 }
16617
16618 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16619         LDKCResult_NodeIdDecodeErrorZ* o_conv = (LDKCResult_NodeIdDecodeErrorZ*)(o & ~1);
16620         jboolean ret_val = CResult_NodeIdDecodeErrorZ_is_ok(o_conv);
16621         return ret_val;
16622 }
16623
16624 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16625         if ((_res & 1) != 0) return;
16626         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16627         CHECK_ACCESS(_res_ptr);
16628         LDKCResult_NodeIdDecodeErrorZ _res_conv = *(LDKCResult_NodeIdDecodeErrorZ*)(_res_ptr);
16629         FREE((void*)_res);
16630         CResult_NodeIdDecodeErrorZ_free(_res_conv);
16631 }
16632
16633 static inline uint64_t CResult_NodeIdDecodeErrorZ_clone_ptr(LDKCResult_NodeIdDecodeErrorZ *NONNULL_PTR arg) {
16634         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16635         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(arg);
16636         return (uint64_t)ret_conv;
16637 }
16638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16639         LDKCResult_NodeIdDecodeErrorZ* arg_conv = (LDKCResult_NodeIdDecodeErrorZ*)(arg & ~1);
16640         int64_t ret_val = CResult_NodeIdDecodeErrorZ_clone_ptr(arg_conv);
16641         return ret_val;
16642 }
16643
16644 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeIdDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16645         LDKCResult_NodeIdDecodeErrorZ* orig_conv = (LDKCResult_NodeIdDecodeErrorZ*)(orig & ~1);
16646         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
16647         *ret_conv = CResult_NodeIdDecodeErrorZ_clone(orig_conv);
16648         return (uint64_t)ret_conv;
16649 }
16650
16651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16652         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16653         CHECK_ACCESS(o_ptr);
16654         LDKCOption_NetworkUpdateZ o_conv = *(LDKCOption_NetworkUpdateZ*)(o_ptr);
16655         o_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)o) & ~1));
16656         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16657         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_ok(o_conv);
16658         return (uint64_t)ret_conv;
16659 }
16660
16661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16662         LDKDecodeError e_conv;
16663         e_conv.inner = (void*)(e & (~1));
16664         e_conv.is_owned = (e & 1) || (e == 0);
16665         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16666         e_conv = DecodeError_clone(&e_conv);
16667         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16668         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_err(e_conv);
16669         return (uint64_t)ret_conv;
16670 }
16671
16672 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16673         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* o_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(o & ~1);
16674         jboolean ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_is_ok(o_conv);
16675         return ret_val;
16676 }
16677
16678 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16679         if ((_res & 1) != 0) return;
16680         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16681         CHECK_ACCESS(_res_ptr);
16682         LDKCResult_COption_NetworkUpdateZDecodeErrorZ _res_conv = *(LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(_res_ptr);
16683         FREE((void*)_res);
16684         CResult_COption_NetworkUpdateZDecodeErrorZ_free(_res_conv);
16685 }
16686
16687 static inline uint64_t CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(LDKCResult_COption_NetworkUpdateZDecodeErrorZ *NONNULL_PTR arg) {
16688         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16689         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(arg);
16690         return (uint64_t)ret_conv;
16691 }
16692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16693         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* arg_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(arg & ~1);
16694         int64_t ret_val = CResult_COption_NetworkUpdateZDecodeErrorZ_clone_ptr(arg_conv);
16695         return ret_val;
16696 }
16697
16698 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1COption_1NetworkUpdateZDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16699         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* orig_conv = (LDKCResult_COption_NetworkUpdateZDecodeErrorZ*)(orig & ~1);
16700         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
16701         *ret_conv = CResult_COption_NetworkUpdateZDecodeErrorZ_clone(orig_conv);
16702         return (uint64_t)ret_conv;
16703 }
16704
16705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1some(JNIEnv *env, jclass clz, int64_t o) {
16706         void* o_ptr = (void*)(((uint64_t)o) & ~1);
16707         CHECK_ACCESS(o_ptr);
16708         LDKAccess o_conv = *(LDKAccess*)(o_ptr);
16709         if (o_conv.free == LDKAccess_JCalls_free) {
16710                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
16711                 LDKAccess_JCalls_cloned(&o_conv);
16712         }
16713         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16714         *ret_copy = COption_AccessZ_some(o_conv);
16715         uint64_t ret_ref = (uint64_t)ret_copy;
16716         return ret_ref;
16717 }
16718
16719 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1none(JNIEnv *env, jclass clz) {
16720         LDKCOption_AccessZ *ret_copy = MALLOC(sizeof(LDKCOption_AccessZ), "LDKCOption_AccessZ");
16721         *ret_copy = COption_AccessZ_none();
16722         uint64_t ret_ref = (uint64_t)ret_copy;
16723         return ret_ref;
16724 }
16725
16726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1AccessZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16727         if ((_res & 1) != 0) return;
16728         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16729         CHECK_ACCESS(_res_ptr);
16730         LDKCOption_AccessZ _res_conv = *(LDKCOption_AccessZ*)(_res_ptr);
16731         FREE((void*)_res);
16732         COption_AccessZ_free(_res_conv);
16733 }
16734
16735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16736         LDKDirectionalChannelInfo o_conv;
16737         o_conv.inner = (void*)(o & (~1));
16738         o_conv.is_owned = (o & 1) || (o == 0);
16739         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16740         o_conv = DirectionalChannelInfo_clone(&o_conv);
16741         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
16742         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_ok(o_conv);
16743         return (uint64_t)ret_conv;
16744 }
16745
16746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16747         LDKDecodeError e_conv;
16748         e_conv.inner = (void*)(e & (~1));
16749         e_conv.is_owned = (e & 1) || (e == 0);
16750         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16751         e_conv = DecodeError_clone(&e_conv);
16752         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
16753         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_err(e_conv);
16754         return (uint64_t)ret_conv;
16755 }
16756
16757 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16758         LDKCResult_DirectionalChannelInfoDecodeErrorZ* o_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(o & ~1);
16759         jboolean ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_is_ok(o_conv);
16760         return ret_val;
16761 }
16762
16763 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16764         if ((_res & 1) != 0) return;
16765         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16766         CHECK_ACCESS(_res_ptr);
16767         LDKCResult_DirectionalChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(_res_ptr);
16768         FREE((void*)_res);
16769         CResult_DirectionalChannelInfoDecodeErrorZ_free(_res_conv);
16770 }
16771
16772 static inline uint64_t CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_DirectionalChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16773         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
16774         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(arg);
16775         return (uint64_t)ret_conv;
16776 }
16777 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16778         LDKCResult_DirectionalChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(arg & ~1);
16779         int64_t ret_val = CResult_DirectionalChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16780         return ret_val;
16781 }
16782
16783 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1DirectionalChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16784         LDKCResult_DirectionalChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_DirectionalChannelInfoDecodeErrorZ*)(orig & ~1);
16785         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
16786         *ret_conv = CResult_DirectionalChannelInfoDecodeErrorZ_clone(orig_conv);
16787         return (uint64_t)ret_conv;
16788 }
16789
16790 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16791         LDKChannelInfo o_conv;
16792         o_conv.inner = (void*)(o & (~1));
16793         o_conv.is_owned = (o & 1) || (o == 0);
16794         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16795         o_conv = ChannelInfo_clone(&o_conv);
16796         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16797         *ret_conv = CResult_ChannelInfoDecodeErrorZ_ok(o_conv);
16798         return (uint64_t)ret_conv;
16799 }
16800
16801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16802         LDKDecodeError e_conv;
16803         e_conv.inner = (void*)(e & (~1));
16804         e_conv.is_owned = (e & 1) || (e == 0);
16805         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16806         e_conv = DecodeError_clone(&e_conv);
16807         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16808         *ret_conv = CResult_ChannelInfoDecodeErrorZ_err(e_conv);
16809         return (uint64_t)ret_conv;
16810 }
16811
16812 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16813         LDKCResult_ChannelInfoDecodeErrorZ* o_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(o & ~1);
16814         jboolean ret_val = CResult_ChannelInfoDecodeErrorZ_is_ok(o_conv);
16815         return ret_val;
16816 }
16817
16818 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16819         if ((_res & 1) != 0) return;
16820         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16821         CHECK_ACCESS(_res_ptr);
16822         LDKCResult_ChannelInfoDecodeErrorZ _res_conv = *(LDKCResult_ChannelInfoDecodeErrorZ*)(_res_ptr);
16823         FREE((void*)_res);
16824         CResult_ChannelInfoDecodeErrorZ_free(_res_conv);
16825 }
16826
16827 static inline uint64_t CResult_ChannelInfoDecodeErrorZ_clone_ptr(LDKCResult_ChannelInfoDecodeErrorZ *NONNULL_PTR arg) {
16828         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16829         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(arg);
16830         return (uint64_t)ret_conv;
16831 }
16832 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16833         LDKCResult_ChannelInfoDecodeErrorZ* arg_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(arg & ~1);
16834         int64_t ret_val = CResult_ChannelInfoDecodeErrorZ_clone_ptr(arg_conv);
16835         return ret_val;
16836 }
16837
16838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16839         LDKCResult_ChannelInfoDecodeErrorZ* orig_conv = (LDKCResult_ChannelInfoDecodeErrorZ*)(orig & ~1);
16840         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
16841         *ret_conv = CResult_ChannelInfoDecodeErrorZ_clone(orig_conv);
16842         return (uint64_t)ret_conv;
16843 }
16844
16845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16846         LDKRoutingFees o_conv;
16847         o_conv.inner = (void*)(o & (~1));
16848         o_conv.is_owned = (o & 1) || (o == 0);
16849         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16850         o_conv = RoutingFees_clone(&o_conv);
16851         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16852         *ret_conv = CResult_RoutingFeesDecodeErrorZ_ok(o_conv);
16853         return (uint64_t)ret_conv;
16854 }
16855
16856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16857         LDKDecodeError e_conv;
16858         e_conv.inner = (void*)(e & (~1));
16859         e_conv.is_owned = (e & 1) || (e == 0);
16860         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16861         e_conv = DecodeError_clone(&e_conv);
16862         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16863         *ret_conv = CResult_RoutingFeesDecodeErrorZ_err(e_conv);
16864         return (uint64_t)ret_conv;
16865 }
16866
16867 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16868         LDKCResult_RoutingFeesDecodeErrorZ* o_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(o & ~1);
16869         jboolean ret_val = CResult_RoutingFeesDecodeErrorZ_is_ok(o_conv);
16870         return ret_val;
16871 }
16872
16873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16874         if ((_res & 1) != 0) return;
16875         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16876         CHECK_ACCESS(_res_ptr);
16877         LDKCResult_RoutingFeesDecodeErrorZ _res_conv = *(LDKCResult_RoutingFeesDecodeErrorZ*)(_res_ptr);
16878         FREE((void*)_res);
16879         CResult_RoutingFeesDecodeErrorZ_free(_res_conv);
16880 }
16881
16882 static inline uint64_t CResult_RoutingFeesDecodeErrorZ_clone_ptr(LDKCResult_RoutingFeesDecodeErrorZ *NONNULL_PTR arg) {
16883         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16884         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(arg);
16885         return (uint64_t)ret_conv;
16886 }
16887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16888         LDKCResult_RoutingFeesDecodeErrorZ* arg_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(arg & ~1);
16889         int64_t ret_val = CResult_RoutingFeesDecodeErrorZ_clone_ptr(arg_conv);
16890         return ret_val;
16891 }
16892
16893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RoutingFeesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16894         LDKCResult_RoutingFeesDecodeErrorZ* orig_conv = (LDKCResult_RoutingFeesDecodeErrorZ*)(orig & ~1);
16895         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
16896         *ret_conv = CResult_RoutingFeesDecodeErrorZ_clone(orig_conv);
16897         return (uint64_t)ret_conv;
16898 }
16899
16900 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16901         LDKNodeAnnouncementInfo o_conv;
16902         o_conv.inner = (void*)(o & (~1));
16903         o_conv.is_owned = (o & 1) || (o == 0);
16904         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16905         o_conv = NodeAnnouncementInfo_clone(&o_conv);
16906         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16907         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_ok(o_conv);
16908         return (uint64_t)ret_conv;
16909 }
16910
16911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16912         LDKDecodeError e_conv;
16913         e_conv.inner = (void*)(e & (~1));
16914         e_conv.is_owned = (e & 1) || (e == 0);
16915         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16916         e_conv = DecodeError_clone(&e_conv);
16917         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16918         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_err(e_conv);
16919         return (uint64_t)ret_conv;
16920 }
16921
16922 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16923         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(o & ~1);
16924         jboolean ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_is_ok(o_conv);
16925         return ret_val;
16926 }
16927
16928 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
16929         if ((_res & 1) != 0) return;
16930         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
16931         CHECK_ACCESS(_res_ptr);
16932         LDKCResult_NodeAnnouncementInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(_res_ptr);
16933         FREE((void*)_res);
16934         CResult_NodeAnnouncementInfoDecodeErrorZ_free(_res_conv);
16935 }
16936
16937 static inline uint64_t CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementInfoDecodeErrorZ *NONNULL_PTR arg) {
16938         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16939         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(arg);
16940         return (uint64_t)ret_conv;
16941 }
16942 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
16943         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(arg & ~1);
16944         int64_t ret_val = CResult_NodeAnnouncementInfoDecodeErrorZ_clone_ptr(arg_conv);
16945         return ret_val;
16946 }
16947
16948 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
16949         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementInfoDecodeErrorZ*)(orig & ~1);
16950         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
16951         *ret_conv = CResult_NodeAnnouncementInfoDecodeErrorZ_clone(orig_conv);
16952         return (uint64_t)ret_conv;
16953 }
16954
16955 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1u64Z_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
16956         LDKCVec_u64Z _res_constr;
16957         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
16958         if (_res_constr.datalen > 0)
16959                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
16960         else
16961                 _res_constr.data = NULL;
16962         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
16963         for (size_t g = 0; g < _res_constr.datalen; g++) {
16964                 int64_t _res_conv_6 = _res_vals[g];
16965                 _res_constr.data[g] = _res_conv_6;
16966         }
16967         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
16968         CVec_u64Z_free(_res_constr);
16969 }
16970
16971 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
16972         LDKNodeInfo o_conv;
16973         o_conv.inner = (void*)(o & (~1));
16974         o_conv.is_owned = (o & 1) || (o == 0);
16975         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
16976         o_conv = NodeInfo_clone(&o_conv);
16977         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16978         *ret_conv = CResult_NodeInfoDecodeErrorZ_ok(o_conv);
16979         return (uint64_t)ret_conv;
16980 }
16981
16982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
16983         LDKDecodeError e_conv;
16984         e_conv.inner = (void*)(e & (~1));
16985         e_conv.is_owned = (e & 1) || (e == 0);
16986         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
16987         e_conv = DecodeError_clone(&e_conv);
16988         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
16989         *ret_conv = CResult_NodeInfoDecodeErrorZ_err(e_conv);
16990         return (uint64_t)ret_conv;
16991 }
16992
16993 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
16994         LDKCResult_NodeInfoDecodeErrorZ* o_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(o & ~1);
16995         jboolean ret_val = CResult_NodeInfoDecodeErrorZ_is_ok(o_conv);
16996         return ret_val;
16997 }
16998
16999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17000         if ((_res & 1) != 0) return;
17001         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17002         CHECK_ACCESS(_res_ptr);
17003         LDKCResult_NodeInfoDecodeErrorZ _res_conv = *(LDKCResult_NodeInfoDecodeErrorZ*)(_res_ptr);
17004         FREE((void*)_res);
17005         CResult_NodeInfoDecodeErrorZ_free(_res_conv);
17006 }
17007
17008 static inline uint64_t CResult_NodeInfoDecodeErrorZ_clone_ptr(LDKCResult_NodeInfoDecodeErrorZ *NONNULL_PTR arg) {
17009         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17010         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(arg);
17011         return (uint64_t)ret_conv;
17012 }
17013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17014         LDKCResult_NodeInfoDecodeErrorZ* arg_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(arg & ~1);
17015         int64_t ret_val = CResult_NodeInfoDecodeErrorZ_clone_ptr(arg_conv);
17016         return ret_val;
17017 }
17018
17019 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeInfoDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17020         LDKCResult_NodeInfoDecodeErrorZ* orig_conv = (LDKCResult_NodeInfoDecodeErrorZ*)(orig & ~1);
17021         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
17022         *ret_conv = CResult_NodeInfoDecodeErrorZ_clone(orig_conv);
17023         return (uint64_t)ret_conv;
17024 }
17025
17026 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17027         LDKNetworkGraph o_conv;
17028         o_conv.inner = (void*)(o & (~1));
17029         o_conv.is_owned = (o & 1) || (o == 0);
17030         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17031         o_conv = NetworkGraph_clone(&o_conv);
17032         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17033         *ret_conv = CResult_NetworkGraphDecodeErrorZ_ok(o_conv);
17034         return (uint64_t)ret_conv;
17035 }
17036
17037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17038         LDKDecodeError e_conv;
17039         e_conv.inner = (void*)(e & (~1));
17040         e_conv.is_owned = (e & 1) || (e == 0);
17041         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17042         e_conv = DecodeError_clone(&e_conv);
17043         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17044         *ret_conv = CResult_NetworkGraphDecodeErrorZ_err(e_conv);
17045         return (uint64_t)ret_conv;
17046 }
17047
17048 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17049         LDKCResult_NetworkGraphDecodeErrorZ* o_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(o & ~1);
17050         jboolean ret_val = CResult_NetworkGraphDecodeErrorZ_is_ok(o_conv);
17051         return ret_val;
17052 }
17053
17054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17055         if ((_res & 1) != 0) return;
17056         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17057         CHECK_ACCESS(_res_ptr);
17058         LDKCResult_NetworkGraphDecodeErrorZ _res_conv = *(LDKCResult_NetworkGraphDecodeErrorZ*)(_res_ptr);
17059         FREE((void*)_res);
17060         CResult_NetworkGraphDecodeErrorZ_free(_res_conv);
17061 }
17062
17063 static inline uint64_t CResult_NetworkGraphDecodeErrorZ_clone_ptr(LDKCResult_NetworkGraphDecodeErrorZ *NONNULL_PTR arg) {
17064         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17065         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(arg);
17066         return (uint64_t)ret_conv;
17067 }
17068 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17069         LDKCResult_NetworkGraphDecodeErrorZ* arg_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(arg & ~1);
17070         int64_t ret_val = CResult_NetworkGraphDecodeErrorZ_clone_ptr(arg_conv);
17071         return ret_val;
17072 }
17073
17074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetworkGraphDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17075         LDKCResult_NetworkGraphDecodeErrorZ* orig_conv = (LDKCResult_NetworkGraphDecodeErrorZ*)(orig & ~1);
17076         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
17077         *ret_conv = CResult_NetworkGraphDecodeErrorZ_clone(orig_conv);
17078         return (uint64_t)ret_conv;
17079 }
17080
17081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1some(JNIEnv *env, jclass clz, int64_tArray o) {
17082         LDKCVec_NetAddressZ o_constr;
17083         o_constr.datalen = (*env)->GetArrayLength(env, o);
17084         if (o_constr.datalen > 0)
17085                 o_constr.data = MALLOC(o_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
17086         else
17087                 o_constr.data = NULL;
17088         int64_t* o_vals = (*env)->GetLongArrayElements (env, o, NULL);
17089         for (size_t m = 0; m < o_constr.datalen; m++) {
17090                 int64_t o_conv_12 = o_vals[m];
17091                 void* o_conv_12_ptr = (void*)(((uint64_t)o_conv_12) & ~1);
17092                 CHECK_ACCESS(o_conv_12_ptr);
17093                 LDKNetAddress o_conv_12_conv = *(LDKNetAddress*)(o_conv_12_ptr);
17094                 o_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o_conv_12) & ~1));
17095                 o_constr.data[m] = o_conv_12_conv;
17096         }
17097         (*env)->ReleaseLongArrayElements(env, o, o_vals, 0);
17098         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17099         *ret_copy = COption_CVec_NetAddressZZ_some(o_constr);
17100         uint64_t ret_ref = (uint64_t)ret_copy;
17101         return ret_ref;
17102 }
17103
17104 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1none(JNIEnv *env, jclass clz) {
17105         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17106         *ret_copy = COption_CVec_NetAddressZZ_none();
17107         uint64_t ret_ref = (uint64_t)ret_copy;
17108         return ret_ref;
17109 }
17110
17111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17112         if ((_res & 1) != 0) return;
17113         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17114         CHECK_ACCESS(_res_ptr);
17115         LDKCOption_CVec_NetAddressZZ _res_conv = *(LDKCOption_CVec_NetAddressZZ*)(_res_ptr);
17116         FREE((void*)_res);
17117         COption_CVec_NetAddressZZ_free(_res_conv);
17118 }
17119
17120 static inline uint64_t COption_CVec_NetAddressZZ_clone_ptr(LDKCOption_CVec_NetAddressZZ *NONNULL_PTR arg) {
17121         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17122         *ret_copy = COption_CVec_NetAddressZZ_clone(arg);
17123 uint64_t ret_ref = (uint64_t)ret_copy;
17124         return ret_ref;
17125 }
17126 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17127         LDKCOption_CVec_NetAddressZZ* arg_conv = (LDKCOption_CVec_NetAddressZZ*)arg;
17128         int64_t ret_val = COption_CVec_NetAddressZZ_clone_ptr(arg_conv);
17129         return ret_val;
17130 }
17131
17132 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1CVec_1NetAddressZZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17133         LDKCOption_CVec_NetAddressZZ* orig_conv = (LDKCOption_CVec_NetAddressZZ*)orig;
17134         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
17135         *ret_copy = COption_CVec_NetAddressZZ_clone(orig_conv);
17136         uint64_t ret_ref = (uint64_t)ret_copy;
17137         return ret_ref;
17138 }
17139
17140 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17141         void* o_ptr = (void*)(((uint64_t)o) & ~1);
17142         CHECK_ACCESS(o_ptr);
17143         LDKNetAddress o_conv = *(LDKNetAddress*)(o_ptr);
17144         o_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)o) & ~1));
17145         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17146         *ret_conv = CResult_NetAddressDecodeErrorZ_ok(o_conv);
17147         return (uint64_t)ret_conv;
17148 }
17149
17150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17151         LDKDecodeError e_conv;
17152         e_conv.inner = (void*)(e & (~1));
17153         e_conv.is_owned = (e & 1) || (e == 0);
17154         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17155         e_conv = DecodeError_clone(&e_conv);
17156         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17157         *ret_conv = CResult_NetAddressDecodeErrorZ_err(e_conv);
17158         return (uint64_t)ret_conv;
17159 }
17160
17161 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17162         LDKCResult_NetAddressDecodeErrorZ* o_conv = (LDKCResult_NetAddressDecodeErrorZ*)(o & ~1);
17163         jboolean ret_val = CResult_NetAddressDecodeErrorZ_is_ok(o_conv);
17164         return ret_val;
17165 }
17166
17167 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17168         if ((_res & 1) != 0) return;
17169         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17170         CHECK_ACCESS(_res_ptr);
17171         LDKCResult_NetAddressDecodeErrorZ _res_conv = *(LDKCResult_NetAddressDecodeErrorZ*)(_res_ptr);
17172         FREE((void*)_res);
17173         CResult_NetAddressDecodeErrorZ_free(_res_conv);
17174 }
17175
17176 static inline uint64_t CResult_NetAddressDecodeErrorZ_clone_ptr(LDKCResult_NetAddressDecodeErrorZ *NONNULL_PTR arg) {
17177         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17178         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(arg);
17179         return (uint64_t)ret_conv;
17180 }
17181 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17182         LDKCResult_NetAddressDecodeErrorZ* arg_conv = (LDKCResult_NetAddressDecodeErrorZ*)(arg & ~1);
17183         int64_t ret_val = CResult_NetAddressDecodeErrorZ_clone_ptr(arg_conv);
17184         return ret_val;
17185 }
17186
17187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NetAddressDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17188         LDKCResult_NetAddressDecodeErrorZ* orig_conv = (LDKCResult_NetAddressDecodeErrorZ*)(orig & ~1);
17189         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
17190         *ret_conv = CResult_NetAddressDecodeErrorZ_clone(orig_conv);
17191         return (uint64_t)ret_conv;
17192 }
17193
17194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateAddHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17195         LDKCVec_UpdateAddHTLCZ _res_constr;
17196         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17197         if (_res_constr.datalen > 0)
17198                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
17199         else
17200                 _res_constr.data = NULL;
17201         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17202         for (size_t p = 0; p < _res_constr.datalen; p++) {
17203                 int64_t _res_conv_15 = _res_vals[p];
17204                 LDKUpdateAddHTLC _res_conv_15_conv;
17205                 _res_conv_15_conv.inner = (void*)(_res_conv_15 & (~1));
17206                 _res_conv_15_conv.is_owned = (_res_conv_15 & 1) || (_res_conv_15 == 0);
17207                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_15_conv);
17208                 _res_constr.data[p] = _res_conv_15_conv;
17209         }
17210         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17211         CVec_UpdateAddHTLCZ_free(_res_constr);
17212 }
17213
17214 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFulfillHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17215         LDKCVec_UpdateFulfillHTLCZ _res_constr;
17216         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17217         if (_res_constr.datalen > 0)
17218                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
17219         else
17220                 _res_constr.data = NULL;
17221         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17222         for (size_t t = 0; t < _res_constr.datalen; t++) {
17223                 int64_t _res_conv_19 = _res_vals[t];
17224                 LDKUpdateFulfillHTLC _res_conv_19_conv;
17225                 _res_conv_19_conv.inner = (void*)(_res_conv_19 & (~1));
17226                 _res_conv_19_conv.is_owned = (_res_conv_19 & 1) || (_res_conv_19 == 0);
17227                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_19_conv);
17228                 _res_constr.data[t] = _res_conv_19_conv;
17229         }
17230         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17231         CVec_UpdateFulfillHTLCZ_free(_res_constr);
17232 }
17233
17234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17235         LDKCVec_UpdateFailHTLCZ _res_constr;
17236         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17237         if (_res_constr.datalen > 0)
17238                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
17239         else
17240                 _res_constr.data = NULL;
17241         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17242         for (size_t q = 0; q < _res_constr.datalen; q++) {
17243                 int64_t _res_conv_16 = _res_vals[q];
17244                 LDKUpdateFailHTLC _res_conv_16_conv;
17245                 _res_conv_16_conv.inner = (void*)(_res_conv_16 & (~1));
17246                 _res_conv_16_conv.is_owned = (_res_conv_16 & 1) || (_res_conv_16 == 0);
17247                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_16_conv);
17248                 _res_constr.data[q] = _res_conv_16_conv;
17249         }
17250         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17251         CVec_UpdateFailHTLCZ_free(_res_constr);
17252 }
17253
17254 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1UpdateFailMalformedHTLCZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
17255         LDKCVec_UpdateFailMalformedHTLCZ _res_constr;
17256         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
17257         if (_res_constr.datalen > 0)
17258                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
17259         else
17260                 _res_constr.data = NULL;
17261         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
17262         for (size_t z = 0; z < _res_constr.datalen; z++) {
17263                 int64_t _res_conv_25 = _res_vals[z];
17264                 LDKUpdateFailMalformedHTLC _res_conv_25_conv;
17265                 _res_conv_25_conv.inner = (void*)(_res_conv_25 & (~1));
17266                 _res_conv_25_conv.is_owned = (_res_conv_25 & 1) || (_res_conv_25 == 0);
17267                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_25_conv);
17268                 _res_constr.data[z] = _res_conv_25_conv;
17269         }
17270         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
17271         CVec_UpdateFailMalformedHTLCZ_free(_res_constr);
17272 }
17273
17274 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17275         LDKAcceptChannel o_conv;
17276         o_conv.inner = (void*)(o & (~1));
17277         o_conv.is_owned = (o & 1) || (o == 0);
17278         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17279         o_conv = AcceptChannel_clone(&o_conv);
17280         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17281         *ret_conv = CResult_AcceptChannelDecodeErrorZ_ok(o_conv);
17282         return (uint64_t)ret_conv;
17283 }
17284
17285 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17286         LDKDecodeError e_conv;
17287         e_conv.inner = (void*)(e & (~1));
17288         e_conv.is_owned = (e & 1) || (e == 0);
17289         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17290         e_conv = DecodeError_clone(&e_conv);
17291         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17292         *ret_conv = CResult_AcceptChannelDecodeErrorZ_err(e_conv);
17293         return (uint64_t)ret_conv;
17294 }
17295
17296 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17297         LDKCResult_AcceptChannelDecodeErrorZ* o_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(o & ~1);
17298         jboolean ret_val = CResult_AcceptChannelDecodeErrorZ_is_ok(o_conv);
17299         return ret_val;
17300 }
17301
17302 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17303         if ((_res & 1) != 0) return;
17304         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17305         CHECK_ACCESS(_res_ptr);
17306         LDKCResult_AcceptChannelDecodeErrorZ _res_conv = *(LDKCResult_AcceptChannelDecodeErrorZ*)(_res_ptr);
17307         FREE((void*)_res);
17308         CResult_AcceptChannelDecodeErrorZ_free(_res_conv);
17309 }
17310
17311 static inline uint64_t CResult_AcceptChannelDecodeErrorZ_clone_ptr(LDKCResult_AcceptChannelDecodeErrorZ *NONNULL_PTR arg) {
17312         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17313         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(arg);
17314         return (uint64_t)ret_conv;
17315 }
17316 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17317         LDKCResult_AcceptChannelDecodeErrorZ* arg_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(arg & ~1);
17318         int64_t ret_val = CResult_AcceptChannelDecodeErrorZ_clone_ptr(arg_conv);
17319         return ret_val;
17320 }
17321
17322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AcceptChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17323         LDKCResult_AcceptChannelDecodeErrorZ* orig_conv = (LDKCResult_AcceptChannelDecodeErrorZ*)(orig & ~1);
17324         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
17325         *ret_conv = CResult_AcceptChannelDecodeErrorZ_clone(orig_conv);
17326         return (uint64_t)ret_conv;
17327 }
17328
17329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17330         LDKAnnouncementSignatures o_conv;
17331         o_conv.inner = (void*)(o & (~1));
17332         o_conv.is_owned = (o & 1) || (o == 0);
17333         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17334         o_conv = AnnouncementSignatures_clone(&o_conv);
17335         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17336         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_ok(o_conv);
17337         return (uint64_t)ret_conv;
17338 }
17339
17340 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17341         LDKDecodeError e_conv;
17342         e_conv.inner = (void*)(e & (~1));
17343         e_conv.is_owned = (e & 1) || (e == 0);
17344         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17345         e_conv = DecodeError_clone(&e_conv);
17346         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17347         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_err(e_conv);
17348         return (uint64_t)ret_conv;
17349 }
17350
17351 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17352         LDKCResult_AnnouncementSignaturesDecodeErrorZ* o_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(o & ~1);
17353         jboolean ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_is_ok(o_conv);
17354         return ret_val;
17355 }
17356
17357 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17358         if ((_res & 1) != 0) return;
17359         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17360         CHECK_ACCESS(_res_ptr);
17361         LDKCResult_AnnouncementSignaturesDecodeErrorZ _res_conv = *(LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(_res_ptr);
17362         FREE((void*)_res);
17363         CResult_AnnouncementSignaturesDecodeErrorZ_free(_res_conv);
17364 }
17365
17366 static inline uint64_t CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(LDKCResult_AnnouncementSignaturesDecodeErrorZ *NONNULL_PTR arg) {
17367         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17368         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(arg);
17369         return (uint64_t)ret_conv;
17370 }
17371 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17372         LDKCResult_AnnouncementSignaturesDecodeErrorZ* arg_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(arg & ~1);
17373         int64_t ret_val = CResult_AnnouncementSignaturesDecodeErrorZ_clone_ptr(arg_conv);
17374         return ret_val;
17375 }
17376
17377 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1AnnouncementSignaturesDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17378         LDKCResult_AnnouncementSignaturesDecodeErrorZ* orig_conv = (LDKCResult_AnnouncementSignaturesDecodeErrorZ*)(orig & ~1);
17379         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
17380         *ret_conv = CResult_AnnouncementSignaturesDecodeErrorZ_clone(orig_conv);
17381         return (uint64_t)ret_conv;
17382 }
17383
17384 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17385         LDKChannelReestablish o_conv;
17386         o_conv.inner = (void*)(o & (~1));
17387         o_conv.is_owned = (o & 1) || (o == 0);
17388         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17389         o_conv = ChannelReestablish_clone(&o_conv);
17390         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17391         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_ok(o_conv);
17392         return (uint64_t)ret_conv;
17393 }
17394
17395 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17396         LDKDecodeError e_conv;
17397         e_conv.inner = (void*)(e & (~1));
17398         e_conv.is_owned = (e & 1) || (e == 0);
17399         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17400         e_conv = DecodeError_clone(&e_conv);
17401         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17402         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_err(e_conv);
17403         return (uint64_t)ret_conv;
17404 }
17405
17406 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17407         LDKCResult_ChannelReestablishDecodeErrorZ* o_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(o & ~1);
17408         jboolean ret_val = CResult_ChannelReestablishDecodeErrorZ_is_ok(o_conv);
17409         return ret_val;
17410 }
17411
17412 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17413         if ((_res & 1) != 0) return;
17414         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17415         CHECK_ACCESS(_res_ptr);
17416         LDKCResult_ChannelReestablishDecodeErrorZ _res_conv = *(LDKCResult_ChannelReestablishDecodeErrorZ*)(_res_ptr);
17417         FREE((void*)_res);
17418         CResult_ChannelReestablishDecodeErrorZ_free(_res_conv);
17419 }
17420
17421 static inline uint64_t CResult_ChannelReestablishDecodeErrorZ_clone_ptr(LDKCResult_ChannelReestablishDecodeErrorZ *NONNULL_PTR arg) {
17422         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17423         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(arg);
17424         return (uint64_t)ret_conv;
17425 }
17426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17427         LDKCResult_ChannelReestablishDecodeErrorZ* arg_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(arg & ~1);
17428         int64_t ret_val = CResult_ChannelReestablishDecodeErrorZ_clone_ptr(arg_conv);
17429         return ret_val;
17430 }
17431
17432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelReestablishDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17433         LDKCResult_ChannelReestablishDecodeErrorZ* orig_conv = (LDKCResult_ChannelReestablishDecodeErrorZ*)(orig & ~1);
17434         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
17435         *ret_conv = CResult_ChannelReestablishDecodeErrorZ_clone(orig_conv);
17436         return (uint64_t)ret_conv;
17437 }
17438
17439 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17440         LDKClosingSigned o_conv;
17441         o_conv.inner = (void*)(o & (~1));
17442         o_conv.is_owned = (o & 1) || (o == 0);
17443         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17444         o_conv = ClosingSigned_clone(&o_conv);
17445         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17446         *ret_conv = CResult_ClosingSignedDecodeErrorZ_ok(o_conv);
17447         return (uint64_t)ret_conv;
17448 }
17449
17450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17451         LDKDecodeError e_conv;
17452         e_conv.inner = (void*)(e & (~1));
17453         e_conv.is_owned = (e & 1) || (e == 0);
17454         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17455         e_conv = DecodeError_clone(&e_conv);
17456         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17457         *ret_conv = CResult_ClosingSignedDecodeErrorZ_err(e_conv);
17458         return (uint64_t)ret_conv;
17459 }
17460
17461 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17462         LDKCResult_ClosingSignedDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(o & ~1);
17463         jboolean ret_val = CResult_ClosingSignedDecodeErrorZ_is_ok(o_conv);
17464         return ret_val;
17465 }
17466
17467 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17468         if ((_res & 1) != 0) return;
17469         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17470         CHECK_ACCESS(_res_ptr);
17471         LDKCResult_ClosingSignedDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedDecodeErrorZ*)(_res_ptr);
17472         FREE((void*)_res);
17473         CResult_ClosingSignedDecodeErrorZ_free(_res_conv);
17474 }
17475
17476 static inline uint64_t CResult_ClosingSignedDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedDecodeErrorZ *NONNULL_PTR arg) {
17477         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17478         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(arg);
17479         return (uint64_t)ret_conv;
17480 }
17481 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17482         LDKCResult_ClosingSignedDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(arg & ~1);
17483         int64_t ret_val = CResult_ClosingSignedDecodeErrorZ_clone_ptr(arg_conv);
17484         return ret_val;
17485 }
17486
17487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17488         LDKCResult_ClosingSignedDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedDecodeErrorZ*)(orig & ~1);
17489         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
17490         *ret_conv = CResult_ClosingSignedDecodeErrorZ_clone(orig_conv);
17491         return (uint64_t)ret_conv;
17492 }
17493
17494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17495         LDKClosingSignedFeeRange o_conv;
17496         o_conv.inner = (void*)(o & (~1));
17497         o_conv.is_owned = (o & 1) || (o == 0);
17498         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17499         o_conv = ClosingSignedFeeRange_clone(&o_conv);
17500         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17501         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_ok(o_conv);
17502         return (uint64_t)ret_conv;
17503 }
17504
17505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17506         LDKDecodeError e_conv;
17507         e_conv.inner = (void*)(e & (~1));
17508         e_conv.is_owned = (e & 1) || (e == 0);
17509         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17510         e_conv = DecodeError_clone(&e_conv);
17511         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17512         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_err(e_conv);
17513         return (uint64_t)ret_conv;
17514 }
17515
17516 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17517         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* o_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(o & ~1);
17518         jboolean ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_is_ok(o_conv);
17519         return ret_val;
17520 }
17521
17522 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17523         if ((_res & 1) != 0) return;
17524         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17525         CHECK_ACCESS(_res_ptr);
17526         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ _res_conv = *(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(_res_ptr);
17527         FREE((void*)_res);
17528         CResult_ClosingSignedFeeRangeDecodeErrorZ_free(_res_conv);
17529 }
17530
17531 static inline uint64_t CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ *NONNULL_PTR arg) {
17532         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17533         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(arg);
17534         return (uint64_t)ret_conv;
17535 }
17536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17537         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* arg_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(arg & ~1);
17538         int64_t ret_val = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone_ptr(arg_conv);
17539         return ret_val;
17540 }
17541
17542 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ClosingSignedFeeRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17543         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* orig_conv = (LDKCResult_ClosingSignedFeeRangeDecodeErrorZ*)(orig & ~1);
17544         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
17545         *ret_conv = CResult_ClosingSignedFeeRangeDecodeErrorZ_clone(orig_conv);
17546         return (uint64_t)ret_conv;
17547 }
17548
17549 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17550         LDKCommitmentSigned o_conv;
17551         o_conv.inner = (void*)(o & (~1));
17552         o_conv.is_owned = (o & 1) || (o == 0);
17553         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17554         o_conv = CommitmentSigned_clone(&o_conv);
17555         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17556         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_ok(o_conv);
17557         return (uint64_t)ret_conv;
17558 }
17559
17560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17561         LDKDecodeError e_conv;
17562         e_conv.inner = (void*)(e & (~1));
17563         e_conv.is_owned = (e & 1) || (e == 0);
17564         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17565         e_conv = DecodeError_clone(&e_conv);
17566         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17567         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_err(e_conv);
17568         return (uint64_t)ret_conv;
17569 }
17570
17571 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17572         LDKCResult_CommitmentSignedDecodeErrorZ* o_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(o & ~1);
17573         jboolean ret_val = CResult_CommitmentSignedDecodeErrorZ_is_ok(o_conv);
17574         return ret_val;
17575 }
17576
17577 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17578         if ((_res & 1) != 0) return;
17579         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17580         CHECK_ACCESS(_res_ptr);
17581         LDKCResult_CommitmentSignedDecodeErrorZ _res_conv = *(LDKCResult_CommitmentSignedDecodeErrorZ*)(_res_ptr);
17582         FREE((void*)_res);
17583         CResult_CommitmentSignedDecodeErrorZ_free(_res_conv);
17584 }
17585
17586 static inline uint64_t CResult_CommitmentSignedDecodeErrorZ_clone_ptr(LDKCResult_CommitmentSignedDecodeErrorZ *NONNULL_PTR arg) {
17587         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17588         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(arg);
17589         return (uint64_t)ret_conv;
17590 }
17591 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17592         LDKCResult_CommitmentSignedDecodeErrorZ* arg_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(arg & ~1);
17593         int64_t ret_val = CResult_CommitmentSignedDecodeErrorZ_clone_ptr(arg_conv);
17594         return ret_val;
17595 }
17596
17597 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1CommitmentSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17598         LDKCResult_CommitmentSignedDecodeErrorZ* orig_conv = (LDKCResult_CommitmentSignedDecodeErrorZ*)(orig & ~1);
17599         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
17600         *ret_conv = CResult_CommitmentSignedDecodeErrorZ_clone(orig_conv);
17601         return (uint64_t)ret_conv;
17602 }
17603
17604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17605         LDKFundingCreated o_conv;
17606         o_conv.inner = (void*)(o & (~1));
17607         o_conv.is_owned = (o & 1) || (o == 0);
17608         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17609         o_conv = FundingCreated_clone(&o_conv);
17610         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17611         *ret_conv = CResult_FundingCreatedDecodeErrorZ_ok(o_conv);
17612         return (uint64_t)ret_conv;
17613 }
17614
17615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17616         LDKDecodeError e_conv;
17617         e_conv.inner = (void*)(e & (~1));
17618         e_conv.is_owned = (e & 1) || (e == 0);
17619         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17620         e_conv = DecodeError_clone(&e_conv);
17621         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17622         *ret_conv = CResult_FundingCreatedDecodeErrorZ_err(e_conv);
17623         return (uint64_t)ret_conv;
17624 }
17625
17626 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17627         LDKCResult_FundingCreatedDecodeErrorZ* o_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(o & ~1);
17628         jboolean ret_val = CResult_FundingCreatedDecodeErrorZ_is_ok(o_conv);
17629         return ret_val;
17630 }
17631
17632 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17633         if ((_res & 1) != 0) return;
17634         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17635         CHECK_ACCESS(_res_ptr);
17636         LDKCResult_FundingCreatedDecodeErrorZ _res_conv = *(LDKCResult_FundingCreatedDecodeErrorZ*)(_res_ptr);
17637         FREE((void*)_res);
17638         CResult_FundingCreatedDecodeErrorZ_free(_res_conv);
17639 }
17640
17641 static inline uint64_t CResult_FundingCreatedDecodeErrorZ_clone_ptr(LDKCResult_FundingCreatedDecodeErrorZ *NONNULL_PTR arg) {
17642         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17643         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(arg);
17644         return (uint64_t)ret_conv;
17645 }
17646 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17647         LDKCResult_FundingCreatedDecodeErrorZ* arg_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(arg & ~1);
17648         int64_t ret_val = CResult_FundingCreatedDecodeErrorZ_clone_ptr(arg_conv);
17649         return ret_val;
17650 }
17651
17652 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingCreatedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17653         LDKCResult_FundingCreatedDecodeErrorZ* orig_conv = (LDKCResult_FundingCreatedDecodeErrorZ*)(orig & ~1);
17654         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
17655         *ret_conv = CResult_FundingCreatedDecodeErrorZ_clone(orig_conv);
17656         return (uint64_t)ret_conv;
17657 }
17658
17659 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17660         LDKFundingSigned o_conv;
17661         o_conv.inner = (void*)(o & (~1));
17662         o_conv.is_owned = (o & 1) || (o == 0);
17663         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17664         o_conv = FundingSigned_clone(&o_conv);
17665         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17666         *ret_conv = CResult_FundingSignedDecodeErrorZ_ok(o_conv);
17667         return (uint64_t)ret_conv;
17668 }
17669
17670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17671         LDKDecodeError e_conv;
17672         e_conv.inner = (void*)(e & (~1));
17673         e_conv.is_owned = (e & 1) || (e == 0);
17674         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17675         e_conv = DecodeError_clone(&e_conv);
17676         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17677         *ret_conv = CResult_FundingSignedDecodeErrorZ_err(e_conv);
17678         return (uint64_t)ret_conv;
17679 }
17680
17681 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17682         LDKCResult_FundingSignedDecodeErrorZ* o_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(o & ~1);
17683         jboolean ret_val = CResult_FundingSignedDecodeErrorZ_is_ok(o_conv);
17684         return ret_val;
17685 }
17686
17687 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17688         if ((_res & 1) != 0) return;
17689         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17690         CHECK_ACCESS(_res_ptr);
17691         LDKCResult_FundingSignedDecodeErrorZ _res_conv = *(LDKCResult_FundingSignedDecodeErrorZ*)(_res_ptr);
17692         FREE((void*)_res);
17693         CResult_FundingSignedDecodeErrorZ_free(_res_conv);
17694 }
17695
17696 static inline uint64_t CResult_FundingSignedDecodeErrorZ_clone_ptr(LDKCResult_FundingSignedDecodeErrorZ *NONNULL_PTR arg) {
17697         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17698         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(arg);
17699         return (uint64_t)ret_conv;
17700 }
17701 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17702         LDKCResult_FundingSignedDecodeErrorZ* arg_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(arg & ~1);
17703         int64_t ret_val = CResult_FundingSignedDecodeErrorZ_clone_ptr(arg_conv);
17704         return ret_val;
17705 }
17706
17707 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingSignedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17708         LDKCResult_FundingSignedDecodeErrorZ* orig_conv = (LDKCResult_FundingSignedDecodeErrorZ*)(orig & ~1);
17709         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
17710         *ret_conv = CResult_FundingSignedDecodeErrorZ_clone(orig_conv);
17711         return (uint64_t)ret_conv;
17712 }
17713
17714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17715         LDKFundingLocked o_conv;
17716         o_conv.inner = (void*)(o & (~1));
17717         o_conv.is_owned = (o & 1) || (o == 0);
17718         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17719         o_conv = FundingLocked_clone(&o_conv);
17720         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17721         *ret_conv = CResult_FundingLockedDecodeErrorZ_ok(o_conv);
17722         return (uint64_t)ret_conv;
17723 }
17724
17725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17726         LDKDecodeError e_conv;
17727         e_conv.inner = (void*)(e & (~1));
17728         e_conv.is_owned = (e & 1) || (e == 0);
17729         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17730         e_conv = DecodeError_clone(&e_conv);
17731         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17732         *ret_conv = CResult_FundingLockedDecodeErrorZ_err(e_conv);
17733         return (uint64_t)ret_conv;
17734 }
17735
17736 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17737         LDKCResult_FundingLockedDecodeErrorZ* o_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(o & ~1);
17738         jboolean ret_val = CResult_FundingLockedDecodeErrorZ_is_ok(o_conv);
17739         return ret_val;
17740 }
17741
17742 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17743         if ((_res & 1) != 0) return;
17744         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17745         CHECK_ACCESS(_res_ptr);
17746         LDKCResult_FundingLockedDecodeErrorZ _res_conv = *(LDKCResult_FundingLockedDecodeErrorZ*)(_res_ptr);
17747         FREE((void*)_res);
17748         CResult_FundingLockedDecodeErrorZ_free(_res_conv);
17749 }
17750
17751 static inline uint64_t CResult_FundingLockedDecodeErrorZ_clone_ptr(LDKCResult_FundingLockedDecodeErrorZ *NONNULL_PTR arg) {
17752         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17753         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(arg);
17754         return (uint64_t)ret_conv;
17755 }
17756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17757         LDKCResult_FundingLockedDecodeErrorZ* arg_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(arg & ~1);
17758         int64_t ret_val = CResult_FundingLockedDecodeErrorZ_clone_ptr(arg_conv);
17759         return ret_val;
17760 }
17761
17762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1FundingLockedDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17763         LDKCResult_FundingLockedDecodeErrorZ* orig_conv = (LDKCResult_FundingLockedDecodeErrorZ*)(orig & ~1);
17764         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
17765         *ret_conv = CResult_FundingLockedDecodeErrorZ_clone(orig_conv);
17766         return (uint64_t)ret_conv;
17767 }
17768
17769 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17770         LDKInit o_conv;
17771         o_conv.inner = (void*)(o & (~1));
17772         o_conv.is_owned = (o & 1) || (o == 0);
17773         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17774         o_conv = Init_clone(&o_conv);
17775         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17776         *ret_conv = CResult_InitDecodeErrorZ_ok(o_conv);
17777         return (uint64_t)ret_conv;
17778 }
17779
17780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17781         LDKDecodeError e_conv;
17782         e_conv.inner = (void*)(e & (~1));
17783         e_conv.is_owned = (e & 1) || (e == 0);
17784         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17785         e_conv = DecodeError_clone(&e_conv);
17786         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17787         *ret_conv = CResult_InitDecodeErrorZ_err(e_conv);
17788         return (uint64_t)ret_conv;
17789 }
17790
17791 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17792         LDKCResult_InitDecodeErrorZ* o_conv = (LDKCResult_InitDecodeErrorZ*)(o & ~1);
17793         jboolean ret_val = CResult_InitDecodeErrorZ_is_ok(o_conv);
17794         return ret_val;
17795 }
17796
17797 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17798         if ((_res & 1) != 0) return;
17799         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17800         CHECK_ACCESS(_res_ptr);
17801         LDKCResult_InitDecodeErrorZ _res_conv = *(LDKCResult_InitDecodeErrorZ*)(_res_ptr);
17802         FREE((void*)_res);
17803         CResult_InitDecodeErrorZ_free(_res_conv);
17804 }
17805
17806 static inline uint64_t CResult_InitDecodeErrorZ_clone_ptr(LDKCResult_InitDecodeErrorZ *NONNULL_PTR arg) {
17807         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17808         *ret_conv = CResult_InitDecodeErrorZ_clone(arg);
17809         return (uint64_t)ret_conv;
17810 }
17811 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17812         LDKCResult_InitDecodeErrorZ* arg_conv = (LDKCResult_InitDecodeErrorZ*)(arg & ~1);
17813         int64_t ret_val = CResult_InitDecodeErrorZ_clone_ptr(arg_conv);
17814         return ret_val;
17815 }
17816
17817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InitDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17818         LDKCResult_InitDecodeErrorZ* orig_conv = (LDKCResult_InitDecodeErrorZ*)(orig & ~1);
17819         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
17820         *ret_conv = CResult_InitDecodeErrorZ_clone(orig_conv);
17821         return (uint64_t)ret_conv;
17822 }
17823
17824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17825         LDKOpenChannel o_conv;
17826         o_conv.inner = (void*)(o & (~1));
17827         o_conv.is_owned = (o & 1) || (o == 0);
17828         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17829         o_conv = OpenChannel_clone(&o_conv);
17830         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17831         *ret_conv = CResult_OpenChannelDecodeErrorZ_ok(o_conv);
17832         return (uint64_t)ret_conv;
17833 }
17834
17835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17836         LDKDecodeError e_conv;
17837         e_conv.inner = (void*)(e & (~1));
17838         e_conv.is_owned = (e & 1) || (e == 0);
17839         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17840         e_conv = DecodeError_clone(&e_conv);
17841         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17842         *ret_conv = CResult_OpenChannelDecodeErrorZ_err(e_conv);
17843         return (uint64_t)ret_conv;
17844 }
17845
17846 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17847         LDKCResult_OpenChannelDecodeErrorZ* o_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(o & ~1);
17848         jboolean ret_val = CResult_OpenChannelDecodeErrorZ_is_ok(o_conv);
17849         return ret_val;
17850 }
17851
17852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17853         if ((_res & 1) != 0) return;
17854         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17855         CHECK_ACCESS(_res_ptr);
17856         LDKCResult_OpenChannelDecodeErrorZ _res_conv = *(LDKCResult_OpenChannelDecodeErrorZ*)(_res_ptr);
17857         FREE((void*)_res);
17858         CResult_OpenChannelDecodeErrorZ_free(_res_conv);
17859 }
17860
17861 static inline uint64_t CResult_OpenChannelDecodeErrorZ_clone_ptr(LDKCResult_OpenChannelDecodeErrorZ *NONNULL_PTR arg) {
17862         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17863         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(arg);
17864         return (uint64_t)ret_conv;
17865 }
17866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17867         LDKCResult_OpenChannelDecodeErrorZ* arg_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(arg & ~1);
17868         int64_t ret_val = CResult_OpenChannelDecodeErrorZ_clone_ptr(arg_conv);
17869         return ret_val;
17870 }
17871
17872 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1OpenChannelDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17873         LDKCResult_OpenChannelDecodeErrorZ* orig_conv = (LDKCResult_OpenChannelDecodeErrorZ*)(orig & ~1);
17874         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
17875         *ret_conv = CResult_OpenChannelDecodeErrorZ_clone(orig_conv);
17876         return (uint64_t)ret_conv;
17877 }
17878
17879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17880         LDKRevokeAndACK o_conv;
17881         o_conv.inner = (void*)(o & (~1));
17882         o_conv.is_owned = (o & 1) || (o == 0);
17883         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17884         o_conv = RevokeAndACK_clone(&o_conv);
17885         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17886         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_ok(o_conv);
17887         return (uint64_t)ret_conv;
17888 }
17889
17890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17891         LDKDecodeError e_conv;
17892         e_conv.inner = (void*)(e & (~1));
17893         e_conv.is_owned = (e & 1) || (e == 0);
17894         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17895         e_conv = DecodeError_clone(&e_conv);
17896         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17897         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_err(e_conv);
17898         return (uint64_t)ret_conv;
17899 }
17900
17901 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17902         LDKCResult_RevokeAndACKDecodeErrorZ* o_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(o & ~1);
17903         jboolean ret_val = CResult_RevokeAndACKDecodeErrorZ_is_ok(o_conv);
17904         return ret_val;
17905 }
17906
17907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17908         if ((_res & 1) != 0) return;
17909         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17910         CHECK_ACCESS(_res_ptr);
17911         LDKCResult_RevokeAndACKDecodeErrorZ _res_conv = *(LDKCResult_RevokeAndACKDecodeErrorZ*)(_res_ptr);
17912         FREE((void*)_res);
17913         CResult_RevokeAndACKDecodeErrorZ_free(_res_conv);
17914 }
17915
17916 static inline uint64_t CResult_RevokeAndACKDecodeErrorZ_clone_ptr(LDKCResult_RevokeAndACKDecodeErrorZ *NONNULL_PTR arg) {
17917         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17918         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(arg);
17919         return (uint64_t)ret_conv;
17920 }
17921 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17922         LDKCResult_RevokeAndACKDecodeErrorZ* arg_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(arg & ~1);
17923         int64_t ret_val = CResult_RevokeAndACKDecodeErrorZ_clone_ptr(arg_conv);
17924         return ret_val;
17925 }
17926
17927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1RevokeAndACKDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17928         LDKCResult_RevokeAndACKDecodeErrorZ* orig_conv = (LDKCResult_RevokeAndACKDecodeErrorZ*)(orig & ~1);
17929         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
17930         *ret_conv = CResult_RevokeAndACKDecodeErrorZ_clone(orig_conv);
17931         return (uint64_t)ret_conv;
17932 }
17933
17934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17935         LDKShutdown o_conv;
17936         o_conv.inner = (void*)(o & (~1));
17937         o_conv.is_owned = (o & 1) || (o == 0);
17938         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17939         o_conv = Shutdown_clone(&o_conv);
17940         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17941         *ret_conv = CResult_ShutdownDecodeErrorZ_ok(o_conv);
17942         return (uint64_t)ret_conv;
17943 }
17944
17945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
17946         LDKDecodeError e_conv;
17947         e_conv.inner = (void*)(e & (~1));
17948         e_conv.is_owned = (e & 1) || (e == 0);
17949         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
17950         e_conv = DecodeError_clone(&e_conv);
17951         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17952         *ret_conv = CResult_ShutdownDecodeErrorZ_err(e_conv);
17953         return (uint64_t)ret_conv;
17954 }
17955
17956 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
17957         LDKCResult_ShutdownDecodeErrorZ* o_conv = (LDKCResult_ShutdownDecodeErrorZ*)(o & ~1);
17958         jboolean ret_val = CResult_ShutdownDecodeErrorZ_is_ok(o_conv);
17959         return ret_val;
17960 }
17961
17962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
17963         if ((_res & 1) != 0) return;
17964         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
17965         CHECK_ACCESS(_res_ptr);
17966         LDKCResult_ShutdownDecodeErrorZ _res_conv = *(LDKCResult_ShutdownDecodeErrorZ*)(_res_ptr);
17967         FREE((void*)_res);
17968         CResult_ShutdownDecodeErrorZ_free(_res_conv);
17969 }
17970
17971 static inline uint64_t CResult_ShutdownDecodeErrorZ_clone_ptr(LDKCResult_ShutdownDecodeErrorZ *NONNULL_PTR arg) {
17972         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17973         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(arg);
17974         return (uint64_t)ret_conv;
17975 }
17976 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
17977         LDKCResult_ShutdownDecodeErrorZ* arg_conv = (LDKCResult_ShutdownDecodeErrorZ*)(arg & ~1);
17978         int64_t ret_val = CResult_ShutdownDecodeErrorZ_clone_ptr(arg_conv);
17979         return ret_val;
17980 }
17981
17982 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ShutdownDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
17983         LDKCResult_ShutdownDecodeErrorZ* orig_conv = (LDKCResult_ShutdownDecodeErrorZ*)(orig & ~1);
17984         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
17985         *ret_conv = CResult_ShutdownDecodeErrorZ_clone(orig_conv);
17986         return (uint64_t)ret_conv;
17987 }
17988
17989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
17990         LDKUpdateFailHTLC o_conv;
17991         o_conv.inner = (void*)(o & (~1));
17992         o_conv.is_owned = (o & 1) || (o == 0);
17993         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
17994         o_conv = UpdateFailHTLC_clone(&o_conv);
17995         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
17996         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_ok(o_conv);
17997         return (uint64_t)ret_conv;
17998 }
17999
18000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18001         LDKDecodeError e_conv;
18002         e_conv.inner = (void*)(e & (~1));
18003         e_conv.is_owned = (e & 1) || (e == 0);
18004         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18005         e_conv = DecodeError_clone(&e_conv);
18006         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18007         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_err(e_conv);
18008         return (uint64_t)ret_conv;
18009 }
18010
18011 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18012         LDKCResult_UpdateFailHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(o & ~1);
18013         jboolean ret_val = CResult_UpdateFailHTLCDecodeErrorZ_is_ok(o_conv);
18014         return ret_val;
18015 }
18016
18017 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18018         if ((_res & 1) != 0) return;
18019         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18020         CHECK_ACCESS(_res_ptr);
18021         LDKCResult_UpdateFailHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailHTLCDecodeErrorZ*)(_res_ptr);
18022         FREE((void*)_res);
18023         CResult_UpdateFailHTLCDecodeErrorZ_free(_res_conv);
18024 }
18025
18026 static inline uint64_t CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailHTLCDecodeErrorZ *NONNULL_PTR arg) {
18027         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18028         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(arg);
18029         return (uint64_t)ret_conv;
18030 }
18031 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18032         LDKCResult_UpdateFailHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(arg & ~1);
18033         int64_t ret_val = CResult_UpdateFailHTLCDecodeErrorZ_clone_ptr(arg_conv);
18034         return ret_val;
18035 }
18036
18037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18038         LDKCResult_UpdateFailHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailHTLCDecodeErrorZ*)(orig & ~1);
18039         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
18040         *ret_conv = CResult_UpdateFailHTLCDecodeErrorZ_clone(orig_conv);
18041         return (uint64_t)ret_conv;
18042 }
18043
18044 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18045         LDKUpdateFailMalformedHTLC o_conv;
18046         o_conv.inner = (void*)(o & (~1));
18047         o_conv.is_owned = (o & 1) || (o == 0);
18048         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18049         o_conv = UpdateFailMalformedHTLC_clone(&o_conv);
18050         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18051         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_ok(o_conv);
18052         return (uint64_t)ret_conv;
18053 }
18054
18055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18056         LDKDecodeError e_conv;
18057         e_conv.inner = (void*)(e & (~1));
18058         e_conv.is_owned = (e & 1) || (e == 0);
18059         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18060         e_conv = DecodeError_clone(&e_conv);
18061         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18062         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_err(e_conv);
18063         return (uint64_t)ret_conv;
18064 }
18065
18066 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18067         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(o & ~1);
18068         jboolean ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_is_ok(o_conv);
18069         return ret_val;
18070 }
18071
18072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18073         if ((_res & 1) != 0) return;
18074         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18075         CHECK_ACCESS(_res_ptr);
18076         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(_res_ptr);
18077         FREE((void*)_res);
18078         CResult_UpdateFailMalformedHTLCDecodeErrorZ_free(_res_conv);
18079 }
18080
18081 static inline uint64_t CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ *NONNULL_PTR arg) {
18082         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18083         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(arg);
18084         return (uint64_t)ret_conv;
18085 }
18086 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18087         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(arg & ~1);
18088         int64_t ret_val = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone_ptr(arg_conv);
18089         return ret_val;
18090 }
18091
18092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFailMalformedHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18093         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ*)(orig & ~1);
18094         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
18095         *ret_conv = CResult_UpdateFailMalformedHTLCDecodeErrorZ_clone(orig_conv);
18096         return (uint64_t)ret_conv;
18097 }
18098
18099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18100         LDKUpdateFee o_conv;
18101         o_conv.inner = (void*)(o & (~1));
18102         o_conv.is_owned = (o & 1) || (o == 0);
18103         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18104         o_conv = UpdateFee_clone(&o_conv);
18105         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18106         *ret_conv = CResult_UpdateFeeDecodeErrorZ_ok(o_conv);
18107         return (uint64_t)ret_conv;
18108 }
18109
18110 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18111         LDKDecodeError e_conv;
18112         e_conv.inner = (void*)(e & (~1));
18113         e_conv.is_owned = (e & 1) || (e == 0);
18114         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18115         e_conv = DecodeError_clone(&e_conv);
18116         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18117         *ret_conv = CResult_UpdateFeeDecodeErrorZ_err(e_conv);
18118         return (uint64_t)ret_conv;
18119 }
18120
18121 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18122         LDKCResult_UpdateFeeDecodeErrorZ* o_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(o & ~1);
18123         jboolean ret_val = CResult_UpdateFeeDecodeErrorZ_is_ok(o_conv);
18124         return ret_val;
18125 }
18126
18127 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18128         if ((_res & 1) != 0) return;
18129         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18130         CHECK_ACCESS(_res_ptr);
18131         LDKCResult_UpdateFeeDecodeErrorZ _res_conv = *(LDKCResult_UpdateFeeDecodeErrorZ*)(_res_ptr);
18132         FREE((void*)_res);
18133         CResult_UpdateFeeDecodeErrorZ_free(_res_conv);
18134 }
18135
18136 static inline uint64_t CResult_UpdateFeeDecodeErrorZ_clone_ptr(LDKCResult_UpdateFeeDecodeErrorZ *NONNULL_PTR arg) {
18137         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18138         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(arg);
18139         return (uint64_t)ret_conv;
18140 }
18141 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18142         LDKCResult_UpdateFeeDecodeErrorZ* arg_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(arg & ~1);
18143         int64_t ret_val = CResult_UpdateFeeDecodeErrorZ_clone_ptr(arg_conv);
18144         return ret_val;
18145 }
18146
18147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFeeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18148         LDKCResult_UpdateFeeDecodeErrorZ* orig_conv = (LDKCResult_UpdateFeeDecodeErrorZ*)(orig & ~1);
18149         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
18150         *ret_conv = CResult_UpdateFeeDecodeErrorZ_clone(orig_conv);
18151         return (uint64_t)ret_conv;
18152 }
18153
18154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18155         LDKUpdateFulfillHTLC o_conv;
18156         o_conv.inner = (void*)(o & (~1));
18157         o_conv.is_owned = (o & 1) || (o == 0);
18158         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18159         o_conv = UpdateFulfillHTLC_clone(&o_conv);
18160         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18161         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_ok(o_conv);
18162         return (uint64_t)ret_conv;
18163 }
18164
18165 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18166         LDKDecodeError e_conv;
18167         e_conv.inner = (void*)(e & (~1));
18168         e_conv.is_owned = (e & 1) || (e == 0);
18169         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18170         e_conv = DecodeError_clone(&e_conv);
18171         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18172         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_err(e_conv);
18173         return (uint64_t)ret_conv;
18174 }
18175
18176 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18177         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(o & ~1);
18178         jboolean ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_is_ok(o_conv);
18179         return ret_val;
18180 }
18181
18182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18183         if ((_res & 1) != 0) return;
18184         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18185         CHECK_ACCESS(_res_ptr);
18186         LDKCResult_UpdateFulfillHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(_res_ptr);
18187         FREE((void*)_res);
18188         CResult_UpdateFulfillHTLCDecodeErrorZ_free(_res_conv);
18189 }
18190
18191 static inline uint64_t CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateFulfillHTLCDecodeErrorZ *NONNULL_PTR arg) {
18192         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18193         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(arg);
18194         return (uint64_t)ret_conv;
18195 }
18196 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18197         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(arg & ~1);
18198         int64_t ret_val = CResult_UpdateFulfillHTLCDecodeErrorZ_clone_ptr(arg_conv);
18199         return ret_val;
18200 }
18201
18202 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateFulfillHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18203         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateFulfillHTLCDecodeErrorZ*)(orig & ~1);
18204         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
18205         *ret_conv = CResult_UpdateFulfillHTLCDecodeErrorZ_clone(orig_conv);
18206         return (uint64_t)ret_conv;
18207 }
18208
18209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18210         LDKUpdateAddHTLC o_conv;
18211         o_conv.inner = (void*)(o & (~1));
18212         o_conv.is_owned = (o & 1) || (o == 0);
18213         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18214         o_conv = UpdateAddHTLC_clone(&o_conv);
18215         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18216         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_ok(o_conv);
18217         return (uint64_t)ret_conv;
18218 }
18219
18220 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18221         LDKDecodeError e_conv;
18222         e_conv.inner = (void*)(e & (~1));
18223         e_conv.is_owned = (e & 1) || (e == 0);
18224         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18225         e_conv = DecodeError_clone(&e_conv);
18226         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18227         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_err(e_conv);
18228         return (uint64_t)ret_conv;
18229 }
18230
18231 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18232         LDKCResult_UpdateAddHTLCDecodeErrorZ* o_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(o & ~1);
18233         jboolean ret_val = CResult_UpdateAddHTLCDecodeErrorZ_is_ok(o_conv);
18234         return ret_val;
18235 }
18236
18237 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18238         if ((_res & 1) != 0) return;
18239         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18240         CHECK_ACCESS(_res_ptr);
18241         LDKCResult_UpdateAddHTLCDecodeErrorZ _res_conv = *(LDKCResult_UpdateAddHTLCDecodeErrorZ*)(_res_ptr);
18242         FREE((void*)_res);
18243         CResult_UpdateAddHTLCDecodeErrorZ_free(_res_conv);
18244 }
18245
18246 static inline uint64_t CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(LDKCResult_UpdateAddHTLCDecodeErrorZ *NONNULL_PTR arg) {
18247         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18248         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(arg);
18249         return (uint64_t)ret_conv;
18250 }
18251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18252         LDKCResult_UpdateAddHTLCDecodeErrorZ* arg_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(arg & ~1);
18253         int64_t ret_val = CResult_UpdateAddHTLCDecodeErrorZ_clone_ptr(arg_conv);
18254         return ret_val;
18255 }
18256
18257 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UpdateAddHTLCDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18258         LDKCResult_UpdateAddHTLCDecodeErrorZ* orig_conv = (LDKCResult_UpdateAddHTLCDecodeErrorZ*)(orig & ~1);
18259         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
18260         *ret_conv = CResult_UpdateAddHTLCDecodeErrorZ_clone(orig_conv);
18261         return (uint64_t)ret_conv;
18262 }
18263
18264 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18265         LDKPing o_conv;
18266         o_conv.inner = (void*)(o & (~1));
18267         o_conv.is_owned = (o & 1) || (o == 0);
18268         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18269         o_conv = Ping_clone(&o_conv);
18270         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18271         *ret_conv = CResult_PingDecodeErrorZ_ok(o_conv);
18272         return (uint64_t)ret_conv;
18273 }
18274
18275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18276         LDKDecodeError e_conv;
18277         e_conv.inner = (void*)(e & (~1));
18278         e_conv.is_owned = (e & 1) || (e == 0);
18279         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18280         e_conv = DecodeError_clone(&e_conv);
18281         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18282         *ret_conv = CResult_PingDecodeErrorZ_err(e_conv);
18283         return (uint64_t)ret_conv;
18284 }
18285
18286 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18287         LDKCResult_PingDecodeErrorZ* o_conv = (LDKCResult_PingDecodeErrorZ*)(o & ~1);
18288         jboolean ret_val = CResult_PingDecodeErrorZ_is_ok(o_conv);
18289         return ret_val;
18290 }
18291
18292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18293         if ((_res & 1) != 0) return;
18294         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18295         CHECK_ACCESS(_res_ptr);
18296         LDKCResult_PingDecodeErrorZ _res_conv = *(LDKCResult_PingDecodeErrorZ*)(_res_ptr);
18297         FREE((void*)_res);
18298         CResult_PingDecodeErrorZ_free(_res_conv);
18299 }
18300
18301 static inline uint64_t CResult_PingDecodeErrorZ_clone_ptr(LDKCResult_PingDecodeErrorZ *NONNULL_PTR arg) {
18302         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18303         *ret_conv = CResult_PingDecodeErrorZ_clone(arg);
18304         return (uint64_t)ret_conv;
18305 }
18306 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18307         LDKCResult_PingDecodeErrorZ* arg_conv = (LDKCResult_PingDecodeErrorZ*)(arg & ~1);
18308         int64_t ret_val = CResult_PingDecodeErrorZ_clone_ptr(arg_conv);
18309         return ret_val;
18310 }
18311
18312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PingDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18313         LDKCResult_PingDecodeErrorZ* orig_conv = (LDKCResult_PingDecodeErrorZ*)(orig & ~1);
18314         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
18315         *ret_conv = CResult_PingDecodeErrorZ_clone(orig_conv);
18316         return (uint64_t)ret_conv;
18317 }
18318
18319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18320         LDKPong o_conv;
18321         o_conv.inner = (void*)(o & (~1));
18322         o_conv.is_owned = (o & 1) || (o == 0);
18323         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18324         o_conv = Pong_clone(&o_conv);
18325         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18326         *ret_conv = CResult_PongDecodeErrorZ_ok(o_conv);
18327         return (uint64_t)ret_conv;
18328 }
18329
18330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18331         LDKDecodeError e_conv;
18332         e_conv.inner = (void*)(e & (~1));
18333         e_conv.is_owned = (e & 1) || (e == 0);
18334         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18335         e_conv = DecodeError_clone(&e_conv);
18336         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18337         *ret_conv = CResult_PongDecodeErrorZ_err(e_conv);
18338         return (uint64_t)ret_conv;
18339 }
18340
18341 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18342         LDKCResult_PongDecodeErrorZ* o_conv = (LDKCResult_PongDecodeErrorZ*)(o & ~1);
18343         jboolean ret_val = CResult_PongDecodeErrorZ_is_ok(o_conv);
18344         return ret_val;
18345 }
18346
18347 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18348         if ((_res & 1) != 0) return;
18349         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18350         CHECK_ACCESS(_res_ptr);
18351         LDKCResult_PongDecodeErrorZ _res_conv = *(LDKCResult_PongDecodeErrorZ*)(_res_ptr);
18352         FREE((void*)_res);
18353         CResult_PongDecodeErrorZ_free(_res_conv);
18354 }
18355
18356 static inline uint64_t CResult_PongDecodeErrorZ_clone_ptr(LDKCResult_PongDecodeErrorZ *NONNULL_PTR arg) {
18357         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18358         *ret_conv = CResult_PongDecodeErrorZ_clone(arg);
18359         return (uint64_t)ret_conv;
18360 }
18361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18362         LDKCResult_PongDecodeErrorZ* arg_conv = (LDKCResult_PongDecodeErrorZ*)(arg & ~1);
18363         int64_t ret_val = CResult_PongDecodeErrorZ_clone_ptr(arg_conv);
18364         return ret_val;
18365 }
18366
18367 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1PongDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18368         LDKCResult_PongDecodeErrorZ* orig_conv = (LDKCResult_PongDecodeErrorZ*)(orig & ~1);
18369         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
18370         *ret_conv = CResult_PongDecodeErrorZ_clone(orig_conv);
18371         return (uint64_t)ret_conv;
18372 }
18373
18374 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18375         LDKUnsignedChannelAnnouncement o_conv;
18376         o_conv.inner = (void*)(o & (~1));
18377         o_conv.is_owned = (o & 1) || (o == 0);
18378         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18379         o_conv = UnsignedChannelAnnouncement_clone(&o_conv);
18380         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18381         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_ok(o_conv);
18382         return (uint64_t)ret_conv;
18383 }
18384
18385 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18386         LDKDecodeError e_conv;
18387         e_conv.inner = (void*)(e & (~1));
18388         e_conv.is_owned = (e & 1) || (e == 0);
18389         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18390         e_conv = DecodeError_clone(&e_conv);
18391         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18392         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_err(e_conv);
18393         return (uint64_t)ret_conv;
18394 }
18395
18396 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18397         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(o & ~1);
18398         jboolean ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18399         return ret_val;
18400 }
18401
18402 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18403         if ((_res & 1) != 0) return;
18404         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18405         CHECK_ACCESS(_res_ptr);
18406         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18407         FREE((void*)_res);
18408         CResult_UnsignedChannelAnnouncementDecodeErrorZ_free(_res_conv);
18409 }
18410
18411 static inline uint64_t CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18412         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18413         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(arg);
18414         return (uint64_t)ret_conv;
18415 }
18416 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18417         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18418         int64_t ret_val = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18419         return ret_val;
18420 }
18421
18422 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18423         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18424         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
18425         *ret_conv = CResult_UnsignedChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18426         return (uint64_t)ret_conv;
18427 }
18428
18429 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18430         LDKChannelAnnouncement o_conv;
18431         o_conv.inner = (void*)(o & (~1));
18432         o_conv.is_owned = (o & 1) || (o == 0);
18433         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18434         o_conv = ChannelAnnouncement_clone(&o_conv);
18435         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18436         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_ok(o_conv);
18437         return (uint64_t)ret_conv;
18438 }
18439
18440 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18441         LDKDecodeError e_conv;
18442         e_conv.inner = (void*)(e & (~1));
18443         e_conv.is_owned = (e & 1) || (e == 0);
18444         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18445         e_conv = DecodeError_clone(&e_conv);
18446         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18447         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_err(e_conv);
18448         return (uint64_t)ret_conv;
18449 }
18450
18451 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18452         LDKCResult_ChannelAnnouncementDecodeErrorZ* o_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(o & ~1);
18453         jboolean ret_val = CResult_ChannelAnnouncementDecodeErrorZ_is_ok(o_conv);
18454         return ret_val;
18455 }
18456
18457 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18458         if ((_res & 1) != 0) return;
18459         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18460         CHECK_ACCESS(_res_ptr);
18461         LDKCResult_ChannelAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_ChannelAnnouncementDecodeErrorZ*)(_res_ptr);
18462         FREE((void*)_res);
18463         CResult_ChannelAnnouncementDecodeErrorZ_free(_res_conv);
18464 }
18465
18466 static inline uint64_t CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_ChannelAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18467         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18468         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(arg);
18469         return (uint64_t)ret_conv;
18470 }
18471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18472         LDKCResult_ChannelAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(arg & ~1);
18473         int64_t ret_val = CResult_ChannelAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18474         return ret_val;
18475 }
18476
18477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18478         LDKCResult_ChannelAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_ChannelAnnouncementDecodeErrorZ*)(orig & ~1);
18479         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
18480         *ret_conv = CResult_ChannelAnnouncementDecodeErrorZ_clone(orig_conv);
18481         return (uint64_t)ret_conv;
18482 }
18483
18484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18485         LDKUnsignedChannelUpdate o_conv;
18486         o_conv.inner = (void*)(o & (~1));
18487         o_conv.is_owned = (o & 1) || (o == 0);
18488         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18489         o_conv = UnsignedChannelUpdate_clone(&o_conv);
18490         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18491         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_ok(o_conv);
18492         return (uint64_t)ret_conv;
18493 }
18494
18495 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18496         LDKDecodeError e_conv;
18497         e_conv.inner = (void*)(e & (~1));
18498         e_conv.is_owned = (e & 1) || (e == 0);
18499         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18500         e_conv = DecodeError_clone(&e_conv);
18501         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18502         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_err(e_conv);
18503         return (uint64_t)ret_conv;
18504 }
18505
18506 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18507         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(o & ~1);
18508         jboolean ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_is_ok(o_conv);
18509         return ret_val;
18510 }
18511
18512 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18513         if ((_res & 1) != 0) return;
18514         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18515         CHECK_ACCESS(_res_ptr);
18516         LDKCResult_UnsignedChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(_res_ptr);
18517         FREE((void*)_res);
18518         CResult_UnsignedChannelUpdateDecodeErrorZ_free(_res_conv);
18519 }
18520
18521 static inline uint64_t CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_UnsignedChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18522         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18523         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(arg);
18524         return (uint64_t)ret_conv;
18525 }
18526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18527         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(arg & ~1);
18528         int64_t ret_val = CResult_UnsignedChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18529         return ret_val;
18530 }
18531
18532 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18533         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_UnsignedChannelUpdateDecodeErrorZ*)(orig & ~1);
18534         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
18535         *ret_conv = CResult_UnsignedChannelUpdateDecodeErrorZ_clone(orig_conv);
18536         return (uint64_t)ret_conv;
18537 }
18538
18539 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18540         LDKChannelUpdate o_conv;
18541         o_conv.inner = (void*)(o & (~1));
18542         o_conv.is_owned = (o & 1) || (o == 0);
18543         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18544         o_conv = ChannelUpdate_clone(&o_conv);
18545         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18546         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_ok(o_conv);
18547         return (uint64_t)ret_conv;
18548 }
18549
18550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18551         LDKDecodeError e_conv;
18552         e_conv.inner = (void*)(e & (~1));
18553         e_conv.is_owned = (e & 1) || (e == 0);
18554         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18555         e_conv = DecodeError_clone(&e_conv);
18556         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18557         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_err(e_conv);
18558         return (uint64_t)ret_conv;
18559 }
18560
18561 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18562         LDKCResult_ChannelUpdateDecodeErrorZ* o_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(o & ~1);
18563         jboolean ret_val = CResult_ChannelUpdateDecodeErrorZ_is_ok(o_conv);
18564         return ret_val;
18565 }
18566
18567 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18568         if ((_res & 1) != 0) return;
18569         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18570         CHECK_ACCESS(_res_ptr);
18571         LDKCResult_ChannelUpdateDecodeErrorZ _res_conv = *(LDKCResult_ChannelUpdateDecodeErrorZ*)(_res_ptr);
18572         FREE((void*)_res);
18573         CResult_ChannelUpdateDecodeErrorZ_free(_res_conv);
18574 }
18575
18576 static inline uint64_t CResult_ChannelUpdateDecodeErrorZ_clone_ptr(LDKCResult_ChannelUpdateDecodeErrorZ *NONNULL_PTR arg) {
18577         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18578         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(arg);
18579         return (uint64_t)ret_conv;
18580 }
18581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18582         LDKCResult_ChannelUpdateDecodeErrorZ* arg_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(arg & ~1);
18583         int64_t ret_val = CResult_ChannelUpdateDecodeErrorZ_clone_ptr(arg_conv);
18584         return ret_val;
18585 }
18586
18587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ChannelUpdateDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18588         LDKCResult_ChannelUpdateDecodeErrorZ* orig_conv = (LDKCResult_ChannelUpdateDecodeErrorZ*)(orig & ~1);
18589         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
18590         *ret_conv = CResult_ChannelUpdateDecodeErrorZ_clone(orig_conv);
18591         return (uint64_t)ret_conv;
18592 }
18593
18594 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18595         LDKErrorMessage o_conv;
18596         o_conv.inner = (void*)(o & (~1));
18597         o_conv.is_owned = (o & 1) || (o == 0);
18598         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18599         o_conv = ErrorMessage_clone(&o_conv);
18600         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18601         *ret_conv = CResult_ErrorMessageDecodeErrorZ_ok(o_conv);
18602         return (uint64_t)ret_conv;
18603 }
18604
18605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18606         LDKDecodeError e_conv;
18607         e_conv.inner = (void*)(e & (~1));
18608         e_conv.is_owned = (e & 1) || (e == 0);
18609         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18610         e_conv = DecodeError_clone(&e_conv);
18611         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18612         *ret_conv = CResult_ErrorMessageDecodeErrorZ_err(e_conv);
18613         return (uint64_t)ret_conv;
18614 }
18615
18616 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18617         LDKCResult_ErrorMessageDecodeErrorZ* o_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(o & ~1);
18618         jboolean ret_val = CResult_ErrorMessageDecodeErrorZ_is_ok(o_conv);
18619         return ret_val;
18620 }
18621
18622 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18623         if ((_res & 1) != 0) return;
18624         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18625         CHECK_ACCESS(_res_ptr);
18626         LDKCResult_ErrorMessageDecodeErrorZ _res_conv = *(LDKCResult_ErrorMessageDecodeErrorZ*)(_res_ptr);
18627         FREE((void*)_res);
18628         CResult_ErrorMessageDecodeErrorZ_free(_res_conv);
18629 }
18630
18631 static inline uint64_t CResult_ErrorMessageDecodeErrorZ_clone_ptr(LDKCResult_ErrorMessageDecodeErrorZ *NONNULL_PTR arg) {
18632         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18633         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(arg);
18634         return (uint64_t)ret_conv;
18635 }
18636 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18637         LDKCResult_ErrorMessageDecodeErrorZ* arg_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(arg & ~1);
18638         int64_t ret_val = CResult_ErrorMessageDecodeErrorZ_clone_ptr(arg_conv);
18639         return ret_val;
18640 }
18641
18642 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ErrorMessageDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18643         LDKCResult_ErrorMessageDecodeErrorZ* orig_conv = (LDKCResult_ErrorMessageDecodeErrorZ*)(orig & ~1);
18644         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
18645         *ret_conv = CResult_ErrorMessageDecodeErrorZ_clone(orig_conv);
18646         return (uint64_t)ret_conv;
18647 }
18648
18649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18650         LDKUnsignedNodeAnnouncement o_conv;
18651         o_conv.inner = (void*)(o & (~1));
18652         o_conv.is_owned = (o & 1) || (o == 0);
18653         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18654         o_conv = UnsignedNodeAnnouncement_clone(&o_conv);
18655         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18656         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_ok(o_conv);
18657         return (uint64_t)ret_conv;
18658 }
18659
18660 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18661         LDKDecodeError e_conv;
18662         e_conv.inner = (void*)(e & (~1));
18663         e_conv.is_owned = (e & 1) || (e == 0);
18664         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18665         e_conv = DecodeError_clone(&e_conv);
18666         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18667         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_err(e_conv);
18668         return (uint64_t)ret_conv;
18669 }
18670
18671 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18672         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(o & ~1);
18673         jboolean ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18674         return ret_val;
18675 }
18676
18677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18678         if ((_res & 1) != 0) return;
18679         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18680         CHECK_ACCESS(_res_ptr);
18681         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(_res_ptr);
18682         FREE((void*)_res);
18683         CResult_UnsignedNodeAnnouncementDecodeErrorZ_free(_res_conv);
18684 }
18685
18686 static inline uint64_t CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18687         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18688         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(arg);
18689         return (uint64_t)ret_conv;
18690 }
18691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18692         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(arg & ~1);
18693         int64_t ret_val = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18694         return ret_val;
18695 }
18696
18697 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1UnsignedNodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18698         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ*)(orig & ~1);
18699         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
18700         *ret_conv = CResult_UnsignedNodeAnnouncementDecodeErrorZ_clone(orig_conv);
18701         return (uint64_t)ret_conv;
18702 }
18703
18704 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18705         LDKNodeAnnouncement o_conv;
18706         o_conv.inner = (void*)(o & (~1));
18707         o_conv.is_owned = (o & 1) || (o == 0);
18708         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18709         o_conv = NodeAnnouncement_clone(&o_conv);
18710         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18711         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_ok(o_conv);
18712         return (uint64_t)ret_conv;
18713 }
18714
18715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18716         LDKDecodeError e_conv;
18717         e_conv.inner = (void*)(e & (~1));
18718         e_conv.is_owned = (e & 1) || (e == 0);
18719         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18720         e_conv = DecodeError_clone(&e_conv);
18721         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18722         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_err(e_conv);
18723         return (uint64_t)ret_conv;
18724 }
18725
18726 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18727         LDKCResult_NodeAnnouncementDecodeErrorZ* o_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(o & ~1);
18728         jboolean ret_val = CResult_NodeAnnouncementDecodeErrorZ_is_ok(o_conv);
18729         return ret_val;
18730 }
18731
18732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18733         if ((_res & 1) != 0) return;
18734         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18735         CHECK_ACCESS(_res_ptr);
18736         LDKCResult_NodeAnnouncementDecodeErrorZ _res_conv = *(LDKCResult_NodeAnnouncementDecodeErrorZ*)(_res_ptr);
18737         FREE((void*)_res);
18738         CResult_NodeAnnouncementDecodeErrorZ_free(_res_conv);
18739 }
18740
18741 static inline uint64_t CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(LDKCResult_NodeAnnouncementDecodeErrorZ *NONNULL_PTR arg) {
18742         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18743         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(arg);
18744         return (uint64_t)ret_conv;
18745 }
18746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18747         LDKCResult_NodeAnnouncementDecodeErrorZ* arg_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(arg & ~1);
18748         int64_t ret_val = CResult_NodeAnnouncementDecodeErrorZ_clone_ptr(arg_conv);
18749         return ret_val;
18750 }
18751
18752 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1NodeAnnouncementDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18753         LDKCResult_NodeAnnouncementDecodeErrorZ* orig_conv = (LDKCResult_NodeAnnouncementDecodeErrorZ*)(orig & ~1);
18754         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
18755         *ret_conv = CResult_NodeAnnouncementDecodeErrorZ_clone(orig_conv);
18756         return (uint64_t)ret_conv;
18757 }
18758
18759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18760         LDKQueryShortChannelIds o_conv;
18761         o_conv.inner = (void*)(o & (~1));
18762         o_conv.is_owned = (o & 1) || (o == 0);
18763         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18764         o_conv = QueryShortChannelIds_clone(&o_conv);
18765         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18766         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_ok(o_conv);
18767         return (uint64_t)ret_conv;
18768 }
18769
18770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18771         LDKDecodeError e_conv;
18772         e_conv.inner = (void*)(e & (~1));
18773         e_conv.is_owned = (e & 1) || (e == 0);
18774         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18775         e_conv = DecodeError_clone(&e_conv);
18776         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18777         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_err(e_conv);
18778         return (uint64_t)ret_conv;
18779 }
18780
18781 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18782         LDKCResult_QueryShortChannelIdsDecodeErrorZ* o_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(o & ~1);
18783         jboolean ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_is_ok(o_conv);
18784         return ret_val;
18785 }
18786
18787 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18788         if ((_res & 1) != 0) return;
18789         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18790         CHECK_ACCESS(_res_ptr);
18791         LDKCResult_QueryShortChannelIdsDecodeErrorZ _res_conv = *(LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(_res_ptr);
18792         FREE((void*)_res);
18793         CResult_QueryShortChannelIdsDecodeErrorZ_free(_res_conv);
18794 }
18795
18796 static inline uint64_t CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(LDKCResult_QueryShortChannelIdsDecodeErrorZ *NONNULL_PTR arg) {
18797         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18798         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(arg);
18799         return (uint64_t)ret_conv;
18800 }
18801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18802         LDKCResult_QueryShortChannelIdsDecodeErrorZ* arg_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(arg & ~1);
18803         int64_t ret_val = CResult_QueryShortChannelIdsDecodeErrorZ_clone_ptr(arg_conv);
18804         return ret_val;
18805 }
18806
18807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryShortChannelIdsDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18808         LDKCResult_QueryShortChannelIdsDecodeErrorZ* orig_conv = (LDKCResult_QueryShortChannelIdsDecodeErrorZ*)(orig & ~1);
18809         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
18810         *ret_conv = CResult_QueryShortChannelIdsDecodeErrorZ_clone(orig_conv);
18811         return (uint64_t)ret_conv;
18812 }
18813
18814 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18815         LDKReplyShortChannelIdsEnd o_conv;
18816         o_conv.inner = (void*)(o & (~1));
18817         o_conv.is_owned = (o & 1) || (o == 0);
18818         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18819         o_conv = ReplyShortChannelIdsEnd_clone(&o_conv);
18820         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18821         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_ok(o_conv);
18822         return (uint64_t)ret_conv;
18823 }
18824
18825 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18826         LDKDecodeError e_conv;
18827         e_conv.inner = (void*)(e & (~1));
18828         e_conv.is_owned = (e & 1) || (e == 0);
18829         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18830         e_conv = DecodeError_clone(&e_conv);
18831         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18832         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_err(e_conv);
18833         return (uint64_t)ret_conv;
18834 }
18835
18836 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18837         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* o_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(o & ~1);
18838         jboolean ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_is_ok(o_conv);
18839         return ret_val;
18840 }
18841
18842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18843         if ((_res & 1) != 0) return;
18844         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18845         CHECK_ACCESS(_res_ptr);
18846         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ _res_conv = *(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(_res_ptr);
18847         FREE((void*)_res);
18848         CResult_ReplyShortChannelIdsEndDecodeErrorZ_free(_res_conv);
18849 }
18850
18851 static inline uint64_t CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ *NONNULL_PTR arg) {
18852         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18853         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(arg);
18854         return (uint64_t)ret_conv;
18855 }
18856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18857         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* arg_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(arg & ~1);
18858         int64_t ret_val = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone_ptr(arg_conv);
18859         return ret_val;
18860 }
18861
18862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyShortChannelIdsEndDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18863         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* orig_conv = (LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ*)(orig & ~1);
18864         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
18865         *ret_conv = CResult_ReplyShortChannelIdsEndDecodeErrorZ_clone(orig_conv);
18866         return (uint64_t)ret_conv;
18867 }
18868
18869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18870         LDKQueryChannelRange o_conv;
18871         o_conv.inner = (void*)(o & (~1));
18872         o_conv.is_owned = (o & 1) || (o == 0);
18873         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18874         o_conv = QueryChannelRange_clone(&o_conv);
18875         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18876         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_ok(o_conv);
18877         return (uint64_t)ret_conv;
18878 }
18879
18880 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18881         LDKDecodeError e_conv;
18882         e_conv.inner = (void*)(e & (~1));
18883         e_conv.is_owned = (e & 1) || (e == 0);
18884         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18885         e_conv = DecodeError_clone(&e_conv);
18886         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18887         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_err(e_conv);
18888         return (uint64_t)ret_conv;
18889 }
18890
18891 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18892         LDKCResult_QueryChannelRangeDecodeErrorZ* o_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(o & ~1);
18893         jboolean ret_val = CResult_QueryChannelRangeDecodeErrorZ_is_ok(o_conv);
18894         return ret_val;
18895 }
18896
18897 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18898         if ((_res & 1) != 0) return;
18899         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18900         CHECK_ACCESS(_res_ptr);
18901         LDKCResult_QueryChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_QueryChannelRangeDecodeErrorZ*)(_res_ptr);
18902         FREE((void*)_res);
18903         CResult_QueryChannelRangeDecodeErrorZ_free(_res_conv);
18904 }
18905
18906 static inline uint64_t CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_QueryChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
18907         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18908         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(arg);
18909         return (uint64_t)ret_conv;
18910 }
18911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18912         LDKCResult_QueryChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(arg & ~1);
18913         int64_t ret_val = CResult_QueryChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
18914         return ret_val;
18915 }
18916
18917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1QueryChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18918         LDKCResult_QueryChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_QueryChannelRangeDecodeErrorZ*)(orig & ~1);
18919         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
18920         *ret_conv = CResult_QueryChannelRangeDecodeErrorZ_clone(orig_conv);
18921         return (uint64_t)ret_conv;
18922 }
18923
18924 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18925         LDKReplyChannelRange o_conv;
18926         o_conv.inner = (void*)(o & (~1));
18927         o_conv.is_owned = (o & 1) || (o == 0);
18928         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18929         o_conv = ReplyChannelRange_clone(&o_conv);
18930         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18931         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_ok(o_conv);
18932         return (uint64_t)ret_conv;
18933 }
18934
18935 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18936         LDKDecodeError e_conv;
18937         e_conv.inner = (void*)(e & (~1));
18938         e_conv.is_owned = (e & 1) || (e == 0);
18939         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18940         e_conv = DecodeError_clone(&e_conv);
18941         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18942         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_err(e_conv);
18943         return (uint64_t)ret_conv;
18944 }
18945
18946 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
18947         LDKCResult_ReplyChannelRangeDecodeErrorZ* o_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(o & ~1);
18948         jboolean ret_val = CResult_ReplyChannelRangeDecodeErrorZ_is_ok(o_conv);
18949         return ret_val;
18950 }
18951
18952 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
18953         if ((_res & 1) != 0) return;
18954         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
18955         CHECK_ACCESS(_res_ptr);
18956         LDKCResult_ReplyChannelRangeDecodeErrorZ _res_conv = *(LDKCResult_ReplyChannelRangeDecodeErrorZ*)(_res_ptr);
18957         FREE((void*)_res);
18958         CResult_ReplyChannelRangeDecodeErrorZ_free(_res_conv);
18959 }
18960
18961 static inline uint64_t CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(LDKCResult_ReplyChannelRangeDecodeErrorZ *NONNULL_PTR arg) {
18962         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18963         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(arg);
18964         return (uint64_t)ret_conv;
18965 }
18966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
18967         LDKCResult_ReplyChannelRangeDecodeErrorZ* arg_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(arg & ~1);
18968         int64_t ret_val = CResult_ReplyChannelRangeDecodeErrorZ_clone_ptr(arg_conv);
18969         return ret_val;
18970 }
18971
18972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1ReplyChannelRangeDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
18973         LDKCResult_ReplyChannelRangeDecodeErrorZ* orig_conv = (LDKCResult_ReplyChannelRangeDecodeErrorZ*)(orig & ~1);
18974         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
18975         *ret_conv = CResult_ReplyChannelRangeDecodeErrorZ_clone(orig_conv);
18976         return (uint64_t)ret_conv;
18977 }
18978
18979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
18980         LDKGossipTimestampFilter o_conv;
18981         o_conv.inner = (void*)(o & (~1));
18982         o_conv.is_owned = (o & 1) || (o == 0);
18983         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
18984         o_conv = GossipTimestampFilter_clone(&o_conv);
18985         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18986         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_ok(o_conv);
18987         return (uint64_t)ret_conv;
18988 }
18989
18990 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
18991         LDKDecodeError e_conv;
18992         e_conv.inner = (void*)(e & (~1));
18993         e_conv.is_owned = (e & 1) || (e == 0);
18994         CHECK_INNER_FIELD_ACCESS_OR_NULL(e_conv);
18995         e_conv = DecodeError_clone(&e_conv);
18996         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
18997         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_err(e_conv);
18998         return (uint64_t)ret_conv;
18999 }
19000
19001 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19002         LDKCResult_GossipTimestampFilterDecodeErrorZ* o_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(o & ~1);
19003         jboolean ret_val = CResult_GossipTimestampFilterDecodeErrorZ_is_ok(o_conv);
19004         return ret_val;
19005 }
19006
19007 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19008         if ((_res & 1) != 0) return;
19009         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19010         CHECK_ACCESS(_res_ptr);
19011         LDKCResult_GossipTimestampFilterDecodeErrorZ _res_conv = *(LDKCResult_GossipTimestampFilterDecodeErrorZ*)(_res_ptr);
19012         FREE((void*)_res);
19013         CResult_GossipTimestampFilterDecodeErrorZ_free(_res_conv);
19014 }
19015
19016 static inline uint64_t CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(LDKCResult_GossipTimestampFilterDecodeErrorZ *NONNULL_PTR arg) {
19017         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19018         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(arg);
19019         return (uint64_t)ret_conv;
19020 }
19021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19022         LDKCResult_GossipTimestampFilterDecodeErrorZ* arg_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(arg & ~1);
19023         int64_t ret_val = CResult_GossipTimestampFilterDecodeErrorZ_clone_ptr(arg_conv);
19024         return ret_val;
19025 }
19026
19027 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1GossipTimestampFilterDecodeErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19028         LDKCResult_GossipTimestampFilterDecodeErrorZ* orig_conv = (LDKCResult_GossipTimestampFilterDecodeErrorZ*)(orig & ~1);
19029         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
19030         *ret_conv = CResult_GossipTimestampFilterDecodeErrorZ_clone(orig_conv);
19031         return (uint64_t)ret_conv;
19032 }
19033
19034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19035         LDKInvoice o_conv;
19036         o_conv.inner = (void*)(o & (~1));
19037         o_conv.is_owned = (o & 1) || (o == 0);
19038         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19039         o_conv = Invoice_clone(&o_conv);
19040         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19041         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_ok(o_conv);
19042         return (uint64_t)ret_conv;
19043 }
19044
19045 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1err(JNIEnv *env, jclass clz, int64_t e) {
19046         void* e_ptr = (void*)(((uint64_t)e) & ~1);
19047         CHECK_ACCESS(e_ptr);
19048         LDKSignOrCreationError e_conv = *(LDKSignOrCreationError*)(e_ptr);
19049         e_conv = SignOrCreationError_clone((LDKSignOrCreationError*)(((uint64_t)e) & ~1));
19050         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19051         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_err(e_conv);
19052         return (uint64_t)ret_conv;
19053 }
19054
19055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19056         LDKCResult_InvoiceSignOrCreationErrorZ* o_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(o & ~1);
19057         jboolean ret_val = CResult_InvoiceSignOrCreationErrorZ_is_ok(o_conv);
19058         return ret_val;
19059 }
19060
19061 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19062         if ((_res & 1) != 0) return;
19063         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19064         CHECK_ACCESS(_res_ptr);
19065         LDKCResult_InvoiceSignOrCreationErrorZ _res_conv = *(LDKCResult_InvoiceSignOrCreationErrorZ*)(_res_ptr);
19066         FREE((void*)_res);
19067         CResult_InvoiceSignOrCreationErrorZ_free(_res_conv);
19068 }
19069
19070 static inline uint64_t CResult_InvoiceSignOrCreationErrorZ_clone_ptr(LDKCResult_InvoiceSignOrCreationErrorZ *NONNULL_PTR arg) {
19071         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19072         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(arg);
19073         return (uint64_t)ret_conv;
19074 }
19075 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19076         LDKCResult_InvoiceSignOrCreationErrorZ* arg_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(arg & ~1);
19077         int64_t ret_val = CResult_InvoiceSignOrCreationErrorZ_clone_ptr(arg_conv);
19078         return ret_val;
19079 }
19080
19081 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1InvoiceSignOrCreationErrorZ_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19082         LDKCResult_InvoiceSignOrCreationErrorZ* orig_conv = (LDKCResult_InvoiceSignOrCreationErrorZ*)(orig & ~1);
19083         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
19084         *ret_conv = CResult_InvoiceSignOrCreationErrorZ_clone(orig_conv);
19085         return (uint64_t)ret_conv;
19086 }
19087
19088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1some(JNIEnv *env, jclass clz, int64_t o) {
19089         void* o_ptr = (void*)(((uint64_t)o) & ~1);
19090         CHECK_ACCESS(o_ptr);
19091         LDKFilter o_conv = *(LDKFilter*)(o_ptr);
19092         if (o_conv.free == LDKFilter_JCalls_free) {
19093                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
19094                 LDKFilter_JCalls_cloned(&o_conv);
19095         }
19096         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19097         *ret_copy = COption_FilterZ_some(o_conv);
19098         uint64_t ret_ref = (uint64_t)ret_copy;
19099         return ret_ref;
19100 }
19101
19102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1none(JNIEnv *env, jclass clz) {
19103         LDKCOption_FilterZ *ret_copy = MALLOC(sizeof(LDKCOption_FilterZ), "LDKCOption_FilterZ");
19104         *ret_copy = COption_FilterZ_none();
19105         uint64_t ret_ref = (uint64_t)ret_copy;
19106         return ret_ref;
19107 }
19108
19109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_COption_1FilterZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19110         if ((_res & 1) != 0) return;
19111         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19112         CHECK_ACCESS(_res_ptr);
19113         LDKCOption_FilterZ _res_conv = *(LDKCOption_FilterZ*)(_res_ptr);
19114         FREE((void*)_res);
19115         COption_FilterZ_free(_res_conv);
19116 }
19117
19118 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1ok(JNIEnv *env, jclass clz, int64_t o) {
19119         LDKLockedChannelMonitor o_conv;
19120         o_conv.inner = (void*)(o & (~1));
19121         o_conv.is_owned = (o & 1) || (o == 0);
19122         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
19123         // Warning: we need a move here but no clone is available for LDKLockedChannelMonitor
19124         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19125         *ret_conv = CResult_LockedChannelMonitorNoneZ_ok(o_conv);
19126         return (uint64_t)ret_conv;
19127 }
19128
19129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1err(JNIEnv *env, jclass clz) {
19130         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
19131         *ret_conv = CResult_LockedChannelMonitorNoneZ_err();
19132         return (uint64_t)ret_conv;
19133 }
19134
19135 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1is_1ok(JNIEnv *env, jclass clz, int64_t o) {
19136         LDKCResult_LockedChannelMonitorNoneZ* o_conv = (LDKCResult_LockedChannelMonitorNoneZ*)(o & ~1);
19137         jboolean ret_val = CResult_LockedChannelMonitorNoneZ_is_ok(o_conv);
19138         return ret_val;
19139 }
19140
19141 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CResult_1LockedChannelMonitorNoneZ_1free(JNIEnv *env, jclass clz, int64_t _res) {
19142         if ((_res & 1) != 0) return;
19143         void* _res_ptr = (void*)(((uint64_t)_res) & ~1);
19144         CHECK_ACCESS(_res_ptr);
19145         LDKCResult_LockedChannelMonitorNoneZ _res_conv = *(LDKCResult_LockedChannelMonitorNoneZ*)(_res_ptr);
19146         FREE((void*)_res);
19147         CResult_LockedChannelMonitorNoneZ_free(_res_conv);
19148 }
19149
19150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CVec_1OutPointZ_1free(JNIEnv *env, jclass clz, int64_tArray _res) {
19151         LDKCVec_OutPointZ _res_constr;
19152         _res_constr.datalen = (*env)->GetArrayLength(env, _res);
19153         if (_res_constr.datalen > 0)
19154                 _res_constr.data = MALLOC(_res_constr.datalen * sizeof(LDKOutPoint), "LDKCVec_OutPointZ Elements");
19155         else
19156                 _res_constr.data = NULL;
19157         int64_t* _res_vals = (*env)->GetLongArrayElements (env, _res, NULL);
19158         for (size_t k = 0; k < _res_constr.datalen; k++) {
19159                 int64_t _res_conv_10 = _res_vals[k];
19160                 LDKOutPoint _res_conv_10_conv;
19161                 _res_conv_10_conv.inner = (void*)(_res_conv_10 & (~1));
19162                 _res_conv_10_conv.is_owned = (_res_conv_10 & 1) || (_res_conv_10 == 0);
19163                 CHECK_INNER_FIELD_ACCESS_OR_NULL(_res_conv_10_conv);
19164                 _res_constr.data[k] = _res_conv_10_conv;
19165         }
19166         (*env)->ReleaseLongArrayElements(env, _res, _res_vals, 0);
19167         CVec_OutPointZ_free(_res_constr);
19168 }
19169
19170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19171         if ((this_ptr & 1) != 0) return;
19172         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19173         CHECK_ACCESS(this_ptr_ptr);
19174         LDKPaymentPurpose this_ptr_conv = *(LDKPaymentPurpose*)(this_ptr_ptr);
19175         FREE((void*)this_ptr);
19176         PaymentPurpose_free(this_ptr_conv);
19177 }
19178
19179 static inline uint64_t PaymentPurpose_clone_ptr(LDKPaymentPurpose *NONNULL_PTR arg) {
19180         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19181         *ret_copy = PaymentPurpose_clone(arg);
19182 uint64_t ret_ref = (uint64_t)ret_copy;
19183         return ret_ref;
19184 }
19185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19186         LDKPaymentPurpose* arg_conv = (LDKPaymentPurpose*)arg;
19187         int64_t ret_val = PaymentPurpose_clone_ptr(arg_conv);
19188         return ret_val;
19189 }
19190
19191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19192         LDKPaymentPurpose* orig_conv = (LDKPaymentPurpose*)orig;
19193         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19194         *ret_copy = PaymentPurpose_clone(orig_conv);
19195         uint64_t ret_ref = (uint64_t)ret_copy;
19196         return ret_ref;
19197 }
19198
19199 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) {
19200         LDKThirtyTwoBytes payment_preimage_ref;
19201         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
19202         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
19203         LDKThirtyTwoBytes payment_secret_ref;
19204         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
19205         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
19206         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19207         *ret_copy = PaymentPurpose_invoice_payment(payment_preimage_ref, payment_secret_ref, user_payment_id);
19208         uint64_t ret_ref = (uint64_t)ret_copy;
19209         return ret_ref;
19210 }
19211
19212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentPurpose_1spontaneous_1payment(JNIEnv *env, jclass clz, int8_tArray a) {
19213         LDKThirtyTwoBytes a_ref;
19214         CHECK((*env)->GetArrayLength(env, a) == 32);
19215         (*env)->GetByteArrayRegion(env, a, 0, 32, a_ref.data);
19216         LDKPaymentPurpose *ret_copy = MALLOC(sizeof(LDKPaymentPurpose), "LDKPaymentPurpose");
19217         *ret_copy = PaymentPurpose_spontaneous_payment(a_ref);
19218         uint64_t ret_ref = (uint64_t)ret_copy;
19219         return ret_ref;
19220 }
19221
19222 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosureReason_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19223         if ((this_ptr & 1) != 0) return;
19224         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19225         CHECK_ACCESS(this_ptr_ptr);
19226         LDKClosureReason this_ptr_conv = *(LDKClosureReason*)(this_ptr_ptr);
19227         FREE((void*)this_ptr);
19228         ClosureReason_free(this_ptr_conv);
19229 }
19230
19231 static inline uint64_t ClosureReason_clone_ptr(LDKClosureReason *NONNULL_PTR arg) {
19232         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19233         *ret_copy = ClosureReason_clone(arg);
19234 uint64_t ret_ref = (uint64_t)ret_copy;
19235         return ret_ref;
19236 }
19237 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19238         LDKClosureReason* arg_conv = (LDKClosureReason*)arg;
19239         int64_t ret_val = ClosureReason_clone_ptr(arg_conv);
19240         return ret_val;
19241 }
19242
19243 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19244         LDKClosureReason* orig_conv = (LDKClosureReason*)orig;
19245         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19246         *ret_copy = ClosureReason_clone(orig_conv);
19247         uint64_t ret_ref = (uint64_t)ret_copy;
19248         return ret_ref;
19249 }
19250
19251 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1counterparty_1force_1closed(JNIEnv *env, jclass clz, jstring peer_msg) {
19252         LDKStr peer_msg_conv = java_to_owned_str(env, peer_msg);
19253         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19254         *ret_copy = ClosureReason_counterparty_force_closed(peer_msg_conv);
19255         uint64_t ret_ref = (uint64_t)ret_copy;
19256         return ret_ref;
19257 }
19258
19259 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1holder_1force_1closed(JNIEnv *env, jclass clz) {
19260         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19261         *ret_copy = ClosureReason_holder_force_closed();
19262         uint64_t ret_ref = (uint64_t)ret_copy;
19263         return ret_ref;
19264 }
19265
19266 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1cooperative_1closure(JNIEnv *env, jclass clz) {
19267         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19268         *ret_copy = ClosureReason_cooperative_closure();
19269         uint64_t ret_ref = (uint64_t)ret_copy;
19270         return ret_ref;
19271 }
19272
19273 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz) {
19274         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19275         *ret_copy = ClosureReason_commitment_tx_confirmed();
19276         uint64_t ret_ref = (uint64_t)ret_copy;
19277         return ret_ref;
19278 }
19279
19280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1processing_1error(JNIEnv *env, jclass clz, jstring err) {
19281         LDKStr err_conv = java_to_owned_str(env, err);
19282         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19283         *ret_copy = ClosureReason_processing_error(err_conv);
19284         uint64_t ret_ref = (uint64_t)ret_copy;
19285         return ret_ref;
19286 }
19287
19288 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1disconnected_1peer(JNIEnv *env, jclass clz) {
19289         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19290         *ret_copy = ClosureReason_disconnected_peer();
19291         uint64_t ret_ref = (uint64_t)ret_copy;
19292         return ret_ref;
19293 }
19294
19295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1outdated_1channel_1manager(JNIEnv *env, jclass clz) {
19296         LDKClosureReason *ret_copy = MALLOC(sizeof(LDKClosureReason), "LDKClosureReason");
19297         *ret_copy = ClosureReason_outdated_channel_manager();
19298         uint64_t ret_ref = (uint64_t)ret_copy;
19299         return ret_ref;
19300 }
19301
19302 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosureReason_1write(JNIEnv *env, jclass clz, int64_t obj) {
19303         LDKClosureReason* obj_conv = (LDKClosureReason*)obj;
19304         LDKCVec_u8Z ret_var = ClosureReason_write(obj_conv);
19305         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19306         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19307         CVec_u8Z_free(ret_var);
19308         return ret_arr;
19309 }
19310
19311 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosureReason_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19312         LDKu8slice ser_ref;
19313         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19314         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19315         LDKCResult_COption_ClosureReasonZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_ClosureReasonZDecodeErrorZ), "LDKCResult_COption_ClosureReasonZDecodeErrorZ");
19316         *ret_conv = ClosureReason_read(ser_ref);
19317         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19318         return (uint64_t)ret_conv;
19319 }
19320
19321 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Event_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19322         if ((this_ptr & 1) != 0) return;
19323         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19324         CHECK_ACCESS(this_ptr_ptr);
19325         LDKEvent this_ptr_conv = *(LDKEvent*)(this_ptr_ptr);
19326         FREE((void*)this_ptr);
19327         Event_free(this_ptr_conv);
19328 }
19329
19330 static inline uint64_t Event_clone_ptr(LDKEvent *NONNULL_PTR arg) {
19331         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19332         *ret_copy = Event_clone(arg);
19333 uint64_t ret_ref = (uint64_t)ret_copy;
19334         return ret_ref;
19335 }
19336 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19337         LDKEvent* arg_conv = (LDKEvent*)arg;
19338         int64_t ret_val = Event_clone_ptr(arg_conv);
19339         return ret_val;
19340 }
19341
19342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19343         LDKEvent* orig_conv = (LDKEvent*)orig;
19344         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19345         *ret_copy = Event_clone(orig_conv);
19346         uint64_t ret_ref = (uint64_t)ret_copy;
19347         return ret_ref;
19348 }
19349
19350 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) {
19351         LDKThirtyTwoBytes temporary_channel_id_ref;
19352         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
19353         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_ref.data);
19354         LDKCVec_u8Z output_script_ref;
19355         output_script_ref.datalen = (*env)->GetArrayLength(env, output_script);
19356         output_script_ref.data = MALLOC(output_script_ref.datalen, "LDKCVec_u8Z Bytes");
19357         (*env)->GetByteArrayRegion(env, output_script, 0, output_script_ref.datalen, output_script_ref.data);
19358         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19359         *ret_copy = Event_funding_generation_ready(temporary_channel_id_ref, channel_value_satoshis, output_script_ref, user_channel_id);
19360         uint64_t ret_ref = (uint64_t)ret_copy;
19361         return ret_ref;
19362 }
19363
19364 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) {
19365         LDKThirtyTwoBytes payment_hash_ref;
19366         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19367         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19368         void* purpose_ptr = (void*)(((uint64_t)purpose) & ~1);
19369         CHECK_ACCESS(purpose_ptr);
19370         LDKPaymentPurpose purpose_conv = *(LDKPaymentPurpose*)(purpose_ptr);
19371         purpose_conv = PaymentPurpose_clone((LDKPaymentPurpose*)(((uint64_t)purpose) & ~1));
19372         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19373         *ret_copy = Event_payment_received(payment_hash_ref, amt, purpose_conv);
19374         uint64_t ret_ref = (uint64_t)ret_copy;
19375         return ret_ref;
19376 }
19377
19378 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) {
19379         LDKThirtyTwoBytes payment_id_ref;
19380         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
19381         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
19382         LDKThirtyTwoBytes payment_preimage_ref;
19383         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
19384         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
19385         LDKThirtyTwoBytes payment_hash_ref;
19386         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19387         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19388         void* fee_paid_msat_ptr = (void*)(((uint64_t)fee_paid_msat) & ~1);
19389         CHECK_ACCESS(fee_paid_msat_ptr);
19390         LDKCOption_u64Z fee_paid_msat_conv = *(LDKCOption_u64Z*)(fee_paid_msat_ptr);
19391         fee_paid_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_paid_msat) & ~1));
19392         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19393         *ret_copy = Event_payment_sent(payment_id_ref, payment_preimage_ref, payment_hash_ref, fee_paid_msat_conv);
19394         uint64_t ret_ref = (uint64_t)ret_copy;
19395         return ret_ref;
19396 }
19397
19398 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) {
19399         LDKThirtyTwoBytes payment_id_ref;
19400         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
19401         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
19402         LDKThirtyTwoBytes payment_hash_ref;
19403         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
19404         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
19405         void* network_update_ptr = (void*)(((uint64_t)network_update) & ~1);
19406         CHECK_ACCESS(network_update_ptr);
19407         LDKCOption_NetworkUpdateZ network_update_conv = *(LDKCOption_NetworkUpdateZ*)(network_update_ptr);
19408         network_update_conv = COption_NetworkUpdateZ_clone((LDKCOption_NetworkUpdateZ*)(((uint64_t)network_update) & ~1));
19409         LDKCVec_RouteHopZ path_constr;
19410         path_constr.datalen = (*env)->GetArrayLength(env, path);
19411         if (path_constr.datalen > 0)
19412                 path_constr.data = MALLOC(path_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
19413         else
19414                 path_constr.data = NULL;
19415         int64_t* path_vals = (*env)->GetLongArrayElements (env, path, NULL);
19416         for (size_t k = 0; k < path_constr.datalen; k++) {
19417                 int64_t path_conv_10 = path_vals[k];
19418                 LDKRouteHop path_conv_10_conv;
19419                 path_conv_10_conv.inner = (void*)(path_conv_10 & (~1));
19420                 path_conv_10_conv.is_owned = (path_conv_10 & 1) || (path_conv_10 == 0);
19421                 CHECK_INNER_FIELD_ACCESS_OR_NULL(path_conv_10_conv);
19422                 path_conv_10_conv = RouteHop_clone(&path_conv_10_conv);
19423                 path_constr.data[k] = path_conv_10_conv;
19424         }
19425         (*env)->ReleaseLongArrayElements(env, path, path_vals, 0);
19426         void* short_channel_id_ptr = (void*)(((uint64_t)short_channel_id) & ~1);
19427         CHECK_ACCESS(short_channel_id_ptr);
19428         LDKCOption_u64Z short_channel_id_conv = *(LDKCOption_u64Z*)(short_channel_id_ptr);
19429         short_channel_id_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id) & ~1));
19430         LDKRouteParameters retry_conv;
19431         retry_conv.inner = (void*)(retry & (~1));
19432         retry_conv.is_owned = (retry & 1) || (retry == 0);
19433         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_conv);
19434         retry_conv = RouteParameters_clone(&retry_conv);
19435         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19436         *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);
19437         uint64_t ret_ref = (uint64_t)ret_copy;
19438         return ret_ref;
19439 }
19440
19441 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1pending_1htlcs_1forwardable(JNIEnv *env, jclass clz, int64_t time_forwardable) {
19442         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19443         *ret_copy = Event_pending_htlcs_forwardable(time_forwardable);
19444         uint64_t ret_ref = (uint64_t)ret_copy;
19445         return ret_ref;
19446 }
19447
19448 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1spendable_1outputs(JNIEnv *env, jclass clz, int64_tArray outputs) {
19449         LDKCVec_SpendableOutputDescriptorZ outputs_constr;
19450         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
19451         if (outputs_constr.datalen > 0)
19452                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
19453         else
19454                 outputs_constr.data = NULL;
19455         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
19456         for (size_t b = 0; b < outputs_constr.datalen; b++) {
19457                 int64_t outputs_conv_27 = outputs_vals[b];
19458                 void* outputs_conv_27_ptr = (void*)(((uint64_t)outputs_conv_27) & ~1);
19459                 CHECK_ACCESS(outputs_conv_27_ptr);
19460                 LDKSpendableOutputDescriptor outputs_conv_27_conv = *(LDKSpendableOutputDescriptor*)(outputs_conv_27_ptr);
19461                 outputs_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)outputs_conv_27) & ~1));
19462                 outputs_constr.data[b] = outputs_conv_27_conv;
19463         }
19464         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
19465         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19466         *ret_copy = Event_spendable_outputs(outputs_constr);
19467         uint64_t ret_ref = (uint64_t)ret_copy;
19468         return ret_ref;
19469 }
19470
19471 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) {
19472         void* fee_earned_msat_ptr = (void*)(((uint64_t)fee_earned_msat) & ~1);
19473         CHECK_ACCESS(fee_earned_msat_ptr);
19474         LDKCOption_u64Z fee_earned_msat_conv = *(LDKCOption_u64Z*)(fee_earned_msat_ptr);
19475         fee_earned_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)fee_earned_msat) & ~1));
19476         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19477         *ret_copy = Event_payment_forwarded(fee_earned_msat_conv, claim_from_onchain_tx);
19478         uint64_t ret_ref = (uint64_t)ret_copy;
19479         return ret_ref;
19480 }
19481
19482 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) {
19483         LDKThirtyTwoBytes channel_id_ref;
19484         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
19485         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
19486         void* reason_ptr = (void*)(((uint64_t)reason) & ~1);
19487         CHECK_ACCESS(reason_ptr);
19488         LDKClosureReason reason_conv = *(LDKClosureReason*)(reason_ptr);
19489         reason_conv = ClosureReason_clone((LDKClosureReason*)(((uint64_t)reason) & ~1));
19490         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19491         *ret_copy = Event_channel_closed(channel_id_ref, user_channel_id, reason_conv);
19492         uint64_t ret_ref = (uint64_t)ret_copy;
19493         return ret_ref;
19494 }
19495
19496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1discard_1funding(JNIEnv *env, jclass clz, int8_tArray channel_id, int8_tArray transaction) {
19497         LDKThirtyTwoBytes channel_id_ref;
19498         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
19499         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_ref.data);
19500         LDKTransaction transaction_ref;
19501         transaction_ref.datalen = (*env)->GetArrayLength(env, transaction);
19502         transaction_ref.data = MALLOC(transaction_ref.datalen, "LDKTransaction Bytes");
19503         (*env)->GetByteArrayRegion(env, transaction, 0, transaction_ref.datalen, transaction_ref.data);
19504         transaction_ref.data_is_owned = true;
19505         LDKEvent *ret_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
19506         *ret_copy = Event_discard_funding(channel_id_ref, transaction_ref);
19507         uint64_t ret_ref = (uint64_t)ret_copy;
19508         return ret_ref;
19509 }
19510
19511 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Event_1write(JNIEnv *env, jclass clz, int64_t obj) {
19512         LDKEvent* obj_conv = (LDKEvent*)obj;
19513         LDKCVec_u8Z ret_var = Event_write(obj_conv);
19514         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
19515         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
19516         CVec_u8Z_free(ret_var);
19517         return ret_arr;
19518 }
19519
19520 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Event_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
19521         LDKu8slice ser_ref;
19522         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
19523         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
19524         LDKCResult_COption_EventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_EventZDecodeErrorZ), "LDKCResult_COption_EventZDecodeErrorZ");
19525         *ret_conv = Event_read(ser_ref);
19526         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
19527         return (uint64_t)ret_conv;
19528 }
19529
19530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19531         if ((this_ptr & 1) != 0) return;
19532         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19533         CHECK_ACCESS(this_ptr_ptr);
19534         LDKMessageSendEvent this_ptr_conv = *(LDKMessageSendEvent*)(this_ptr_ptr);
19535         FREE((void*)this_ptr);
19536         MessageSendEvent_free(this_ptr_conv);
19537 }
19538
19539 static inline uint64_t MessageSendEvent_clone_ptr(LDKMessageSendEvent *NONNULL_PTR arg) {
19540         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19541         *ret_copy = MessageSendEvent_clone(arg);
19542 uint64_t ret_ref = (uint64_t)ret_copy;
19543         return ret_ref;
19544 }
19545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19546         LDKMessageSendEvent* arg_conv = (LDKMessageSendEvent*)arg;
19547         int64_t ret_val = MessageSendEvent_clone_ptr(arg_conv);
19548         return ret_val;
19549 }
19550
19551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19552         LDKMessageSendEvent* orig_conv = (LDKMessageSendEvent*)orig;
19553         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19554         *ret_copy = MessageSendEvent_clone(orig_conv);
19555         uint64_t ret_ref = (uint64_t)ret_copy;
19556         return ret_ref;
19557 }
19558
19559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1accept_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19560         LDKPublicKey node_id_ref;
19561         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19562         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19563         LDKAcceptChannel msg_conv;
19564         msg_conv.inner = (void*)(msg & (~1));
19565         msg_conv.is_owned = (msg & 1) || (msg == 0);
19566         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19567         msg_conv = AcceptChannel_clone(&msg_conv);
19568         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19569         *ret_copy = MessageSendEvent_send_accept_channel(node_id_ref, msg_conv);
19570         uint64_t ret_ref = (uint64_t)ret_copy;
19571         return ret_ref;
19572 }
19573
19574 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1open_1channel(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19575         LDKPublicKey node_id_ref;
19576         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19577         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19578         LDKOpenChannel msg_conv;
19579         msg_conv.inner = (void*)(msg & (~1));
19580         msg_conv.is_owned = (msg & 1) || (msg == 0);
19581         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19582         msg_conv = OpenChannel_clone(&msg_conv);
19583         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19584         *ret_copy = MessageSendEvent_send_open_channel(node_id_ref, msg_conv);
19585         uint64_t ret_ref = (uint64_t)ret_copy;
19586         return ret_ref;
19587 }
19588
19589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1created(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19590         LDKPublicKey node_id_ref;
19591         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19592         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19593         LDKFundingCreated msg_conv;
19594         msg_conv.inner = (void*)(msg & (~1));
19595         msg_conv.is_owned = (msg & 1) || (msg == 0);
19596         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19597         msg_conv = FundingCreated_clone(&msg_conv);
19598         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19599         *ret_copy = MessageSendEvent_send_funding_created(node_id_ref, msg_conv);
19600         uint64_t ret_ref = (uint64_t)ret_copy;
19601         return ret_ref;
19602 }
19603
19604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19605         LDKPublicKey node_id_ref;
19606         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19607         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19608         LDKFundingSigned msg_conv;
19609         msg_conv.inner = (void*)(msg & (~1));
19610         msg_conv.is_owned = (msg & 1) || (msg == 0);
19611         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19612         msg_conv = FundingSigned_clone(&msg_conv);
19613         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19614         *ret_copy = MessageSendEvent_send_funding_signed(node_id_ref, msg_conv);
19615         uint64_t ret_ref = (uint64_t)ret_copy;
19616         return ret_ref;
19617 }
19618
19619 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1funding_1locked(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19620         LDKPublicKey node_id_ref;
19621         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19622         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19623         LDKFundingLocked msg_conv;
19624         msg_conv.inner = (void*)(msg & (~1));
19625         msg_conv.is_owned = (msg & 1) || (msg == 0);
19626         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19627         msg_conv = FundingLocked_clone(&msg_conv);
19628         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19629         *ret_copy = MessageSendEvent_send_funding_locked(node_id_ref, msg_conv);
19630         uint64_t ret_ref = (uint64_t)ret_copy;
19631         return ret_ref;
19632 }
19633
19634 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1announcement_1signatures(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19635         LDKPublicKey node_id_ref;
19636         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19637         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19638         LDKAnnouncementSignatures msg_conv;
19639         msg_conv.inner = (void*)(msg & (~1));
19640         msg_conv.is_owned = (msg & 1) || (msg == 0);
19641         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19642         msg_conv = AnnouncementSignatures_clone(&msg_conv);
19643         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19644         *ret_copy = MessageSendEvent_send_announcement_signatures(node_id_ref, msg_conv);
19645         uint64_t ret_ref = (uint64_t)ret_copy;
19646         return ret_ref;
19647 }
19648
19649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1update_1htlcs(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t updates) {
19650         LDKPublicKey node_id_ref;
19651         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19652         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19653         LDKCommitmentUpdate updates_conv;
19654         updates_conv.inner = (void*)(updates & (~1));
19655         updates_conv.is_owned = (updates & 1) || (updates == 0);
19656         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
19657         updates_conv = CommitmentUpdate_clone(&updates_conv);
19658         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19659         *ret_copy = MessageSendEvent_update_htlcs(node_id_ref, updates_conv);
19660         uint64_t ret_ref = (uint64_t)ret_copy;
19661         return ret_ref;
19662 }
19663
19664 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) {
19665         LDKPublicKey node_id_ref;
19666         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19667         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19668         LDKRevokeAndACK msg_conv;
19669         msg_conv.inner = (void*)(msg & (~1));
19670         msg_conv.is_owned = (msg & 1) || (msg == 0);
19671         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19672         msg_conv = RevokeAndACK_clone(&msg_conv);
19673         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19674         *ret_copy = MessageSendEvent_send_revoke_and_ack(node_id_ref, msg_conv);
19675         uint64_t ret_ref = (uint64_t)ret_copy;
19676         return ret_ref;
19677 }
19678
19679 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1closing_1signed(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19680         LDKPublicKey node_id_ref;
19681         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19682         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19683         LDKClosingSigned msg_conv;
19684         msg_conv.inner = (void*)(msg & (~1));
19685         msg_conv.is_owned = (msg & 1) || (msg == 0);
19686         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19687         msg_conv = ClosingSigned_clone(&msg_conv);
19688         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19689         *ret_copy = MessageSendEvent_send_closing_signed(node_id_ref, msg_conv);
19690         uint64_t ret_ref = (uint64_t)ret_copy;
19691         return ret_ref;
19692 }
19693
19694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1shutdown(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19695         LDKPublicKey node_id_ref;
19696         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19697         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19698         LDKShutdown msg_conv;
19699         msg_conv.inner = (void*)(msg & (~1));
19700         msg_conv.is_owned = (msg & 1) || (msg == 0);
19701         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19702         msg_conv = Shutdown_clone(&msg_conv);
19703         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19704         *ret_copy = MessageSendEvent_send_shutdown(node_id_ref, msg_conv);
19705         uint64_t ret_ref = (uint64_t)ret_copy;
19706         return ret_ref;
19707 }
19708
19709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1reestablish(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19710         LDKPublicKey node_id_ref;
19711         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19712         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19713         LDKChannelReestablish msg_conv;
19714         msg_conv.inner = (void*)(msg & (~1));
19715         msg_conv.is_owned = (msg & 1) || (msg == 0);
19716         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19717         msg_conv = ChannelReestablish_clone(&msg_conv);
19718         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19719         *ret_copy = MessageSendEvent_send_channel_reestablish(node_id_ref, msg_conv);
19720         uint64_t ret_ref = (uint64_t)ret_copy;
19721         return ret_ref;
19722 }
19723
19724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1announcement(JNIEnv *env, jclass clz, int64_t msg, int64_t update_msg) {
19725         LDKChannelAnnouncement msg_conv;
19726         msg_conv.inner = (void*)(msg & (~1));
19727         msg_conv.is_owned = (msg & 1) || (msg == 0);
19728         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19729         msg_conv = ChannelAnnouncement_clone(&msg_conv);
19730         LDKChannelUpdate update_msg_conv;
19731         update_msg_conv.inner = (void*)(update_msg & (~1));
19732         update_msg_conv.is_owned = (update_msg & 1) || (update_msg == 0);
19733         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_msg_conv);
19734         update_msg_conv = ChannelUpdate_clone(&update_msg_conv);
19735         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19736         *ret_copy = MessageSendEvent_broadcast_channel_announcement(msg_conv, update_msg_conv);
19737         uint64_t ret_ref = (uint64_t)ret_copy;
19738         return ret_ref;
19739 }
19740
19741 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1node_1announcement(JNIEnv *env, jclass clz, int64_t msg) {
19742         LDKNodeAnnouncement msg_conv;
19743         msg_conv.inner = (void*)(msg & (~1));
19744         msg_conv.is_owned = (msg & 1) || (msg == 0);
19745         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19746         msg_conv = NodeAnnouncement_clone(&msg_conv);
19747         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19748         *ret_copy = MessageSendEvent_broadcast_node_announcement(msg_conv);
19749         uint64_t ret_ref = (uint64_t)ret_copy;
19750         return ret_ref;
19751 }
19752
19753 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1broadcast_1channel_1update(JNIEnv *env, jclass clz, int64_t msg) {
19754         LDKChannelUpdate msg_conv;
19755         msg_conv.inner = (void*)(msg & (~1));
19756         msg_conv.is_owned = (msg & 1) || (msg == 0);
19757         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19758         msg_conv = ChannelUpdate_clone(&msg_conv);
19759         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19760         *ret_copy = MessageSendEvent_broadcast_channel_update(msg_conv);
19761         uint64_t ret_ref = (uint64_t)ret_copy;
19762         return ret_ref;
19763 }
19764
19765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1send_1channel_1update(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t msg) {
19766         LDKPublicKey node_id_ref;
19767         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19768         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19769         LDKChannelUpdate msg_conv;
19770         msg_conv.inner = (void*)(msg & (~1));
19771         msg_conv.is_owned = (msg & 1) || (msg == 0);
19772         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19773         msg_conv = ChannelUpdate_clone(&msg_conv);
19774         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19775         *ret_copy = MessageSendEvent_send_channel_update(node_id_ref, msg_conv);
19776         uint64_t ret_ref = (uint64_t)ret_copy;
19777         return ret_ref;
19778 }
19779
19780 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageSendEvent_1handle_1error(JNIEnv *env, jclass clz, int8_tArray node_id, int64_t action) {
19781         LDKPublicKey node_id_ref;
19782         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19783         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19784         void* action_ptr = (void*)(((uint64_t)action) & ~1);
19785         CHECK_ACCESS(action_ptr);
19786         LDKErrorAction action_conv = *(LDKErrorAction*)(action_ptr);
19787         action_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action) & ~1));
19788         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19789         *ret_copy = MessageSendEvent_handle_error(node_id_ref, action_conv);
19790         uint64_t ret_ref = (uint64_t)ret_copy;
19791         return ret_ref;
19792 }
19793
19794 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) {
19795         LDKPublicKey node_id_ref;
19796         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19797         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19798         LDKQueryChannelRange msg_conv;
19799         msg_conv.inner = (void*)(msg & (~1));
19800         msg_conv.is_owned = (msg & 1) || (msg == 0);
19801         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19802         msg_conv = QueryChannelRange_clone(&msg_conv);
19803         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19804         *ret_copy = MessageSendEvent_send_channel_range_query(node_id_ref, msg_conv);
19805         uint64_t ret_ref = (uint64_t)ret_copy;
19806         return ret_ref;
19807 }
19808
19809 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) {
19810         LDKPublicKey node_id_ref;
19811         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19812         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19813         LDKQueryShortChannelIds msg_conv;
19814         msg_conv.inner = (void*)(msg & (~1));
19815         msg_conv.is_owned = (msg & 1) || (msg == 0);
19816         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19817         msg_conv = QueryShortChannelIds_clone(&msg_conv);
19818         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19819         *ret_copy = MessageSendEvent_send_short_ids_query(node_id_ref, msg_conv);
19820         uint64_t ret_ref = (uint64_t)ret_copy;
19821         return ret_ref;
19822 }
19823
19824 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) {
19825         LDKPublicKey node_id_ref;
19826         CHECK((*env)->GetArrayLength(env, node_id) == 33);
19827         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
19828         LDKReplyChannelRange msg_conv;
19829         msg_conv.inner = (void*)(msg & (~1));
19830         msg_conv.is_owned = (msg & 1) || (msg == 0);
19831         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
19832         msg_conv = ReplyChannelRange_clone(&msg_conv);
19833         LDKMessageSendEvent *ret_copy = MALLOC(sizeof(LDKMessageSendEvent), "LDKMessageSendEvent");
19834         *ret_copy = MessageSendEvent_send_reply_channel_range(node_id_ref, msg_conv);
19835         uint64_t ret_ref = (uint64_t)ret_copy;
19836         return ret_ref;
19837 }
19838
19839 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageSendEventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19840         if ((this_ptr & 1) != 0) return;
19841         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19842         CHECK_ACCESS(this_ptr_ptr);
19843         LDKMessageSendEventsProvider this_ptr_conv = *(LDKMessageSendEventsProvider*)(this_ptr_ptr);
19844         FREE((void*)this_ptr);
19845         MessageSendEventsProvider_free(this_ptr_conv);
19846 }
19847
19848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventsProvider_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19849         if ((this_ptr & 1) != 0) return;
19850         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19851         CHECK_ACCESS(this_ptr_ptr);
19852         LDKEventsProvider this_ptr_conv = *(LDKEventsProvider*)(this_ptr_ptr);
19853         FREE((void*)this_ptr);
19854         EventsProvider_free(this_ptr_conv);
19855 }
19856
19857 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_EventHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19858         if ((this_ptr & 1) != 0) return;
19859         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19860         CHECK_ACCESS(this_ptr_ptr);
19861         LDKEventHandler this_ptr_conv = *(LDKEventHandler*)(this_ptr_ptr);
19862         FREE((void*)this_ptr);
19863         EventHandler_free(this_ptr_conv);
19864 }
19865
19866 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_APIError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
19867         if ((this_ptr & 1) != 0) return;
19868         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
19869         CHECK_ACCESS(this_ptr_ptr);
19870         LDKAPIError this_ptr_conv = *(LDKAPIError*)(this_ptr_ptr);
19871         FREE((void*)this_ptr);
19872         APIError_free(this_ptr_conv);
19873 }
19874
19875 static inline uint64_t APIError_clone_ptr(LDKAPIError *NONNULL_PTR arg) {
19876         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19877         *ret_copy = APIError_clone(arg);
19878 uint64_t ret_ref = (uint64_t)ret_copy;
19879         return ret_ref;
19880 }
19881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
19882         LDKAPIError* arg_conv = (LDKAPIError*)arg;
19883         int64_t ret_val = APIError_clone_ptr(arg_conv);
19884         return ret_val;
19885 }
19886
19887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19888         LDKAPIError* orig_conv = (LDKAPIError*)orig;
19889         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19890         *ret_copy = APIError_clone(orig_conv);
19891         uint64_t ret_ref = (uint64_t)ret_copy;
19892         return ret_ref;
19893 }
19894
19895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1apimisuse_1error(JNIEnv *env, jclass clz, jstring err) {
19896         LDKStr err_conv = java_to_owned_str(env, err);
19897         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19898         *ret_copy = APIError_apimisuse_error(err_conv);
19899         uint64_t ret_ref = (uint64_t)ret_copy;
19900         return ret_ref;
19901 }
19902
19903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1fee_1rate_1too_1high(JNIEnv *env, jclass clz, jstring err, int32_t feerate) {
19904         LDKStr err_conv = java_to_owned_str(env, err);
19905         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19906         *ret_copy = APIError_fee_rate_too_high(err_conv, feerate);
19907         uint64_t ret_ref = (uint64_t)ret_copy;
19908         return ret_ref;
19909 }
19910
19911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1route_1error(JNIEnv *env, jclass clz, jstring err) {
19912         LDKStr err_conv = java_to_owned_str(env, err);
19913         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19914         *ret_copy = APIError_route_error(err_conv);
19915         uint64_t ret_ref = (uint64_t)ret_copy;
19916         return ret_ref;
19917 }
19918
19919 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1channel_1unavailable(JNIEnv *env, jclass clz, jstring err) {
19920         LDKStr err_conv = java_to_owned_str(env, err);
19921         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19922         *ret_copy = APIError_channel_unavailable(err_conv);
19923         uint64_t ret_ref = (uint64_t)ret_copy;
19924         return ret_ref;
19925 }
19926
19927 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1monitor_1update_1failed(JNIEnv *env, jclass clz) {
19928         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19929         *ret_copy = APIError_monitor_update_failed();
19930         uint64_t ret_ref = (uint64_t)ret_copy;
19931         return ret_ref;
19932 }
19933
19934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_APIError_1incompatible_1shutdown_1script(JNIEnv *env, jclass clz, int64_t script) {
19935         LDKShutdownScript script_conv;
19936         script_conv.inner = (void*)(script & (~1));
19937         script_conv.is_owned = (script & 1) || (script == 0);
19938         CHECK_INNER_FIELD_ACCESS_OR_NULL(script_conv);
19939         script_conv = ShutdownScript_clone(&script_conv);
19940         LDKAPIError *ret_copy = MALLOC(sizeof(LDKAPIError), "LDKAPIError");
19941         *ret_copy = APIError_incompatible_shutdown_script(script_conv);
19942         uint64_t ret_ref = (uint64_t)ret_copy;
19943         return ret_ref;
19944 }
19945
19946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_sign(JNIEnv *env, jclass clz, int8_tArray msg, int8_tArray sk) {
19947         LDKu8slice msg_ref;
19948         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
19949         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
19950         unsigned char sk_arr[32];
19951         CHECK((*env)->GetArrayLength(env, sk) == 32);
19952         (*env)->GetByteArrayRegion(env, sk, 0, 32, sk_arr);
19953         unsigned char (*sk_ref)[32] = &sk_arr;
19954         LDKCResult_StringErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StringErrorZ), "LDKCResult_StringErrorZ");
19955         *ret_conv = sign(msg_ref, sk_ref);
19956         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
19957         return (uint64_t)ret_conv;
19958 }
19959
19960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_recover_1pk(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig) {
19961         LDKu8slice msg_ref;
19962         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
19963         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
19964         LDKStr sig_conv = java_to_owned_str(env, sig);
19965         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
19966         *ret_conv = recover_pk(msg_ref, sig_conv);
19967         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
19968         return (uint64_t)ret_conv;
19969 }
19970
19971 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_verify(JNIEnv *env, jclass clz, int8_tArray msg, jstring sig, int8_tArray pk) {
19972         LDKu8slice msg_ref;
19973         msg_ref.datalen = (*env)->GetArrayLength(env, msg);
19974         msg_ref.data = (*env)->GetByteArrayElements (env, msg, NULL);
19975         LDKStr sig_conv = java_to_owned_str(env, sig);
19976         LDKPublicKey pk_ref;
19977         CHECK((*env)->GetArrayLength(env, pk) == 33);
19978         (*env)->GetByteArrayRegion(env, pk, 0, 33, pk_ref.compressed_form);
19979         jboolean ret_val = verify(msg_ref, sig_conv, pk_ref);
19980         (*env)->ReleaseByteArrayElements(env, msg, (int8_t*)msg_ref.data, 0);
19981         return ret_val;
19982 }
19983
19984 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1clone(JNIEnv *env, jclass clz, int64_t orig) {
19985         LDKLevel* orig_conv = (LDKLevel*)(orig & ~1);
19986         jclass ret_conv = LDKLevel_to_java(env, Level_clone(orig_conv));
19987         return ret_conv;
19988 }
19989
19990 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1trace(JNIEnv *env, jclass clz) {
19991         jclass ret_conv = LDKLevel_to_java(env, Level_trace());
19992         return ret_conv;
19993 }
19994
19995 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1debug(JNIEnv *env, jclass clz) {
19996         jclass ret_conv = LDKLevel_to_java(env, Level_debug());
19997         return ret_conv;
19998 }
19999
20000 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1info(JNIEnv *env, jclass clz) {
20001         jclass ret_conv = LDKLevel_to_java(env, Level_info());
20002         return ret_conv;
20003 }
20004
20005 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1warn(JNIEnv *env, jclass clz) {
20006         jclass ret_conv = LDKLevel_to_java(env, Level_warn());
20007         return ret_conv;
20008 }
20009
20010 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1error(JNIEnv *env, jclass clz) {
20011         jclass ret_conv = LDKLevel_to_java(env, Level_error());
20012         return ret_conv;
20013 }
20014
20015 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Level_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
20016         LDKLevel* a_conv = (LDKLevel*)(a & ~1);
20017         LDKLevel* b_conv = (LDKLevel*)(b & ~1);
20018         jboolean ret_val = Level_eq(a_conv, b_conv);
20019         return ret_val;
20020 }
20021
20022 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Level_1hash(JNIEnv *env, jclass clz, int64_t o) {
20023         LDKLevel* o_conv = (LDKLevel*)(o & ~1);
20024         int64_t ret_val = Level_hash(o_conv);
20025         return ret_val;
20026 }
20027
20028 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Level_1max(JNIEnv *env, jclass clz) {
20029         jclass ret_conv = LDKLevel_to_java(env, Level_max());
20030         return ret_conv;
20031 }
20032
20033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20034         LDKRecord this_obj_conv;
20035         this_obj_conv.inner = (void*)(this_obj & (~1));
20036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20038         Record_free(this_obj_conv);
20039 }
20040
20041 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Record_1get_1level(JNIEnv *env, jclass clz, int64_t this_ptr) {
20042         LDKRecord this_ptr_conv;
20043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20044         this_ptr_conv.is_owned = false;
20045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20046         jclass ret_conv = LDKLevel_to_java(env, Record_get_level(&this_ptr_conv));
20047         return ret_conv;
20048 }
20049
20050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1level(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
20051         LDKRecord this_ptr_conv;
20052         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20053         this_ptr_conv.is_owned = false;
20054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20055         LDKLevel val_conv = LDKLevel_from_java(env, val);
20056         Record_set_level(&this_ptr_conv, val_conv);
20057 }
20058
20059 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1args(JNIEnv *env, jclass clz, int64_t this_ptr) {
20060         LDKRecord this_ptr_conv;
20061         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20062         this_ptr_conv.is_owned = false;
20063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20064         LDKStr ret_str = Record_get_args(&this_ptr_conv);
20065         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20066         Str_free(ret_str);
20067         return ret_conv;
20068 }
20069
20070 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1args(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20071         LDKRecord this_ptr_conv;
20072         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20073         this_ptr_conv.is_owned = false;
20074         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20075         LDKStr val_conv = java_to_owned_str(env, val);
20076         Record_set_args(&this_ptr_conv, val_conv);
20077 }
20078
20079 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr) {
20080         LDKRecord this_ptr_conv;
20081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20082         this_ptr_conv.is_owned = false;
20083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20084         LDKStr ret_str = Record_get_module_path(&this_ptr_conv);
20085         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20086         Str_free(ret_str);
20087         return ret_conv;
20088 }
20089
20090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1module_1path(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20091         LDKRecord this_ptr_conv;
20092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20093         this_ptr_conv.is_owned = false;
20094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20095         LDKStr val_conv = java_to_owned_str(env, val);
20096         Record_set_module_path(&this_ptr_conv, val_conv);
20097 }
20098
20099 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Record_1get_1file(JNIEnv *env, jclass clz, int64_t this_ptr) {
20100         LDKRecord this_ptr_conv;
20101         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20102         this_ptr_conv.is_owned = false;
20103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20104         LDKStr ret_str = Record_get_file(&this_ptr_conv);
20105         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
20106         Str_free(ret_str);
20107         return ret_conv;
20108 }
20109
20110 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1file(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
20111         LDKRecord this_ptr_conv;
20112         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20113         this_ptr_conv.is_owned = false;
20114         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20115         LDKStr val_conv = java_to_owned_str(env, val);
20116         Record_set_file(&this_ptr_conv, val_conv);
20117 }
20118
20119 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_Record_1get_1line(JNIEnv *env, jclass clz, int64_t this_ptr) {
20120         LDKRecord this_ptr_conv;
20121         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20122         this_ptr_conv.is_owned = false;
20123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20124         int32_t ret_val = Record_get_line(&this_ptr_conv);
20125         return ret_val;
20126 }
20127
20128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Record_1set_1line(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20129         LDKRecord this_ptr_conv;
20130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20131         this_ptr_conv.is_owned = false;
20132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20133         Record_set_line(&this_ptr_conv, val);
20134 }
20135
20136 static inline uint64_t Record_clone_ptr(LDKRecord *NONNULL_PTR arg) {
20137         LDKRecord ret_var = Record_clone(arg);
20138 uint64_t ret_ref = 0;
20139 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20140 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20141 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20142 ret_ref = (uint64_t)ret_var.inner;
20143 if (ret_var.is_owned) {
20144         ret_ref |= 1;
20145 }
20146         return ret_ref;
20147 }
20148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20149         LDKRecord arg_conv;
20150         arg_conv.inner = (void*)(arg & (~1));
20151         arg_conv.is_owned = false;
20152         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20153         int64_t ret_val = Record_clone_ptr(&arg_conv);
20154         return ret_val;
20155 }
20156
20157 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Record_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20158         LDKRecord orig_conv;
20159         orig_conv.inner = (void*)(orig & (~1));
20160         orig_conv.is_owned = false;
20161         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20162         LDKRecord ret_var = Record_clone(&orig_conv);
20163         uint64_t ret_ref = 0;
20164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20167         ret_ref = (uint64_t)ret_var.inner;
20168         if (ret_var.is_owned) {
20169                 ret_ref |= 1;
20170         }
20171         return ret_ref;
20172 }
20173
20174 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Logger_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
20175         if ((this_ptr & 1) != 0) return;
20176         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
20177         CHECK_ACCESS(this_ptr_ptr);
20178         LDKLogger this_ptr_conv = *(LDKLogger*)(this_ptr_ptr);
20179         FREE((void*)this_ptr);
20180         Logger_free(this_ptr_conv);
20181 }
20182
20183 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20184         LDKChannelHandshakeConfig this_obj_conv;
20185         this_obj_conv.inner = (void*)(this_obj & (~1));
20186         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20187         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20188         ChannelHandshakeConfig_free(this_obj_conv);
20189 }
20190
20191 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
20192         LDKChannelHandshakeConfig this_ptr_conv;
20193         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20194         this_ptr_conv.is_owned = false;
20195         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20196         int32_t ret_val = ChannelHandshakeConfig_get_minimum_depth(&this_ptr_conv);
20197         return ret_val;
20198 }
20199
20200 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20201         LDKChannelHandshakeConfig this_ptr_conv;
20202         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20203         this_ptr_conv.is_owned = false;
20204         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20205         ChannelHandshakeConfig_set_minimum_depth(&this_ptr_conv, val);
20206 }
20207
20208 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
20209         LDKChannelHandshakeConfig this_ptr_conv;
20210         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20211         this_ptr_conv.is_owned = false;
20212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20213         int16_t ret_val = ChannelHandshakeConfig_get_our_to_self_delay(&this_ptr_conv);
20214         return ret_val;
20215 }
20216
20217 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) {
20218         LDKChannelHandshakeConfig this_ptr_conv;
20219         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20220         this_ptr_conv.is_owned = false;
20221         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20222         ChannelHandshakeConfig_set_our_to_self_delay(&this_ptr_conv, val);
20223 }
20224
20225 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1get_1our_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20226         LDKChannelHandshakeConfig this_ptr_conv;
20227         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20228         this_ptr_conv.is_owned = false;
20229         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20230         int64_t ret_val = ChannelHandshakeConfig_get_our_htlc_minimum_msat(&this_ptr_conv);
20231         return ret_val;
20232 }
20233
20234 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) {
20235         LDKChannelHandshakeConfig this_ptr_conv;
20236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20237         this_ptr_conv.is_owned = false;
20238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20239         ChannelHandshakeConfig_set_our_htlc_minimum_msat(&this_ptr_conv, val);
20240 }
20241
20242 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) {
20243         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_new(minimum_depth_arg, our_to_self_delay_arg, our_htlc_minimum_msat_arg);
20244         uint64_t ret_ref = 0;
20245         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20246         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20247         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20248         ret_ref = (uint64_t)ret_var.inner;
20249         if (ret_var.is_owned) {
20250                 ret_ref |= 1;
20251         }
20252         return ret_ref;
20253 }
20254
20255 static inline uint64_t ChannelHandshakeConfig_clone_ptr(LDKChannelHandshakeConfig *NONNULL_PTR arg) {
20256         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(arg);
20257 uint64_t ret_ref = 0;
20258 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20259 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20260 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20261 ret_ref = (uint64_t)ret_var.inner;
20262 if (ret_var.is_owned) {
20263         ret_ref |= 1;
20264 }
20265         return ret_ref;
20266 }
20267 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20268         LDKChannelHandshakeConfig arg_conv;
20269         arg_conv.inner = (void*)(arg & (~1));
20270         arg_conv.is_owned = false;
20271         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20272         int64_t ret_val = ChannelHandshakeConfig_clone_ptr(&arg_conv);
20273         return ret_val;
20274 }
20275
20276 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20277         LDKChannelHandshakeConfig orig_conv;
20278         orig_conv.inner = (void*)(orig & (~1));
20279         orig_conv.is_owned = false;
20280         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20281         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_clone(&orig_conv);
20282         uint64_t ret_ref = 0;
20283         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20284         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20285         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20286         ret_ref = (uint64_t)ret_var.inner;
20287         if (ret_var.is_owned) {
20288                 ret_ref |= 1;
20289         }
20290         return ret_ref;
20291 }
20292
20293 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeConfig_1default(JNIEnv *env, jclass clz) {
20294         LDKChannelHandshakeConfig ret_var = ChannelHandshakeConfig_default();
20295         uint64_t ret_ref = 0;
20296         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20297         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20298         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20299         ret_ref = (uint64_t)ret_var.inner;
20300         if (ret_var.is_owned) {
20301                 ret_ref |= 1;
20302         }
20303         return ret_ref;
20304 }
20305
20306 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20307         LDKChannelHandshakeLimits this_obj_conv;
20308         this_obj_conv.inner = (void*)(this_obj & (~1));
20309         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20310         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20311         ChannelHandshakeLimits_free(this_obj_conv);
20312 }
20313
20314 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20315         LDKChannelHandshakeLimits this_ptr_conv;
20316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20317         this_ptr_conv.is_owned = false;
20318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20319         int64_t ret_val = ChannelHandshakeLimits_get_min_funding_satoshis(&this_ptr_conv);
20320         return ret_val;
20321 }
20322
20323 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1min_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20324         LDKChannelHandshakeLimits this_ptr_conv;
20325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20326         this_ptr_conv.is_owned = false;
20327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20328         ChannelHandshakeLimits_set_min_funding_satoshis(&this_ptr_conv, val);
20329 }
20330
20331 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20332         LDKChannelHandshakeLimits this_ptr_conv;
20333         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20334         this_ptr_conv.is_owned = false;
20335         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20336         int64_t ret_val = ChannelHandshakeLimits_get_max_htlc_minimum_msat(&this_ptr_conv);
20337         return ret_val;
20338 }
20339
20340 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) {
20341         LDKChannelHandshakeLimits this_ptr_conv;
20342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20343         this_ptr_conv.is_owned = false;
20344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20345         ChannelHandshakeLimits_set_max_htlc_minimum_msat(&this_ptr_conv, val);
20346 }
20347
20348 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) {
20349         LDKChannelHandshakeLimits this_ptr_conv;
20350         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20351         this_ptr_conv.is_owned = false;
20352         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20353         int64_t ret_val = ChannelHandshakeLimits_get_min_max_htlc_value_in_flight_msat(&this_ptr_conv);
20354         return ret_val;
20355 }
20356
20357 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) {
20358         LDKChannelHandshakeLimits this_ptr_conv;
20359         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20360         this_ptr_conv.is_owned = false;
20361         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20362         ChannelHandshakeLimits_set_min_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
20363 }
20364
20365 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
20366         LDKChannelHandshakeLimits this_ptr_conv;
20367         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20368         this_ptr_conv.is_owned = false;
20369         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20370         int64_t ret_val = ChannelHandshakeLimits_get_max_channel_reserve_satoshis(&this_ptr_conv);
20371         return ret_val;
20372 }
20373
20374 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) {
20375         LDKChannelHandshakeLimits this_ptr_conv;
20376         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20377         this_ptr_conv.is_owned = false;
20378         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20379         ChannelHandshakeLimits_set_max_channel_reserve_satoshis(&this_ptr_conv, val);
20380 }
20381
20382 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1min_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
20383         LDKChannelHandshakeLimits this_ptr_conv;
20384         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20385         this_ptr_conv.is_owned = false;
20386         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20387         int16_t ret_val = ChannelHandshakeLimits_get_min_max_accepted_htlcs(&this_ptr_conv);
20388         return ret_val;
20389 }
20390
20391 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) {
20392         LDKChannelHandshakeLimits this_ptr_conv;
20393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20394         this_ptr_conv.is_owned = false;
20395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20396         ChannelHandshakeLimits_set_min_max_accepted_htlcs(&this_ptr_conv, val);
20397 }
20398
20399 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
20400         LDKChannelHandshakeLimits this_ptr_conv;
20401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20402         this_ptr_conv.is_owned = false;
20403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20404         int32_t ret_val = ChannelHandshakeLimits_get_max_minimum_depth(&this_ptr_conv);
20405         return ret_val;
20406 }
20407
20408 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1max_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
20409         LDKChannelHandshakeLimits this_ptr_conv;
20410         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20411         this_ptr_conv.is_owned = false;
20412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20413         ChannelHandshakeLimits_set_max_minimum_depth(&this_ptr_conv, val);
20414 }
20415
20416 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr) {
20417         LDKChannelHandshakeLimits this_ptr_conv;
20418         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20419         this_ptr_conv.is_owned = false;
20420         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20421         jboolean ret_val = ChannelHandshakeLimits_get_force_announced_channel_preference(&this_ptr_conv);
20422         return ret_val;
20423 }
20424
20425 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1set_1force_1announced_1channel_1preference(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20426         LDKChannelHandshakeLimits this_ptr_conv;
20427         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20428         this_ptr_conv.is_owned = false;
20429         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20430         ChannelHandshakeLimits_set_force_announced_channel_preference(&this_ptr_conv, val);
20431 }
20432
20433 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1get_1their_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
20434         LDKChannelHandshakeLimits this_ptr_conv;
20435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20436         this_ptr_conv.is_owned = false;
20437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20438         int16_t ret_val = ChannelHandshakeLimits_get_their_to_self_delay(&this_ptr_conv);
20439         return ret_val;
20440 }
20441
20442 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) {
20443         LDKChannelHandshakeLimits this_ptr_conv;
20444         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20445         this_ptr_conv.is_owned = false;
20446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20447         ChannelHandshakeLimits_set_their_to_self_delay(&this_ptr_conv, val);
20448 }
20449
20450 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) {
20451         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);
20452         uint64_t ret_ref = 0;
20453         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20454         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20455         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20456         ret_ref = (uint64_t)ret_var.inner;
20457         if (ret_var.is_owned) {
20458                 ret_ref |= 1;
20459         }
20460         return ret_ref;
20461 }
20462
20463 static inline uint64_t ChannelHandshakeLimits_clone_ptr(LDKChannelHandshakeLimits *NONNULL_PTR arg) {
20464         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(arg);
20465 uint64_t ret_ref = 0;
20466 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20467 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20468 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20469 ret_ref = (uint64_t)ret_var.inner;
20470 if (ret_var.is_owned) {
20471         ret_ref |= 1;
20472 }
20473         return ret_ref;
20474 }
20475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20476         LDKChannelHandshakeLimits arg_conv;
20477         arg_conv.inner = (void*)(arg & (~1));
20478         arg_conv.is_owned = false;
20479         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20480         int64_t ret_val = ChannelHandshakeLimits_clone_ptr(&arg_conv);
20481         return ret_val;
20482 }
20483
20484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20485         LDKChannelHandshakeLimits orig_conv;
20486         orig_conv.inner = (void*)(orig & (~1));
20487         orig_conv.is_owned = false;
20488         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20489         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_clone(&orig_conv);
20490         uint64_t ret_ref = 0;
20491         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20492         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20493         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20494         ret_ref = (uint64_t)ret_var.inner;
20495         if (ret_var.is_owned) {
20496                 ret_ref |= 1;
20497         }
20498         return ret_ref;
20499 }
20500
20501 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelHandshakeLimits_1default(JNIEnv *env, jclass clz) {
20502         LDKChannelHandshakeLimits ret_var = ChannelHandshakeLimits_default();
20503         uint64_t ret_ref = 0;
20504         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20505         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20506         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20507         ret_ref = (uint64_t)ret_var.inner;
20508         if (ret_var.is_owned) {
20509                 ret_ref |= 1;
20510         }
20511         return ret_ref;
20512 }
20513
20514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20515         LDKChannelConfig this_obj_conv;
20516         this_obj_conv.inner = (void*)(this_obj & (~1));
20517         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20518         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20519         ChannelConfig_free(this_obj_conv);
20520 }
20521
20522 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
20523         LDKChannelConfig this_ptr_conv;
20524         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20525         this_ptr_conv.is_owned = false;
20526         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20527         int32_t ret_val = ChannelConfig_get_forwarding_fee_proportional_millionths(&this_ptr_conv);
20528         return ret_val;
20529 }
20530
20531 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) {
20532         LDKChannelConfig this_ptr_conv;
20533         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20534         this_ptr_conv.is_owned = false;
20535         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20536         ChannelConfig_set_forwarding_fee_proportional_millionths(&this_ptr_conv, val);
20537 }
20538
20539 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1forwarding_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20540         LDKChannelConfig this_ptr_conv;
20541         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20542         this_ptr_conv.is_owned = false;
20543         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20544         int32_t ret_val = ChannelConfig_get_forwarding_fee_base_msat(&this_ptr_conv);
20545         return ret_val;
20546 }
20547
20548 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) {
20549         LDKChannelConfig this_ptr_conv;
20550         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20551         this_ptr_conv.is_owned = false;
20552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20553         ChannelConfig_set_forwarding_fee_base_msat(&this_ptr_conv, val);
20554 }
20555
20556 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
20557         LDKChannelConfig this_ptr_conv;
20558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20559         this_ptr_conv.is_owned = false;
20560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20561         int16_t ret_val = ChannelConfig_get_cltv_expiry_delta(&this_ptr_conv);
20562         return ret_val;
20563 }
20564
20565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
20566         LDKChannelConfig this_ptr_conv;
20567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20568         this_ptr_conv.is_owned = false;
20569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20570         ChannelConfig_set_cltv_expiry_delta(&this_ptr_conv, val);
20571 }
20572
20573 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr) {
20574         LDKChannelConfig this_ptr_conv;
20575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20576         this_ptr_conv.is_owned = false;
20577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20578         jboolean ret_val = ChannelConfig_get_announced_channel(&this_ptr_conv);
20579         return ret_val;
20580 }
20581
20582 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1announced_1channel(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20583         LDKChannelConfig this_ptr_conv;
20584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20585         this_ptr_conv.is_owned = false;
20586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20587         ChannelConfig_set_announced_channel(&this_ptr_conv, val);
20588 }
20589
20590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
20591         LDKChannelConfig this_ptr_conv;
20592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20593         this_ptr_conv.is_owned = false;
20594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20595         jboolean ret_val = ChannelConfig_get_commit_upfront_shutdown_pubkey(&this_ptr_conv);
20596         return ret_val;
20597 }
20598
20599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1set_1commit_1upfront_1shutdown_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
20600         LDKChannelConfig this_ptr_conv;
20601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20602         this_ptr_conv.is_owned = false;
20603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20604         ChannelConfig_set_commit_upfront_shutdown_pubkey(&this_ptr_conv, val);
20605 }
20606
20607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1get_1max_1dust_1htlc_1exposure_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
20608         LDKChannelConfig this_ptr_conv;
20609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20610         this_ptr_conv.is_owned = false;
20611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20612         int64_t ret_val = ChannelConfig_get_max_dust_htlc_exposure_msat(&this_ptr_conv);
20613         return ret_val;
20614 }
20615
20616 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) {
20617         LDKChannelConfig this_ptr_conv;
20618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20619         this_ptr_conv.is_owned = false;
20620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20621         ChannelConfig_set_max_dust_htlc_exposure_msat(&this_ptr_conv, val);
20622 }
20623
20624 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) {
20625         LDKChannelConfig this_ptr_conv;
20626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20627         this_ptr_conv.is_owned = false;
20628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20629         int64_t ret_val = ChannelConfig_get_force_close_avoidance_max_fee_satoshis(&this_ptr_conv);
20630         return ret_val;
20631 }
20632
20633 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) {
20634         LDKChannelConfig this_ptr_conv;
20635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20636         this_ptr_conv.is_owned = false;
20637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20638         ChannelConfig_set_force_close_avoidance_max_fee_satoshis(&this_ptr_conv, val);
20639 }
20640
20641 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) {
20642         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);
20643         uint64_t ret_ref = 0;
20644         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20645         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20646         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20647         ret_ref = (uint64_t)ret_var.inner;
20648         if (ret_var.is_owned) {
20649                 ret_ref |= 1;
20650         }
20651         return ret_ref;
20652 }
20653
20654 static inline uint64_t ChannelConfig_clone_ptr(LDKChannelConfig *NONNULL_PTR arg) {
20655         LDKChannelConfig ret_var = ChannelConfig_clone(arg);
20656 uint64_t ret_ref = 0;
20657 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20658 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20659 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20660 ret_ref = (uint64_t)ret_var.inner;
20661 if (ret_var.is_owned) {
20662         ret_ref |= 1;
20663 }
20664         return ret_ref;
20665 }
20666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20667         LDKChannelConfig arg_conv;
20668         arg_conv.inner = (void*)(arg & (~1));
20669         arg_conv.is_owned = false;
20670         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20671         int64_t ret_val = ChannelConfig_clone_ptr(&arg_conv);
20672         return ret_val;
20673 }
20674
20675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20676         LDKChannelConfig orig_conv;
20677         orig_conv.inner = (void*)(orig & (~1));
20678         orig_conv.is_owned = false;
20679         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20680         LDKChannelConfig ret_var = ChannelConfig_clone(&orig_conv);
20681         uint64_t ret_ref = 0;
20682         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20683         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20684         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20685         ret_ref = (uint64_t)ret_var.inner;
20686         if (ret_var.is_owned) {
20687                 ret_ref |= 1;
20688         }
20689         return ret_ref;
20690 }
20691
20692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1default(JNIEnv *env, jclass clz) {
20693         LDKChannelConfig ret_var = ChannelConfig_default();
20694         uint64_t ret_ref = 0;
20695         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20696         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20697         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20698         ret_ref = (uint64_t)ret_var.inner;
20699         if (ret_var.is_owned) {
20700                 ret_ref |= 1;
20701         }
20702         return ret_ref;
20703 }
20704
20705 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1write(JNIEnv *env, jclass clz, int64_t obj) {
20706         LDKChannelConfig obj_conv;
20707         obj_conv.inner = (void*)(obj & (~1));
20708         obj_conv.is_owned = false;
20709         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
20710         LDKCVec_u8Z ret_var = ChannelConfig_write(&obj_conv);
20711         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
20712         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
20713         CVec_u8Z_free(ret_var);
20714         return ret_arr;
20715 }
20716
20717 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelConfig_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
20718         LDKu8slice ser_ref;
20719         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
20720         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
20721         LDKCResult_ChannelConfigDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelConfigDecodeErrorZ), "LDKCResult_ChannelConfigDecodeErrorZ");
20722         *ret_conv = ChannelConfig_read(ser_ref);
20723         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
20724         return (uint64_t)ret_conv;
20725 }
20726
20727 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20728         LDKUserConfig this_obj_conv;
20729         this_obj_conv.inner = (void*)(this_obj & (~1));
20730         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20731         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20732         UserConfig_free(this_obj_conv);
20733 }
20734
20735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
20736         LDKUserConfig this_ptr_conv;
20737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20738         this_ptr_conv.is_owned = false;
20739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20740         LDKChannelHandshakeConfig ret_var = UserConfig_get_own_channel_config(&this_ptr_conv);
20741         uint64_t ret_ref = 0;
20742         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20743         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20744         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20745         ret_ref = (uint64_t)ret_var.inner;
20746         if (ret_var.is_owned) {
20747                 ret_ref |= 1;
20748         }
20749         return ret_ref;
20750 }
20751
20752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1own_1channel_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20753         LDKUserConfig this_ptr_conv;
20754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20755         this_ptr_conv.is_owned = false;
20756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20757         LDKChannelHandshakeConfig val_conv;
20758         val_conv.inner = (void*)(val & (~1));
20759         val_conv.is_owned = (val & 1) || (val == 0);
20760         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20761         val_conv = ChannelHandshakeConfig_clone(&val_conv);
20762         UserConfig_set_own_channel_config(&this_ptr_conv, val_conv);
20763 }
20764
20765 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1peer_1channel_1config_1limits(JNIEnv *env, jclass clz, int64_t this_ptr) {
20766         LDKUserConfig this_ptr_conv;
20767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20768         this_ptr_conv.is_owned = false;
20769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20770         LDKChannelHandshakeLimits ret_var = UserConfig_get_peer_channel_config_limits(&this_ptr_conv);
20771         uint64_t ret_ref = 0;
20772         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20773         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20774         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20775         ret_ref = (uint64_t)ret_var.inner;
20776         if (ret_var.is_owned) {
20777                 ret_ref |= 1;
20778         }
20779         return ret_ref;
20780 }
20781
20782 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) {
20783         LDKUserConfig this_ptr_conv;
20784         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20785         this_ptr_conv.is_owned = false;
20786         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20787         LDKChannelHandshakeLimits val_conv;
20788         val_conv.inner = (void*)(val & (~1));
20789         val_conv.is_owned = (val & 1) || (val == 0);
20790         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20791         val_conv = ChannelHandshakeLimits_clone(&val_conv);
20792         UserConfig_set_peer_channel_config_limits(&this_ptr_conv, val_conv);
20793 }
20794
20795 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr) {
20796         LDKUserConfig this_ptr_conv;
20797         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20798         this_ptr_conv.is_owned = false;
20799         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20800         LDKChannelConfig ret_var = UserConfig_get_channel_options(&this_ptr_conv);
20801         uint64_t ret_ref = 0;
20802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20805         ret_ref = (uint64_t)ret_var.inner;
20806         if (ret_var.is_owned) {
20807                 ret_ref |= 1;
20808         }
20809         return ret_ref;
20810 }
20811
20812 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UserConfig_1set_1channel_1options(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
20813         LDKUserConfig this_ptr_conv;
20814         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20815         this_ptr_conv.is_owned = false;
20816         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20817         LDKChannelConfig val_conv;
20818         val_conv.inner = (void*)(val & (~1));
20819         val_conv.is_owned = (val & 1) || (val == 0);
20820         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
20821         val_conv = ChannelConfig_clone(&val_conv);
20822         UserConfig_set_channel_options(&this_ptr_conv, val_conv);
20823 }
20824
20825 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_UserConfig_1get_1accept_1forwards_1to_1priv_1channels(JNIEnv *env, jclass clz, int64_t this_ptr) {
20826         LDKUserConfig this_ptr_conv;
20827         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20828         this_ptr_conv.is_owned = false;
20829         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20830         jboolean ret_val = UserConfig_get_accept_forwards_to_priv_channels(&this_ptr_conv);
20831         return ret_val;
20832 }
20833
20834 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) {
20835         LDKUserConfig this_ptr_conv;
20836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
20837         this_ptr_conv.is_owned = false;
20838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
20839         UserConfig_set_accept_forwards_to_priv_channels(&this_ptr_conv, val);
20840 }
20841
20842 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) {
20843         LDKChannelHandshakeConfig own_channel_config_arg_conv;
20844         own_channel_config_arg_conv.inner = (void*)(own_channel_config_arg & (~1));
20845         own_channel_config_arg_conv.is_owned = (own_channel_config_arg & 1) || (own_channel_config_arg == 0);
20846         CHECK_INNER_FIELD_ACCESS_OR_NULL(own_channel_config_arg_conv);
20847         own_channel_config_arg_conv = ChannelHandshakeConfig_clone(&own_channel_config_arg_conv);
20848         LDKChannelHandshakeLimits peer_channel_config_limits_arg_conv;
20849         peer_channel_config_limits_arg_conv.inner = (void*)(peer_channel_config_limits_arg & (~1));
20850         peer_channel_config_limits_arg_conv.is_owned = (peer_channel_config_limits_arg & 1) || (peer_channel_config_limits_arg == 0);
20851         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_channel_config_limits_arg_conv);
20852         peer_channel_config_limits_arg_conv = ChannelHandshakeLimits_clone(&peer_channel_config_limits_arg_conv);
20853         LDKChannelConfig channel_options_arg_conv;
20854         channel_options_arg_conv.inner = (void*)(channel_options_arg & (~1));
20855         channel_options_arg_conv.is_owned = (channel_options_arg & 1) || (channel_options_arg == 0);
20856         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_options_arg_conv);
20857         channel_options_arg_conv = ChannelConfig_clone(&channel_options_arg_conv);
20858         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);
20859         uint64_t ret_ref = 0;
20860         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20861         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20862         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20863         ret_ref = (uint64_t)ret_var.inner;
20864         if (ret_var.is_owned) {
20865                 ret_ref |= 1;
20866         }
20867         return ret_ref;
20868 }
20869
20870 static inline uint64_t UserConfig_clone_ptr(LDKUserConfig *NONNULL_PTR arg) {
20871         LDKUserConfig ret_var = UserConfig_clone(arg);
20872 uint64_t ret_ref = 0;
20873 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20874 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20875 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20876 ret_ref = (uint64_t)ret_var.inner;
20877 if (ret_var.is_owned) {
20878         ret_ref |= 1;
20879 }
20880         return ret_ref;
20881 }
20882 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20883         LDKUserConfig arg_conv;
20884         arg_conv.inner = (void*)(arg & (~1));
20885         arg_conv.is_owned = false;
20886         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20887         int64_t ret_val = UserConfig_clone_ptr(&arg_conv);
20888         return ret_val;
20889 }
20890
20891 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20892         LDKUserConfig orig_conv;
20893         orig_conv.inner = (void*)(orig & (~1));
20894         orig_conv.is_owned = false;
20895         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20896         LDKUserConfig ret_var = UserConfig_clone(&orig_conv);
20897         uint64_t ret_ref = 0;
20898         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20899         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20900         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20901         ret_ref = (uint64_t)ret_var.inner;
20902         if (ret_var.is_owned) {
20903                 ret_ref |= 1;
20904         }
20905         return ret_ref;
20906 }
20907
20908 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UserConfig_1default(JNIEnv *env, jclass clz) {
20909         LDKUserConfig ret_var = UserConfig_default();
20910         uint64_t ret_ref = 0;
20911         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20912         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20913         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20914         ret_ref = (uint64_t)ret_var.inner;
20915         if (ret_var.is_owned) {
20916                 ret_ref |= 1;
20917         }
20918         return ret_ref;
20919 }
20920
20921 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BestBlock_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
20922         LDKBestBlock this_obj_conv;
20923         this_obj_conv.inner = (void*)(this_obj & (~1));
20924         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
20925         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
20926         BestBlock_free(this_obj_conv);
20927 }
20928
20929 static inline uint64_t BestBlock_clone_ptr(LDKBestBlock *NONNULL_PTR arg) {
20930         LDKBestBlock ret_var = BestBlock_clone(arg);
20931 uint64_t ret_ref = 0;
20932 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20933 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20934 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20935 ret_ref = (uint64_t)ret_var.inner;
20936 if (ret_var.is_owned) {
20937         ret_ref |= 1;
20938 }
20939         return ret_ref;
20940 }
20941 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
20942         LDKBestBlock arg_conv;
20943         arg_conv.inner = (void*)(arg & (~1));
20944         arg_conv.is_owned = false;
20945         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
20946         int64_t ret_val = BestBlock_clone_ptr(&arg_conv);
20947         return ret_val;
20948 }
20949
20950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1clone(JNIEnv *env, jclass clz, int64_t orig) {
20951         LDKBestBlock orig_conv;
20952         orig_conv.inner = (void*)(orig & (~1));
20953         orig_conv.is_owned = false;
20954         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
20955         LDKBestBlock ret_var = BestBlock_clone(&orig_conv);
20956         uint64_t ret_ref = 0;
20957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20960         ret_ref = (uint64_t)ret_var.inner;
20961         if (ret_var.is_owned) {
20962                 ret_ref |= 1;
20963         }
20964         return ret_ref;
20965 }
20966
20967 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1from_1genesis(JNIEnv *env, jclass clz, jclass network) {
20968         LDKNetwork network_conv = LDKNetwork_from_java(env, network);
20969         LDKBestBlock ret_var = BestBlock_from_genesis(network_conv);
20970         uint64_t ret_ref = 0;
20971         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20972         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20973         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20974         ret_ref = (uint64_t)ret_var.inner;
20975         if (ret_var.is_owned) {
20976                 ret_ref |= 1;
20977         }
20978         return ret_ref;
20979 }
20980
20981 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1new(JNIEnv *env, jclass clz, int8_tArray block_hash, int32_t height) {
20982         LDKThirtyTwoBytes block_hash_ref;
20983         CHECK((*env)->GetArrayLength(env, block_hash) == 32);
20984         (*env)->GetByteArrayRegion(env, block_hash, 0, 32, block_hash_ref.data);
20985         LDKBestBlock ret_var = BestBlock_new(block_hash_ref, height);
20986         uint64_t ret_ref = 0;
20987         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
20988         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
20989         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
20990         ret_ref = (uint64_t)ret_var.inner;
20991         if (ret_var.is_owned) {
20992                 ret_ref |= 1;
20993         }
20994         return ret_ref;
20995 }
20996
20997 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BestBlock_1block_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
20998         LDKBestBlock this_arg_conv;
20999         this_arg_conv.inner = (void*)(this_arg & (~1));
21000         this_arg_conv.is_owned = false;
21001         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21002         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21003         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BestBlock_block_hash(&this_arg_conv).data);
21004         return ret_arr;
21005 }
21006
21007 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_BestBlock_1height(JNIEnv *env, jclass clz, int64_t this_arg) {
21008         LDKBestBlock this_arg_conv;
21009         this_arg_conv.inner = (void*)(this_arg & (~1));
21010         this_arg_conv.is_owned = false;
21011         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21012         int32_t ret_val = BestBlock_height(&this_arg_conv);
21013         return ret_val;
21014 }
21015
21016 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21017         LDKAccessError* orig_conv = (LDKAccessError*)(orig & ~1);
21018         jclass ret_conv = LDKAccessError_to_java(env, AccessError_clone(orig_conv));
21019         return ret_conv;
21020 }
21021
21022 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1chain(JNIEnv *env, jclass clz) {
21023         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_chain());
21024         return ret_conv;
21025 }
21026
21027 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_AccessError_1unknown_1tx(JNIEnv *env, jclass clz) {
21028         jclass ret_conv = LDKAccessError_to_java(env, AccessError_unknown_tx());
21029         return ret_conv;
21030 }
21031
21032 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Access_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21033         if ((this_ptr & 1) != 0) return;
21034         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21035         CHECK_ACCESS(this_ptr_ptr);
21036         LDKAccess this_ptr_conv = *(LDKAccess*)(this_ptr_ptr);
21037         FREE((void*)this_ptr);
21038         Access_free(this_ptr_conv);
21039 }
21040
21041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Listen_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21042         if ((this_ptr & 1) != 0) return;
21043         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21044         CHECK_ACCESS(this_ptr_ptr);
21045         LDKListen this_ptr_conv = *(LDKListen*)(this_ptr_ptr);
21046         FREE((void*)this_ptr);
21047         Listen_free(this_ptr_conv);
21048 }
21049
21050 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Confirm_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21051         if ((this_ptr & 1) != 0) return;
21052         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21053         CHECK_ACCESS(this_ptr_ptr);
21054         LDKConfirm this_ptr_conv = *(LDKConfirm*)(this_ptr_ptr);
21055         FREE((void*)this_ptr);
21056         Confirm_free(this_ptr_conv);
21057 }
21058
21059 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21060         LDKChannelMonitorUpdateErr* orig_conv = (LDKChannelMonitorUpdateErr*)(orig & ~1);
21061         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_clone(orig_conv));
21062         return ret_conv;
21063 }
21064
21065 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1temporary_1failure(JNIEnv *env, jclass clz) {
21066         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_temporary_failure());
21067         return ret_conv;
21068 }
21069
21070 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdateErr_1permanent_1failure(JNIEnv *env, jclass clz) {
21071         jclass ret_conv = LDKChannelMonitorUpdateErr_to_java(env, ChannelMonitorUpdateErr_permanent_failure());
21072         return ret_conv;
21073 }
21074
21075 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Watch_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21076         if ((this_ptr & 1) != 0) return;
21077         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21078         CHECK_ACCESS(this_ptr_ptr);
21079         LDKWatch this_ptr_conv = *(LDKWatch*)(this_ptr_ptr);
21080         FREE((void*)this_ptr);
21081         Watch_free(this_ptr_conv);
21082 }
21083
21084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Filter_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21085         if ((this_ptr & 1) != 0) return;
21086         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21087         CHECK_ACCESS(this_ptr_ptr);
21088         LDKFilter this_ptr_conv = *(LDKFilter*)(this_ptr_ptr);
21089         FREE((void*)this_ptr);
21090         Filter_free(this_ptr_conv);
21091 }
21092
21093 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21094         LDKWatchedOutput this_obj_conv;
21095         this_obj_conv.inner = (void*)(this_obj & (~1));
21096         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21097         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21098         WatchedOutput_free(this_obj_conv);
21099 }
21100
21101 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
21102         LDKWatchedOutput this_ptr_conv;
21103         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21104         this_ptr_conv.is_owned = false;
21105         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21106         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
21107         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, WatchedOutput_get_block_hash(&this_ptr_conv).data);
21108         return ret_arr;
21109 }
21110
21111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1block_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21112         LDKWatchedOutput this_ptr_conv;
21113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21114         this_ptr_conv.is_owned = false;
21115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21116         LDKThirtyTwoBytes val_ref;
21117         CHECK((*env)->GetArrayLength(env, val) == 32);
21118         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
21119         WatchedOutput_set_block_hash(&this_ptr_conv, val_ref);
21120 }
21121
21122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
21123         LDKWatchedOutput this_ptr_conv;
21124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21125         this_ptr_conv.is_owned = false;
21126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21127         LDKOutPoint ret_var = WatchedOutput_get_outpoint(&this_ptr_conv);
21128         uint64_t ret_ref = 0;
21129         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21130         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21131         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21132         ret_ref = (uint64_t)ret_var.inner;
21133         if (ret_var.is_owned) {
21134                 ret_ref |= 1;
21135         }
21136         return ret_ref;
21137 }
21138
21139 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21140         LDKWatchedOutput this_ptr_conv;
21141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21142         this_ptr_conv.is_owned = false;
21143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21144         LDKOutPoint val_conv;
21145         val_conv.inner = (void*)(val & (~1));
21146         val_conv.is_owned = (val & 1) || (val == 0);
21147         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
21148         val_conv = OutPoint_clone(&val_conv);
21149         WatchedOutput_set_outpoint(&this_ptr_conv, val_conv);
21150 }
21151
21152 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1get_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
21153         LDKWatchedOutput this_ptr_conv;
21154         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21155         this_ptr_conv.is_owned = false;
21156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21157         LDKu8slice ret_var = WatchedOutput_get_script_pubkey(&this_ptr_conv);
21158         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21159         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21160         return ret_arr;
21161 }
21162
21163 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1set_1script_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
21164         LDKWatchedOutput this_ptr_conv;
21165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21166         this_ptr_conv.is_owned = false;
21167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21168         LDKCVec_u8Z val_ref;
21169         val_ref.datalen = (*env)->GetArrayLength(env, val);
21170         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
21171         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
21172         WatchedOutput_set_script_pubkey(&this_ptr_conv, val_ref);
21173 }
21174
21175 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) {
21176         LDKThirtyTwoBytes block_hash_arg_ref;
21177         CHECK((*env)->GetArrayLength(env, block_hash_arg) == 32);
21178         (*env)->GetByteArrayRegion(env, block_hash_arg, 0, 32, block_hash_arg_ref.data);
21179         LDKOutPoint outpoint_arg_conv;
21180         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
21181         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
21182         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
21183         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
21184         LDKCVec_u8Z script_pubkey_arg_ref;
21185         script_pubkey_arg_ref.datalen = (*env)->GetArrayLength(env, script_pubkey_arg);
21186         script_pubkey_arg_ref.data = MALLOC(script_pubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
21187         (*env)->GetByteArrayRegion(env, script_pubkey_arg, 0, script_pubkey_arg_ref.datalen, script_pubkey_arg_ref.data);
21188         LDKWatchedOutput ret_var = WatchedOutput_new(block_hash_arg_ref, outpoint_arg_conv, script_pubkey_arg_ref);
21189         uint64_t ret_ref = 0;
21190         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21191         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21192         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21193         ret_ref = (uint64_t)ret_var.inner;
21194         if (ret_var.is_owned) {
21195                 ret_ref |= 1;
21196         }
21197         return ret_ref;
21198 }
21199
21200 static inline uint64_t WatchedOutput_clone_ptr(LDKWatchedOutput *NONNULL_PTR arg) {
21201         LDKWatchedOutput ret_var = WatchedOutput_clone(arg);
21202 uint64_t ret_ref = 0;
21203 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21204 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21205 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21206 ret_ref = (uint64_t)ret_var.inner;
21207 if (ret_var.is_owned) {
21208         ret_ref |= 1;
21209 }
21210         return ret_ref;
21211 }
21212 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21213         LDKWatchedOutput arg_conv;
21214         arg_conv.inner = (void*)(arg & (~1));
21215         arg_conv.is_owned = false;
21216         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21217         int64_t ret_val = WatchedOutput_clone_ptr(&arg_conv);
21218         return ret_val;
21219 }
21220
21221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21222         LDKWatchedOutput orig_conv;
21223         orig_conv.inner = (void*)(orig & (~1));
21224         orig_conv.is_owned = false;
21225         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21226         LDKWatchedOutput ret_var = WatchedOutput_clone(&orig_conv);
21227         uint64_t ret_ref = 0;
21228         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21229         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21230         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21231         ret_ref = (uint64_t)ret_var.inner;
21232         if (ret_var.is_owned) {
21233                 ret_ref |= 1;
21234         }
21235         return ret_ref;
21236 }
21237
21238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_WatchedOutput_1hash(JNIEnv *env, jclass clz, int64_t o) {
21239         LDKWatchedOutput o_conv;
21240         o_conv.inner = (void*)(o & (~1));
21241         o_conv.is_owned = false;
21242         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21243         int64_t ret_val = WatchedOutput_hash(&o_conv);
21244         return ret_val;
21245 }
21246
21247 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BroadcasterInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21248         if ((this_ptr & 1) != 0) return;
21249         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21250         CHECK_ACCESS(this_ptr_ptr);
21251         LDKBroadcasterInterface this_ptr_conv = *(LDKBroadcasterInterface*)(this_ptr_ptr);
21252         FREE((void*)this_ptr);
21253         BroadcasterInterface_free(this_ptr_conv);
21254 }
21255
21256 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21257         LDKConfirmationTarget* orig_conv = (LDKConfirmationTarget*)(orig & ~1);
21258         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_clone(orig_conv));
21259         return ret_conv;
21260 }
21261
21262 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1background(JNIEnv *env, jclass clz) {
21263         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_background());
21264         return ret_conv;
21265 }
21266
21267 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1normal(JNIEnv *env, jclass clz) {
21268         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_normal());
21269         return ret_conv;
21270 }
21271
21272 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1high_1priority(JNIEnv *env, jclass clz) {
21273         jclass ret_conv = LDKConfirmationTarget_to_java(env, ConfirmationTarget_high_priority());
21274         return ret_conv;
21275 }
21276
21277 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ConfirmationTarget_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
21278         LDKConfirmationTarget* a_conv = (LDKConfirmationTarget*)(a & ~1);
21279         LDKConfirmationTarget* b_conv = (LDKConfirmationTarget*)(b & ~1);
21280         jboolean ret_val = ConfirmationTarget_eq(a_conv, b_conv);
21281         return ret_val;
21282 }
21283
21284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FeeEstimator_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21285         if ((this_ptr & 1) != 0) return;
21286         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21287         CHECK_ACCESS(this_ptr_ptr);
21288         LDKFeeEstimator this_ptr_conv = *(LDKFeeEstimator*)(this_ptr_ptr);
21289         FREE((void*)this_ptr);
21290         FeeEstimator_free(this_ptr_conv);
21291 }
21292
21293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21294         LDKMonitorUpdateId this_obj_conv;
21295         this_obj_conv.inner = (void*)(this_obj & (~1));
21296         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21298         MonitorUpdateId_free(this_obj_conv);
21299 }
21300
21301 static inline uint64_t MonitorUpdateId_clone_ptr(LDKMonitorUpdateId *NONNULL_PTR arg) {
21302         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(arg);
21303 uint64_t ret_ref = 0;
21304 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21305 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21306 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21307 ret_ref = (uint64_t)ret_var.inner;
21308 if (ret_var.is_owned) {
21309         ret_ref |= 1;
21310 }
21311         return ret_ref;
21312 }
21313 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21314         LDKMonitorUpdateId arg_conv;
21315         arg_conv.inner = (void*)(arg & (~1));
21316         arg_conv.is_owned = false;
21317         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21318         int64_t ret_val = MonitorUpdateId_clone_ptr(&arg_conv);
21319         return ret_val;
21320 }
21321
21322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21323         LDKMonitorUpdateId orig_conv;
21324         orig_conv.inner = (void*)(orig & (~1));
21325         orig_conv.is_owned = false;
21326         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21327         LDKMonitorUpdateId ret_var = MonitorUpdateId_clone(&orig_conv);
21328         uint64_t ret_ref = 0;
21329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21332         ret_ref = (uint64_t)ret_var.inner;
21333         if (ret_var.is_owned) {
21334                 ret_ref |= 1;
21335         }
21336         return ret_ref;
21337 }
21338
21339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1hash(JNIEnv *env, jclass clz, int64_t o) {
21340         LDKMonitorUpdateId o_conv;
21341         o_conv.inner = (void*)(o & (~1));
21342         o_conv.is_owned = false;
21343         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
21344         int64_t ret_val = MonitorUpdateId_hash(&o_conv);
21345         return ret_val;
21346 }
21347
21348 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MonitorUpdateId_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
21349         LDKMonitorUpdateId a_conv;
21350         a_conv.inner = (void*)(a & (~1));
21351         a_conv.is_owned = false;
21352         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21353         LDKMonitorUpdateId b_conv;
21354         b_conv.inner = (void*)(b & (~1));
21355         b_conv.is_owned = false;
21356         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
21357         jboolean ret_val = MonitorUpdateId_eq(&a_conv, &b_conv);
21358         return ret_val;
21359 }
21360
21361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Persist_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21362         if ((this_ptr & 1) != 0) return;
21363         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21364         CHECK_ACCESS(this_ptr_ptr);
21365         LDKPersist this_ptr_conv = *(LDKPersist*)(this_ptr_ptr);
21366         FREE((void*)this_ptr);
21367         Persist_free(this_ptr_conv);
21368 }
21369
21370 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockedChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21371         LDKLockedChannelMonitor this_obj_conv;
21372         this_obj_conv.inner = (void*)(this_obj & (~1));
21373         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21375         LockedChannelMonitor_free(this_obj_conv);
21376 }
21377
21378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21379         LDKChainMonitor this_obj_conv;
21380         this_obj_conv.inner = (void*)(this_obj & (~1));
21381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21383         ChainMonitor_free(this_obj_conv);
21384 }
21385
21386 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) {
21387         void* chain_source_ptr = (void*)(((uint64_t)chain_source) & ~1);
21388         CHECK_ACCESS(chain_source_ptr);
21389         LDKCOption_FilterZ chain_source_conv = *(LDKCOption_FilterZ*)(chain_source_ptr);
21390         // Warning: we may need a move here but no clone is available for LDKCOption_FilterZ
21391         if (chain_source_conv.tag == LDKCOption_FilterZ_Some) {
21392                 // Manually implement clone for Java trait instances
21393                 if (chain_source_conv.some.free == LDKFilter_JCalls_free) {
21394                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21395                         LDKFilter_JCalls_cloned(&chain_source_conv.some);
21396                 }
21397         }
21398         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
21399         CHECK_ACCESS(broadcaster_ptr);
21400         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
21401         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
21402                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21403                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
21404         }
21405         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
21406         CHECK_ACCESS(logger_ptr);
21407         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
21408         if (logger_conv.free == LDKLogger_JCalls_free) {
21409                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21410                 LDKLogger_JCalls_cloned(&logger_conv);
21411         }
21412         void* feeest_ptr = (void*)(((uint64_t)feeest) & ~1);
21413         CHECK_ACCESS(feeest_ptr);
21414         LDKFeeEstimator feeest_conv = *(LDKFeeEstimator*)(feeest_ptr);
21415         if (feeest_conv.free == LDKFeeEstimator_JCalls_free) {
21416                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21417                 LDKFeeEstimator_JCalls_cloned(&feeest_conv);
21418         }
21419         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
21420         CHECK_ACCESS(persister_ptr);
21421         LDKPersist persister_conv = *(LDKPersist*)(persister_ptr);
21422         if (persister_conv.free == LDKPersist_JCalls_free) {
21423                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
21424                 LDKPersist_JCalls_cloned(&persister_conv);
21425         }
21426         LDKChainMonitor ret_var = ChainMonitor_new(chain_source_conv, broadcaster_conv, logger_conv, feeest_conv, persister_conv);
21427         uint64_t ret_ref = 0;
21428         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21429         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21430         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21431         ret_ref = (uint64_t)ret_var.inner;
21432         if (ret_var.is_owned) {
21433                 ret_ref |= 1;
21434         }
21435         return ret_ref;
21436 }
21437
21438 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) {
21439         LDKChainMonitor this_arg_conv;
21440         this_arg_conv.inner = (void*)(this_arg & (~1));
21441         this_arg_conv.is_owned = false;
21442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21443         LDKCVec_ChannelDetailsZ ignored_channels_constr;
21444         ignored_channels_constr.datalen = (*env)->GetArrayLength(env, ignored_channels);
21445         if (ignored_channels_constr.datalen > 0)
21446                 ignored_channels_constr.data = MALLOC(ignored_channels_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
21447         else
21448                 ignored_channels_constr.data = NULL;
21449         int64_t* ignored_channels_vals = (*env)->GetLongArrayElements (env, ignored_channels, NULL);
21450         for (size_t q = 0; q < ignored_channels_constr.datalen; q++) {
21451                 int64_t ignored_channels_conv_16 = ignored_channels_vals[q];
21452                 LDKChannelDetails ignored_channels_conv_16_conv;
21453                 ignored_channels_conv_16_conv.inner = (void*)(ignored_channels_conv_16 & (~1));
21454                 ignored_channels_conv_16_conv.is_owned = (ignored_channels_conv_16 & 1) || (ignored_channels_conv_16 == 0);
21455                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ignored_channels_conv_16_conv);
21456                 ignored_channels_conv_16_conv = ChannelDetails_clone(&ignored_channels_conv_16_conv);
21457                 ignored_channels_constr.data[q] = ignored_channels_conv_16_conv;
21458         }
21459         (*env)->ReleaseLongArrayElements(env, ignored_channels, ignored_channels_vals, 0);
21460         LDKCVec_BalanceZ ret_var = ChainMonitor_get_claimable_balances(&this_arg_conv, ignored_channels_constr);
21461         int64_tArray ret_arr = NULL;
21462         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
21463         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
21464         for (size_t j = 0; j < ret_var.datalen; j++) {
21465                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21466                 *ret_conv_9_copy = ret_var.data[j];
21467                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
21468                 ret_arr_ptr[j] = ret_conv_9_ref;
21469         }
21470         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
21471         FREE(ret_var.data);
21472         return ret_arr;
21473 }
21474
21475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1get_1monitor(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_txo) {
21476         LDKChainMonitor this_arg_conv;
21477         this_arg_conv.inner = (void*)(this_arg & (~1));
21478         this_arg_conv.is_owned = false;
21479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21480         LDKOutPoint funding_txo_conv;
21481         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21482         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21483         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21484         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21485         LDKCResult_LockedChannelMonitorNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_LockedChannelMonitorNoneZ), "LDKCResult_LockedChannelMonitorNoneZ");
21486         *ret_conv = ChainMonitor_get_monitor(&this_arg_conv, funding_txo_conv);
21487         return (uint64_t)ret_conv;
21488 }
21489
21490 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1list_1monitors(JNIEnv *env, jclass clz, int64_t this_arg) {
21491         LDKChainMonitor this_arg_conv;
21492         this_arg_conv.inner = (void*)(this_arg & (~1));
21493         this_arg_conv.is_owned = false;
21494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21495         LDKCVec_OutPointZ ret_var = ChainMonitor_list_monitors(&this_arg_conv);
21496         int64_tArray ret_arr = NULL;
21497         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
21498         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
21499         for (size_t k = 0; k < ret_var.datalen; k++) {
21500                 LDKOutPoint ret_conv_10_var = ret_var.data[k];
21501                 uint64_t ret_conv_10_ref = 0;
21502                 CHECK((((uint64_t)ret_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21503                 CHECK((((uint64_t)&ret_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21504                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_10_var);
21505                 ret_conv_10_ref = (uint64_t)ret_conv_10_var.inner;
21506                 if (ret_conv_10_var.is_owned) {
21507                         ret_conv_10_ref |= 1;
21508                 }
21509                 ret_arr_ptr[k] = ret_conv_10_ref;
21510         }
21511         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
21512         FREE(ret_var.data);
21513         return ret_arr;
21514 }
21515
21516 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) {
21517         LDKChainMonitor this_arg_conv;
21518         this_arg_conv.inner = (void*)(this_arg & (~1));
21519         this_arg_conv.is_owned = false;
21520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21521         LDKOutPoint funding_txo_conv;
21522         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21523         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21524         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21525         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21526         LDKMonitorUpdateId completed_update_id_conv;
21527         completed_update_id_conv.inner = (void*)(completed_update_id & (~1));
21528         completed_update_id_conv.is_owned = (completed_update_id & 1) || (completed_update_id == 0);
21529         CHECK_INNER_FIELD_ACCESS_OR_NULL(completed_update_id_conv);
21530         completed_update_id_conv = MonitorUpdateId_clone(&completed_update_id_conv);
21531         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
21532         *ret_conv = ChainMonitor_channel_monitor_updated(&this_arg_conv, funding_txo_conv, completed_update_id_conv);
21533         return (uint64_t)ret_conv;
21534 }
21535
21536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
21537         LDKChainMonitor this_arg_conv;
21538         this_arg_conv.inner = (void*)(this_arg & (~1));
21539         this_arg_conv.is_owned = false;
21540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21541         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
21542         *ret_ret = ChainMonitor_as_Listen(&this_arg_conv);
21543         return (uint64_t)ret_ret;
21544 }
21545
21546 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
21547         LDKChainMonitor this_arg_conv;
21548         this_arg_conv.inner = (void*)(this_arg & (~1));
21549         this_arg_conv.is_owned = false;
21550         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21551         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
21552         *ret_ret = ChainMonitor_as_Confirm(&this_arg_conv);
21553         return (uint64_t)ret_ret;
21554 }
21555
21556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1Watch(JNIEnv *env, jclass clz, int64_t this_arg) {
21557         LDKChainMonitor this_arg_conv;
21558         this_arg_conv.inner = (void*)(this_arg & (~1));
21559         this_arg_conv.is_owned = false;
21560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21561         LDKWatch* ret_ret = MALLOC(sizeof(LDKWatch), "LDKWatch");
21562         *ret_ret = ChainMonitor_as_Watch(&this_arg_conv);
21563         return (uint64_t)ret_ret;
21564 }
21565
21566 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainMonitor_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
21567         LDKChainMonitor this_arg_conv;
21568         this_arg_conv.inner = (void*)(this_arg & (~1));
21569         this_arg_conv.is_owned = false;
21570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
21571         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
21572         *ret_ret = ChainMonitor_as_EventsProvider(&this_arg_conv);
21573         return (uint64_t)ret_ret;
21574 }
21575
21576 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21577         LDKChannelMonitorUpdate this_obj_conv;
21578         this_obj_conv.inner = (void*)(this_obj & (~1));
21579         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21580         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21581         ChannelMonitorUpdate_free(this_obj_conv);
21582 }
21583
21584 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1get_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
21585         LDKChannelMonitorUpdate this_ptr_conv;
21586         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21587         this_ptr_conv.is_owned = false;
21588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21589         int64_t ret_val = ChannelMonitorUpdate_get_update_id(&this_ptr_conv);
21590         return ret_val;
21591 }
21592
21593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1set_1update_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
21594         LDKChannelMonitorUpdate this_ptr_conv;
21595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21596         this_ptr_conv.is_owned = false;
21597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21598         ChannelMonitorUpdate_set_update_id(&this_ptr_conv, val);
21599 }
21600
21601 static inline uint64_t ChannelMonitorUpdate_clone_ptr(LDKChannelMonitorUpdate *NONNULL_PTR arg) {
21602         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(arg);
21603 uint64_t ret_ref = 0;
21604 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21605 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21606 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21607 ret_ref = (uint64_t)ret_var.inner;
21608 if (ret_var.is_owned) {
21609         ret_ref |= 1;
21610 }
21611         return ret_ref;
21612 }
21613 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21614         LDKChannelMonitorUpdate arg_conv;
21615         arg_conv.inner = (void*)(arg & (~1));
21616         arg_conv.is_owned = false;
21617         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21618         int64_t ret_val = ChannelMonitorUpdate_clone_ptr(&arg_conv);
21619         return ret_val;
21620 }
21621
21622 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21623         LDKChannelMonitorUpdate orig_conv;
21624         orig_conv.inner = (void*)(orig & (~1));
21625         orig_conv.is_owned = false;
21626         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21627         LDKChannelMonitorUpdate ret_var = ChannelMonitorUpdate_clone(&orig_conv);
21628         uint64_t ret_ref = 0;
21629         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21630         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21631         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21632         ret_ref = (uint64_t)ret_var.inner;
21633         if (ret_var.is_owned) {
21634                 ret_ref |= 1;
21635         }
21636         return ret_ref;
21637 }
21638
21639 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21640         LDKChannelMonitorUpdate obj_conv;
21641         obj_conv.inner = (void*)(obj & (~1));
21642         obj_conv.is_owned = false;
21643         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21644         LDKCVec_u8Z ret_var = ChannelMonitorUpdate_write(&obj_conv);
21645         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21646         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21647         CVec_u8Z_free(ret_var);
21648         return ret_arr;
21649 }
21650
21651 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitorUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21652         LDKu8slice ser_ref;
21653         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21654         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21655         LDKCResult_ChannelMonitorUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelMonitorUpdateDecodeErrorZ), "LDKCResult_ChannelMonitorUpdateDecodeErrorZ");
21656         *ret_conv = ChannelMonitorUpdate_read(ser_ref);
21657         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21658         return (uint64_t)ret_conv;
21659 }
21660
21661 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21662         LDKMonitorUpdateError this_obj_conv;
21663         this_obj_conv.inner = (void*)(this_obj & (~1));
21664         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21665         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21666         MonitorUpdateError_free(this_obj_conv);
21667 }
21668
21669 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
21670         LDKMonitorUpdateError this_ptr_conv;
21671         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21672         this_ptr_conv.is_owned = false;
21673         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21674         LDKStr ret_str = MonitorUpdateError_get_a(&this_ptr_conv);
21675         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
21676         Str_free(ret_str);
21677         return ret_conv;
21678 }
21679
21680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
21681         LDKMonitorUpdateError this_ptr_conv;
21682         this_ptr_conv.inner = (void*)(this_ptr & (~1));
21683         this_ptr_conv.is_owned = false;
21684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
21685         LDKStr val_conv = java_to_owned_str(env, val);
21686         MonitorUpdateError_set_a(&this_ptr_conv, val_conv);
21687 }
21688
21689 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1new(JNIEnv *env, jclass clz, jstring a_arg) {
21690         LDKStr a_arg_conv = java_to_owned_str(env, a_arg);
21691         LDKMonitorUpdateError ret_var = MonitorUpdateError_new(a_arg_conv);
21692         uint64_t ret_ref = 0;
21693         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21694         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21695         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21696         ret_ref = (uint64_t)ret_var.inner;
21697         if (ret_var.is_owned) {
21698                 ret_ref |= 1;
21699         }
21700         return ret_ref;
21701 }
21702
21703 static inline uint64_t MonitorUpdateError_clone_ptr(LDKMonitorUpdateError *NONNULL_PTR arg) {
21704         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(arg);
21705 uint64_t ret_ref = 0;
21706 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21707 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21708 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21709 ret_ref = (uint64_t)ret_var.inner;
21710 if (ret_var.is_owned) {
21711         ret_ref |= 1;
21712 }
21713         return ret_ref;
21714 }
21715 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21716         LDKMonitorUpdateError arg_conv;
21717         arg_conv.inner = (void*)(arg & (~1));
21718         arg_conv.is_owned = false;
21719         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21720         int64_t ret_val = MonitorUpdateError_clone_ptr(&arg_conv);
21721         return ret_val;
21722 }
21723
21724 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorUpdateError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21725         LDKMonitorUpdateError orig_conv;
21726         orig_conv.inner = (void*)(orig & (~1));
21727         orig_conv.is_owned = false;
21728         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21729         LDKMonitorUpdateError ret_var = MonitorUpdateError_clone(&orig_conv);
21730         uint64_t ret_ref = 0;
21731         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21732         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21733         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21734         ret_ref = (uint64_t)ret_var.inner;
21735         if (ret_var.is_owned) {
21736                 ret_ref |= 1;
21737         }
21738         return ret_ref;
21739 }
21740
21741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21742         if ((this_ptr & 1) != 0) return;
21743         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21744         CHECK_ACCESS(this_ptr_ptr);
21745         LDKMonitorEvent this_ptr_conv = *(LDKMonitorEvent*)(this_ptr_ptr);
21746         FREE((void*)this_ptr);
21747         MonitorEvent_free(this_ptr_conv);
21748 }
21749
21750 static inline uint64_t MonitorEvent_clone_ptr(LDKMonitorEvent *NONNULL_PTR arg) {
21751         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21752         *ret_copy = MonitorEvent_clone(arg);
21753 uint64_t ret_ref = (uint64_t)ret_copy;
21754         return ret_ref;
21755 }
21756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21757         LDKMonitorEvent* arg_conv = (LDKMonitorEvent*)arg;
21758         int64_t ret_val = MonitorEvent_clone_ptr(arg_conv);
21759         return ret_val;
21760 }
21761
21762 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21763         LDKMonitorEvent* orig_conv = (LDKMonitorEvent*)orig;
21764         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21765         *ret_copy = MonitorEvent_clone(orig_conv);
21766         uint64_t ret_ref = (uint64_t)ret_copy;
21767         return ret_ref;
21768 }
21769
21770 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1htlcevent(JNIEnv *env, jclass clz, int64_t a) {
21771         LDKHTLCUpdate a_conv;
21772         a_conv.inner = (void*)(a & (~1));
21773         a_conv.is_owned = (a & 1) || (a == 0);
21774         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21775         a_conv = HTLCUpdate_clone(&a_conv);
21776         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21777         *ret_copy = MonitorEvent_htlcevent(a_conv);
21778         uint64_t ret_ref = (uint64_t)ret_copy;
21779         return ret_ref;
21780 }
21781
21782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1commitment_1tx_1confirmed(JNIEnv *env, jclass clz, int64_t a) {
21783         LDKOutPoint a_conv;
21784         a_conv.inner = (void*)(a & (~1));
21785         a_conv.is_owned = (a & 1) || (a == 0);
21786         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21787         a_conv = OutPoint_clone(&a_conv);
21788         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21789         *ret_copy = MonitorEvent_commitment_tx_confirmed(a_conv);
21790         uint64_t ret_ref = (uint64_t)ret_copy;
21791         return ret_ref;
21792 }
21793
21794 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) {
21795         LDKOutPoint funding_txo_conv;
21796         funding_txo_conv.inner = (void*)(funding_txo & (~1));
21797         funding_txo_conv.is_owned = (funding_txo & 1) || (funding_txo == 0);
21798         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_conv);
21799         funding_txo_conv = OutPoint_clone(&funding_txo_conv);
21800         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21801         *ret_copy = MonitorEvent_update_completed(funding_txo_conv, monitor_update_id);
21802         uint64_t ret_ref = (uint64_t)ret_copy;
21803         return ret_ref;
21804 }
21805
21806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1update_1failed(JNIEnv *env, jclass clz, int64_t a) {
21807         LDKOutPoint a_conv;
21808         a_conv.inner = (void*)(a & (~1));
21809         a_conv.is_owned = (a & 1) || (a == 0);
21810         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
21811         a_conv = OutPoint_clone(&a_conv);
21812         LDKMonitorEvent *ret_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
21813         *ret_copy = MonitorEvent_update_failed(a_conv);
21814         uint64_t ret_ref = (uint64_t)ret_copy;
21815         return ret_ref;
21816 }
21817
21818 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1write(JNIEnv *env, jclass clz, int64_t obj) {
21819         LDKMonitorEvent* obj_conv = (LDKMonitorEvent*)obj;
21820         LDKCVec_u8Z ret_var = MonitorEvent_write(obj_conv);
21821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21823         CVec_u8Z_free(ret_var);
21824         return ret_arr;
21825 }
21826
21827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MonitorEvent_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21828         LDKu8slice ser_ref;
21829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21831         LDKCResult_COption_MonitorEventZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_MonitorEventZDecodeErrorZ), "LDKCResult_COption_MonitorEventZDecodeErrorZ");
21832         *ret_conv = MonitorEvent_read(ser_ref);
21833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21834         return (uint64_t)ret_conv;
21835 }
21836
21837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21838         LDKHTLCUpdate this_obj_conv;
21839         this_obj_conv.inner = (void*)(this_obj & (~1));
21840         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21842         HTLCUpdate_free(this_obj_conv);
21843 }
21844
21845 static inline uint64_t HTLCUpdate_clone_ptr(LDKHTLCUpdate *NONNULL_PTR arg) {
21846         LDKHTLCUpdate ret_var = HTLCUpdate_clone(arg);
21847 uint64_t ret_ref = 0;
21848 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21849 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21850 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21851 ret_ref = (uint64_t)ret_var.inner;
21852 if (ret_var.is_owned) {
21853         ret_ref |= 1;
21854 }
21855         return ret_ref;
21856 }
21857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21858         LDKHTLCUpdate arg_conv;
21859         arg_conv.inner = (void*)(arg & (~1));
21860         arg_conv.is_owned = false;
21861         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21862         int64_t ret_val = HTLCUpdate_clone_ptr(&arg_conv);
21863         return ret_val;
21864 }
21865
21866 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21867         LDKHTLCUpdate orig_conv;
21868         orig_conv.inner = (void*)(orig & (~1));
21869         orig_conv.is_owned = false;
21870         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
21871         LDKHTLCUpdate ret_var = HTLCUpdate_clone(&orig_conv);
21872         uint64_t ret_ref = 0;
21873         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21874         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21875         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21876         ret_ref = (uint64_t)ret_var.inner;
21877         if (ret_var.is_owned) {
21878                 ret_ref |= 1;
21879         }
21880         return ret_ref;
21881 }
21882
21883 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
21884         LDKHTLCUpdate obj_conv;
21885         obj_conv.inner = (void*)(obj & (~1));
21886         obj_conv.is_owned = false;
21887         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
21888         LDKCVec_u8Z ret_var = HTLCUpdate_write(&obj_conv);
21889         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
21890         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
21891         CVec_u8Z_free(ret_var);
21892         return ret_arr;
21893 }
21894
21895 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
21896         LDKu8slice ser_ref;
21897         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
21898         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
21899         LDKCResult_HTLCUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCUpdateDecodeErrorZ), "LDKCResult_HTLCUpdateDecodeErrorZ");
21900         *ret_conv = HTLCUpdate_read(ser_ref);
21901         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
21902         return (uint64_t)ret_conv;
21903 }
21904
21905 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Balance_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
21906         if ((this_ptr & 1) != 0) return;
21907         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
21908         CHECK_ACCESS(this_ptr_ptr);
21909         LDKBalance this_ptr_conv = *(LDKBalance*)(this_ptr_ptr);
21910         FREE((void*)this_ptr);
21911         Balance_free(this_ptr_conv);
21912 }
21913
21914 static inline uint64_t Balance_clone_ptr(LDKBalance *NONNULL_PTR arg) {
21915         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21916         *ret_copy = Balance_clone(arg);
21917 uint64_t ret_ref = (uint64_t)ret_copy;
21918         return ret_ref;
21919 }
21920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21921         LDKBalance* arg_conv = (LDKBalance*)arg;
21922         int64_t ret_val = Balance_clone_ptr(arg_conv);
21923         return ret_val;
21924 }
21925
21926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21927         LDKBalance* orig_conv = (LDKBalance*)orig;
21928         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21929         *ret_copy = Balance_clone(orig_conv);
21930         uint64_t ret_ref = (uint64_t)ret_copy;
21931         return ret_ref;
21932 }
21933
21934 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Balance_1claimable_1on_1channel_1close(JNIEnv *env, jclass clz, int64_t claimable_amount_satoshis) {
21935         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21936         *ret_copy = Balance_claimable_on_channel_close(claimable_amount_satoshis);
21937         uint64_t ret_ref = (uint64_t)ret_copy;
21938         return ret_ref;
21939 }
21940
21941 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) {
21942         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21943         *ret_copy = Balance_claimable_awaiting_confirmations(claimable_amount_satoshis, confirmation_height);
21944         uint64_t ret_ref = (uint64_t)ret_copy;
21945         return ret_ref;
21946 }
21947
21948 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) {
21949         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21950         *ret_copy = Balance_contentious_claimable(claimable_amount_satoshis, timeout_height);
21951         uint64_t ret_ref = (uint64_t)ret_copy;
21952         return ret_ref;
21953 }
21954
21955 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) {
21956         LDKBalance *ret_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
21957         *ret_copy = Balance_maybe_claimable_htlcawaiting_timeout(claimable_amount_satoshis, claimable_height);
21958         uint64_t ret_ref = (uint64_t)ret_copy;
21959         return ret_ref;
21960 }
21961
21962 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Balance_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
21963         LDKBalance* a_conv = (LDKBalance*)a;
21964         LDKBalance* b_conv = (LDKBalance*)b;
21965         jboolean ret_val = Balance_eq(a_conv, b_conv);
21966         return ret_val;
21967 }
21968
21969 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
21970         LDKChannelMonitor this_obj_conv;
21971         this_obj_conv.inner = (void*)(this_obj & (~1));
21972         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
21973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
21974         ChannelMonitor_free(this_obj_conv);
21975 }
21976
21977 static inline uint64_t ChannelMonitor_clone_ptr(LDKChannelMonitor *NONNULL_PTR arg) {
21978         LDKChannelMonitor ret_var = ChannelMonitor_clone(arg);
21979 uint64_t ret_ref = 0;
21980 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
21981 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
21982 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
21983 ret_ref = (uint64_t)ret_var.inner;
21984 if (ret_var.is_owned) {
21985         ret_ref |= 1;
21986 }
21987         return ret_ref;
21988 }
21989 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
21990         LDKChannelMonitor arg_conv;
21991         arg_conv.inner = (void*)(arg & (~1));
21992         arg_conv.is_owned = false;
21993         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
21994         int64_t ret_val = ChannelMonitor_clone_ptr(&arg_conv);
21995         return ret_val;
21996 }
21997
21998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
21999         LDKChannelMonitor orig_conv;
22000         orig_conv.inner = (void*)(orig & (~1));
22001         orig_conv.is_owned = false;
22002         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22003         LDKChannelMonitor ret_var = ChannelMonitor_clone(&orig_conv);
22004         uint64_t ret_ref = 0;
22005         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22006         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22008         ret_ref = (uint64_t)ret_var.inner;
22009         if (ret_var.is_owned) {
22010                 ret_ref |= 1;
22011         }
22012         return ret_ref;
22013 }
22014
22015 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1write(JNIEnv *env, jclass clz, int64_t obj) {
22016         LDKChannelMonitor obj_conv;
22017         obj_conv.inner = (void*)(obj & (~1));
22018         obj_conv.is_owned = false;
22019         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22020         LDKCVec_u8Z ret_var = ChannelMonitor_write(&obj_conv);
22021         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22022         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22023         CVec_u8Z_free(ret_var);
22024         return ret_arr;
22025 }
22026
22027 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) {
22028         LDKChannelMonitor this_arg_conv;
22029         this_arg_conv.inner = (void*)(this_arg & (~1));
22030         this_arg_conv.is_owned = false;
22031         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22032         LDKChannelMonitorUpdate updates_conv;
22033         updates_conv.inner = (void*)(updates & (~1));
22034         updates_conv.is_owned = false;
22035         CHECK_INNER_FIELD_ACCESS_OR_NULL(updates_conv);
22036         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22037         if (!(broadcaster & 1)) { CHECK_ACCESS(broadcaster_ptr); }
22038         LDKBroadcasterInterface* broadcaster_conv = (LDKBroadcasterInterface*)broadcaster_ptr;
22039         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22040         if (!(fee_estimator & 1)) { CHECK_ACCESS(fee_estimator_ptr); }
22041         LDKFeeEstimator* fee_estimator_conv = (LDKFeeEstimator*)fee_estimator_ptr;
22042         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22043         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22044         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22045         LDKCResult_NoneMonitorUpdateErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneMonitorUpdateErrorZ), "LDKCResult_NoneMonitorUpdateErrorZ");
22046         *ret_conv = ChannelMonitor_update_monitor(&this_arg_conv, &updates_conv, broadcaster_conv, fee_estimator_conv, logger_conv);
22047         return (uint64_t)ret_conv;
22048 }
22049
22050 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1latest_1update_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
22051         LDKChannelMonitor this_arg_conv;
22052         this_arg_conv.inner = (void*)(this_arg & (~1));
22053         this_arg_conv.is_owned = false;
22054         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22055         int64_t ret_val = ChannelMonitor_get_latest_update_id(&this_arg_conv);
22056         return ret_val;
22057 }
22058
22059 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_arg) {
22060         LDKChannelMonitor this_arg_conv;
22061         this_arg_conv.inner = (void*)(this_arg & (~1));
22062         this_arg_conv.is_owned = false;
22063         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22064         LDKC2Tuple_OutPointScriptZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_OutPointScriptZ), "LDKC2Tuple_OutPointScriptZ");
22065         *ret_conv = ChannelMonitor_get_funding_txo(&this_arg_conv);
22066         return ((uint64_t)ret_conv);
22067 }
22068
22069 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg) {
22070         LDKChannelMonitor this_arg_conv;
22071         this_arg_conv.inner = (void*)(this_arg & (~1));
22072         this_arg_conv.is_owned = false;
22073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22074         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32ScriptZZZZ ret_var = ChannelMonitor_get_outputs_to_watch(&this_arg_conv);
22075         int64_tArray ret_arr = NULL;
22076         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22077         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22078         for (size_t o = 0; o < ret_var.datalen; o++) {
22079                 LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ* ret_conv_40_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32ScriptZZZ");
22080                 *ret_conv_40_conv = ret_var.data[o];
22081                 ret_arr_ptr[o] = ((uint64_t)ret_conv_40_conv);
22082         }
22083         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22084         FREE(ret_var.data);
22085         return ret_arr;
22086 }
22087
22088 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1load_1outputs_1to_1watch(JNIEnv *env, jclass clz, int64_t this_arg, int64_t filter) {
22089         LDKChannelMonitor this_arg_conv;
22090         this_arg_conv.inner = (void*)(this_arg & (~1));
22091         this_arg_conv.is_owned = false;
22092         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22093         void* filter_ptr = (void*)(((uint64_t)filter) & ~1);
22094         if (!(filter & 1)) { CHECK_ACCESS(filter_ptr); }
22095         LDKFilter* filter_conv = (LDKFilter*)filter_ptr;
22096         ChannelMonitor_load_outputs_to_watch(&this_arg_conv, filter_conv);
22097 }
22098
22099 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1monitor_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22100         LDKChannelMonitor this_arg_conv;
22101         this_arg_conv.inner = (void*)(this_arg & (~1));
22102         this_arg_conv.is_owned = false;
22103         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22104         LDKCVec_MonitorEventZ ret_var = ChannelMonitor_get_and_clear_pending_monitor_events(&this_arg_conv);
22105         int64_tArray ret_arr = NULL;
22106         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22107         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22108         for (size_t o = 0; o < ret_var.datalen; o++) {
22109                 LDKMonitorEvent *ret_conv_14_copy = MALLOC(sizeof(LDKMonitorEvent), "LDKMonitorEvent");
22110                 *ret_conv_14_copy = ret_var.data[o];
22111                 uint64_t ret_conv_14_ref = (uint64_t)ret_conv_14_copy;
22112                 ret_arr_ptr[o] = ret_conv_14_ref;
22113         }
22114         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22115         FREE(ret_var.data);
22116         return ret_arr;
22117 }
22118
22119 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1and_1clear_1pending_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
22120         LDKChannelMonitor this_arg_conv;
22121         this_arg_conv.inner = (void*)(this_arg & (~1));
22122         this_arg_conv.is_owned = false;
22123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22124         LDKCVec_EventZ ret_var = ChannelMonitor_get_and_clear_pending_events(&this_arg_conv);
22125         int64_tArray ret_arr = NULL;
22126         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22127         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22128         for (size_t h = 0; h < ret_var.datalen; h++) {
22129                 LDKEvent *ret_conv_7_copy = MALLOC(sizeof(LDKEvent), "LDKEvent");
22130                 *ret_conv_7_copy = ret_var.data[h];
22131                 uint64_t ret_conv_7_ref = (uint64_t)ret_conv_7_copy;
22132                 ret_arr_ptr[h] = ret_conv_7_ref;
22133         }
22134         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22135         FREE(ret_var.data);
22136         return ret_arr;
22137 }
22138
22139 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) {
22140         LDKChannelMonitor this_arg_conv;
22141         this_arg_conv.inner = (void*)(this_arg & (~1));
22142         this_arg_conv.is_owned = false;
22143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22144         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22145         if (!(logger & 1)) { CHECK_ACCESS(logger_ptr); }
22146         LDKLogger* logger_conv = (LDKLogger*)logger_ptr;
22147         LDKCVec_TransactionZ ret_var = ChannelMonitor_get_latest_holder_commitment_txn(&this_arg_conv, logger_conv);
22148         jobjectArray ret_arr = NULL;
22149         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22150         ;
22151         for (size_t i = 0; i < ret_var.datalen; i++) {
22152                 LDKTransaction ret_conv_8_var = ret_var.data[i];
22153                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, ret_conv_8_var.datalen);
22154                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, ret_conv_8_var.datalen, ret_conv_8_var.data);
22155                 Transaction_free(ret_conv_8_var);
22156                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22157         }
22158         
22159         FREE(ret_var.data);
22160         return ret_arr;
22161 }
22162
22163 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) {
22164         LDKChannelMonitor this_arg_conv;
22165         this_arg_conv.inner = (void*)(this_arg & (~1));
22166         this_arg_conv.is_owned = false;
22167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22168         unsigned char header_arr[80];
22169         CHECK((*env)->GetArrayLength(env, header) == 80);
22170         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22171         unsigned char (*header_ref)[80] = &header_arr;
22172         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22173         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
22174         if (txdata_constr.datalen > 0)
22175                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22176         else
22177                 txdata_constr.data = NULL;
22178         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
22179         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22180                 int64_t txdata_conv_28 = txdata_vals[c];
22181                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
22182                 CHECK_ACCESS(txdata_conv_28_ptr);
22183                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22184                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
22185                 txdata_constr.data[c] = txdata_conv_28_conv;
22186         }
22187         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
22188         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22189         CHECK_ACCESS(broadcaster_ptr);
22190         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22191         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22192                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22193                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22194         }
22195         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22196         CHECK_ACCESS(fee_estimator_ptr);
22197         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22198         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22199                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22200                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22201         }
22202         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22203         CHECK_ACCESS(logger_ptr);
22204         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22205         if (logger_conv.free == LDKLogger_JCalls_free) {
22206                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22207                 LDKLogger_JCalls_cloned(&logger_conv);
22208         }
22209         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);
22210         int64_tArray ret_arr = NULL;
22211         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22212         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22213         for (size_t n = 0; n < ret_var.datalen; n++) {
22214                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22215                 *ret_conv_39_conv = ret_var.data[n];
22216                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
22217         }
22218         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22219         FREE(ret_var.data);
22220         return ret_arr;
22221 }
22222
22223 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) {
22224         LDKChannelMonitor this_arg_conv;
22225         this_arg_conv.inner = (void*)(this_arg & (~1));
22226         this_arg_conv.is_owned = false;
22227         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22228         unsigned char header_arr[80];
22229         CHECK((*env)->GetArrayLength(env, header) == 80);
22230         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22231         unsigned char (*header_ref)[80] = &header_arr;
22232         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22233         CHECK_ACCESS(broadcaster_ptr);
22234         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22235         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22236                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22237                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22238         }
22239         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22240         CHECK_ACCESS(fee_estimator_ptr);
22241         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22242         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22243                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22244                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22245         }
22246         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22247         CHECK_ACCESS(logger_ptr);
22248         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22249         if (logger_conv.free == LDKLogger_JCalls_free) {
22250                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22251                 LDKLogger_JCalls_cloned(&logger_conv);
22252         }
22253         ChannelMonitor_block_disconnected(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22254 }
22255
22256 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) {
22257         LDKChannelMonitor this_arg_conv;
22258         this_arg_conv.inner = (void*)(this_arg & (~1));
22259         this_arg_conv.is_owned = false;
22260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22261         unsigned char header_arr[80];
22262         CHECK((*env)->GetArrayLength(env, header) == 80);
22263         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22264         unsigned char (*header_ref)[80] = &header_arr;
22265         LDKCVec_C2Tuple_usizeTransactionZZ txdata_constr;
22266         txdata_constr.datalen = (*env)->GetArrayLength(env, txdata);
22267         if (txdata_constr.datalen > 0)
22268                 txdata_constr.data = MALLOC(txdata_constr.datalen * sizeof(LDKC2Tuple_usizeTransactionZ), "LDKCVec_C2Tuple_usizeTransactionZZ Elements");
22269         else
22270                 txdata_constr.data = NULL;
22271         int64_t* txdata_vals = (*env)->GetLongArrayElements (env, txdata, NULL);
22272         for (size_t c = 0; c < txdata_constr.datalen; c++) {
22273                 int64_t txdata_conv_28 = txdata_vals[c];
22274                 void* txdata_conv_28_ptr = (void*)(((uint64_t)txdata_conv_28) & ~1);
22275                 CHECK_ACCESS(txdata_conv_28_ptr);
22276                 LDKC2Tuple_usizeTransactionZ txdata_conv_28_conv = *(LDKC2Tuple_usizeTransactionZ*)(txdata_conv_28_ptr);
22277                 txdata_conv_28_conv = C2Tuple_usizeTransactionZ_clone((LDKC2Tuple_usizeTransactionZ*)(((uint64_t)txdata_conv_28) & ~1));
22278                 txdata_constr.data[c] = txdata_conv_28_conv;
22279         }
22280         (*env)->ReleaseLongArrayElements(env, txdata, txdata_vals, 0);
22281         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22282         CHECK_ACCESS(broadcaster_ptr);
22283         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22284         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22285                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22286                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22287         }
22288         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22289         CHECK_ACCESS(fee_estimator_ptr);
22290         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22291         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22292                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22293                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22294         }
22295         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22296         CHECK_ACCESS(logger_ptr);
22297         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22298         if (logger_conv.free == LDKLogger_JCalls_free) {
22299                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22300                 LDKLogger_JCalls_cloned(&logger_conv);
22301         }
22302         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);
22303         int64_tArray ret_arr = NULL;
22304         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22305         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22306         for (size_t n = 0; n < ret_var.datalen; n++) {
22307                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22308                 *ret_conv_39_conv = ret_var.data[n];
22309                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
22310         }
22311         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22312         FREE(ret_var.data);
22313         return ret_arr;
22314 }
22315
22316 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) {
22317         LDKChannelMonitor this_arg_conv;
22318         this_arg_conv.inner = (void*)(this_arg & (~1));
22319         this_arg_conv.is_owned = false;
22320         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22321         unsigned char txid_arr[32];
22322         CHECK((*env)->GetArrayLength(env, txid) == 32);
22323         (*env)->GetByteArrayRegion(env, txid, 0, 32, txid_arr);
22324         unsigned char (*txid_ref)[32] = &txid_arr;
22325         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22326         CHECK_ACCESS(broadcaster_ptr);
22327         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22328         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22329                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22330                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22331         }
22332         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22333         CHECK_ACCESS(fee_estimator_ptr);
22334         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22335         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22336                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22337                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22338         }
22339         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22340         CHECK_ACCESS(logger_ptr);
22341         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22342         if (logger_conv.free == LDKLogger_JCalls_free) {
22343                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22344                 LDKLogger_JCalls_cloned(&logger_conv);
22345         }
22346         ChannelMonitor_transaction_unconfirmed(&this_arg_conv, txid_ref, broadcaster_conv, fee_estimator_conv, logger_conv);
22347 }
22348
22349 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) {
22350         LDKChannelMonitor this_arg_conv;
22351         this_arg_conv.inner = (void*)(this_arg & (~1));
22352         this_arg_conv.is_owned = false;
22353         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22354         unsigned char header_arr[80];
22355         CHECK((*env)->GetArrayLength(env, header) == 80);
22356         (*env)->GetByteArrayRegion(env, header, 0, 80, header_arr);
22357         unsigned char (*header_ref)[80] = &header_arr;
22358         void* broadcaster_ptr = (void*)(((uint64_t)broadcaster) & ~1);
22359         CHECK_ACCESS(broadcaster_ptr);
22360         LDKBroadcasterInterface broadcaster_conv = *(LDKBroadcasterInterface*)(broadcaster_ptr);
22361         if (broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
22362                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22363                 LDKBroadcasterInterface_JCalls_cloned(&broadcaster_conv);
22364         }
22365         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
22366         CHECK_ACCESS(fee_estimator_ptr);
22367         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
22368         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
22369                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22370                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
22371         }
22372         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
22373         CHECK_ACCESS(logger_ptr);
22374         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
22375         if (logger_conv.free == LDKLogger_JCalls_free) {
22376                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
22377                 LDKLogger_JCalls_cloned(&logger_conv);
22378         }
22379         LDKCVec_C2Tuple_TxidCVec_C2Tuple_u32TxOutZZZZ ret_var = ChannelMonitor_best_block_updated(&this_arg_conv, header_ref, height, broadcaster_conv, fee_estimator_conv, logger_conv);
22380         int64_tArray ret_arr = NULL;
22381         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22382         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22383         for (size_t n = 0; n < ret_var.datalen; n++) {
22384                 LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ* ret_conv_39_conv = MALLOC(sizeof(LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ), "LDKC2Tuple_TxidCVec_C2Tuple_u32TxOutZZZ");
22385                 *ret_conv_39_conv = ret_var.data[n];
22386                 ret_arr_ptr[n] = ((uint64_t)ret_conv_39_conv);
22387         }
22388         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22389         FREE(ret_var.data);
22390         return ret_arr;
22391 }
22392
22393 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1relevant_1txids(JNIEnv *env, jclass clz, int64_t this_arg) {
22394         LDKChannelMonitor this_arg_conv;
22395         this_arg_conv.inner = (void*)(this_arg & (~1));
22396         this_arg_conv.is_owned = false;
22397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22398         LDKCVec_TxidZ ret_var = ChannelMonitor_get_relevant_txids(&this_arg_conv);
22399         jobjectArray ret_arr = NULL;
22400         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
22401         ;
22402         for (size_t i = 0; i < ret_var.datalen; i++) {
22403                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 32);
22404                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 32, ret_var.data[i].data);
22405                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
22406         }
22407         
22408         FREE(ret_var.data);
22409         return ret_arr;
22410 }
22411
22412 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
22413         LDKChannelMonitor this_arg_conv;
22414         this_arg_conv.inner = (void*)(this_arg & (~1));
22415         this_arg_conv.is_owned = false;
22416         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22417         LDKBestBlock ret_var = ChannelMonitor_current_best_block(&this_arg_conv);
22418         uint64_t ret_ref = 0;
22419         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22420         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22421         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22422         ret_ref = (uint64_t)ret_var.inner;
22423         if (ret_var.is_owned) {
22424                 ret_ref |= 1;
22425         }
22426         return ret_ref;
22427 }
22428
22429 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelMonitor_1get_1claimable_1balances(JNIEnv *env, jclass clz, int64_t this_arg) {
22430         LDKChannelMonitor this_arg_conv;
22431         this_arg_conv.inner = (void*)(this_arg & (~1));
22432         this_arg_conv.is_owned = false;
22433         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22434         LDKCVec_BalanceZ ret_var = ChannelMonitor_get_claimable_balances(&this_arg_conv);
22435         int64_tArray ret_arr = NULL;
22436         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
22437         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
22438         for (size_t j = 0; j < ret_var.datalen; j++) {
22439                 LDKBalance *ret_conv_9_copy = MALLOC(sizeof(LDKBalance), "LDKBalance");
22440                 *ret_conv_9_copy = ret_var.data[j];
22441                 uint64_t ret_conv_9_ref = (uint64_t)ret_conv_9_copy;
22442                 ret_arr_ptr[j] = ret_conv_9_ref;
22443         }
22444         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
22445         FREE(ret_var.data);
22446         return ret_arr;
22447 }
22448
22449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelMonitorZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
22450         LDKu8slice ser_ref;
22451         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22452         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22453         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
22454         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
22455         LDKKeysInterface* arg_conv = (LDKKeysInterface*)arg_ptr;
22456         LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelMonitorZDecodeErrorZ");
22457         *ret_conv = C2Tuple_BlockHashChannelMonitorZ_read(ser_ref, arg_conv);
22458         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22459         return (uint64_t)ret_conv;
22460 }
22461
22462 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22463         LDKOutPoint this_obj_conv;
22464         this_obj_conv.inner = (void*)(this_obj & (~1));
22465         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22466         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22467         OutPoint_free(this_obj_conv);
22468 }
22469
22470 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
22471         LDKOutPoint this_ptr_conv;
22472         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22473         this_ptr_conv.is_owned = false;
22474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22475         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22476         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OutPoint_get_txid(&this_ptr_conv));
22477         return ret_arr;
22478 }
22479
22480 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22481         LDKOutPoint this_ptr_conv;
22482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22483         this_ptr_conv.is_owned = false;
22484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22485         LDKThirtyTwoBytes val_ref;
22486         CHECK((*env)->GetArrayLength(env, val) == 32);
22487         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22488         OutPoint_set_txid(&this_ptr_conv, val_ref);
22489 }
22490
22491 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1get_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
22492         LDKOutPoint this_ptr_conv;
22493         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22494         this_ptr_conv.is_owned = false;
22495         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22496         int16_t ret_val = OutPoint_get_index(&this_ptr_conv);
22497         return ret_val;
22498 }
22499
22500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OutPoint_1set_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22501         LDKOutPoint this_ptr_conv;
22502         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22503         this_ptr_conv.is_owned = false;
22504         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22505         OutPoint_set_index(&this_ptr_conv, val);
22506 }
22507
22508 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1new(JNIEnv *env, jclass clz, int8_tArray txid_arg, int16_t index_arg) {
22509         LDKThirtyTwoBytes txid_arg_ref;
22510         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
22511         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
22512         LDKOutPoint ret_var = OutPoint_new(txid_arg_ref, index_arg);
22513         uint64_t ret_ref = 0;
22514         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22515         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22516         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22517         ret_ref = (uint64_t)ret_var.inner;
22518         if (ret_var.is_owned) {
22519                 ret_ref |= 1;
22520         }
22521         return ret_ref;
22522 }
22523
22524 static inline uint64_t OutPoint_clone_ptr(LDKOutPoint *NONNULL_PTR arg) {
22525         LDKOutPoint ret_var = OutPoint_clone(arg);
22526 uint64_t ret_ref = 0;
22527 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22528 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22529 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22530 ret_ref = (uint64_t)ret_var.inner;
22531 if (ret_var.is_owned) {
22532         ret_ref |= 1;
22533 }
22534         return ret_ref;
22535 }
22536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22537         LDKOutPoint arg_conv;
22538         arg_conv.inner = (void*)(arg & (~1));
22539         arg_conv.is_owned = false;
22540         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22541         int64_t ret_val = OutPoint_clone_ptr(&arg_conv);
22542         return ret_val;
22543 }
22544
22545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22546         LDKOutPoint orig_conv;
22547         orig_conv.inner = (void*)(orig & (~1));
22548         orig_conv.is_owned = false;
22549         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22550         LDKOutPoint ret_var = OutPoint_clone(&orig_conv);
22551         uint64_t ret_ref = 0;
22552         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22553         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22554         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22555         ret_ref = (uint64_t)ret_var.inner;
22556         if (ret_var.is_owned) {
22557                 ret_ref |= 1;
22558         }
22559         return ret_ref;
22560 }
22561
22562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_OutPoint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
22563         LDKOutPoint a_conv;
22564         a_conv.inner = (void*)(a & (~1));
22565         a_conv.is_owned = false;
22566         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
22567         LDKOutPoint b_conv;
22568         b_conv.inner = (void*)(b & (~1));
22569         b_conv.is_owned = false;
22570         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
22571         jboolean ret_val = OutPoint_eq(&a_conv, &b_conv);
22572         return ret_val;
22573 }
22574
22575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1hash(JNIEnv *env, jclass clz, int64_t o) {
22576         LDKOutPoint o_conv;
22577         o_conv.inner = (void*)(o & (~1));
22578         o_conv.is_owned = false;
22579         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
22580         int64_t ret_val = OutPoint_hash(&o_conv);
22581         return ret_val;
22582 }
22583
22584 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1to_1channel_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
22585         LDKOutPoint this_arg_conv;
22586         this_arg_conv.inner = (void*)(this_arg & (~1));
22587         this_arg_conv.is_owned = false;
22588         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
22589         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22590         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, OutPoint_to_channel_id(&this_arg_conv).data);
22591         return ret_arr;
22592 }
22593
22594 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OutPoint_1write(JNIEnv *env, jclass clz, int64_t obj) {
22595         LDKOutPoint obj_conv;
22596         obj_conv.inner = (void*)(obj & (~1));
22597         obj_conv.is_owned = false;
22598         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22599         LDKCVec_u8Z ret_var = OutPoint_write(&obj_conv);
22600         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22601         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22602         CVec_u8Z_free(ret_var);
22603         return ret_arr;
22604 }
22605
22606 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OutPoint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22607         LDKu8slice ser_ref;
22608         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22609         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22610         LDKCResult_OutPointDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OutPointDecodeErrorZ), "LDKCResult_OutPointDecodeErrorZ");
22611         *ret_conv = OutPoint_read(ser_ref);
22612         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22613         return (uint64_t)ret_conv;
22614 }
22615
22616 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22617         LDKDelayedPaymentOutputDescriptor this_obj_conv;
22618         this_obj_conv.inner = (void*)(this_obj & (~1));
22619         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22621         DelayedPaymentOutputDescriptor_free(this_obj_conv);
22622 }
22623
22624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22625         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22626         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22627         this_ptr_conv.is_owned = false;
22628         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22629         LDKOutPoint ret_var = DelayedPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22630         uint64_t ret_ref = 0;
22631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22634         ret_ref = (uint64_t)ret_var.inner;
22635         if (ret_var.is_owned) {
22636                 ret_ref |= 1;
22637         }
22638         return ret_ref;
22639 }
22640
22641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22642         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22644         this_ptr_conv.is_owned = false;
22645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22646         LDKOutPoint val_conv;
22647         val_conv.inner = (void*)(val & (~1));
22648         val_conv.is_owned = (val & 1) || (val == 0);
22649         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22650         val_conv = OutPoint_clone(&val_conv);
22651         DelayedPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22652 }
22653
22654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
22655         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22656         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22657         this_ptr_conv.is_owned = false;
22658         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22659         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22660         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_per_commitment_point(&this_ptr_conv).compressed_form);
22661         return ret_arr;
22662 }
22663
22664 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22665         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22667         this_ptr_conv.is_owned = false;
22668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22669         LDKPublicKey val_ref;
22670         CHECK((*env)->GetArrayLength(env, val) == 33);
22671         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22672         DelayedPaymentOutputDescriptor_set_per_commitment_point(&this_ptr_conv, val_ref);
22673 }
22674
22675 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
22676         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22678         this_ptr_conv.is_owned = false;
22679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22680         int16_t ret_val = DelayedPaymentOutputDescriptor_get_to_self_delay(&this_ptr_conv);
22681         return ret_val;
22682 }
22683
22684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
22685         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22687         this_ptr_conv.is_owned = false;
22688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22689         DelayedPaymentOutputDescriptor_set_to_self_delay(&this_ptr_conv, val);
22690 }
22691
22692 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22693         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22695         this_ptr_conv.is_owned = false;
22696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22697         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22698         CHECK_ACCESS(val_ptr);
22699         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22700         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
22701         DelayedPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22702 }
22703
22704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
22705         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22707         this_ptr_conv.is_owned = false;
22708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22709         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
22710         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DelayedPaymentOutputDescriptor_get_revocation_pubkey(&this_ptr_conv).compressed_form);
22711         return ret_arr;
22712 }
22713
22714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1revocation_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22715         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22717         this_ptr_conv.is_owned = false;
22718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22719         LDKPublicKey val_ref;
22720         CHECK((*env)->GetArrayLength(env, val) == 33);
22721         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
22722         DelayedPaymentOutputDescriptor_set_revocation_pubkey(&this_ptr_conv, val_ref);
22723 }
22724
22725 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22726         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22728         this_ptr_conv.is_owned = false;
22729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22730         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22731         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DelayedPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
22732         return ret_arr;
22733 }
22734
22735 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22736         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22737         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22738         this_ptr_conv.is_owned = false;
22739         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22740         LDKThirtyTwoBytes val_ref;
22741         CHECK((*env)->GetArrayLength(env, val) == 32);
22742         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22743         DelayedPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22744 }
22745
22746 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22747         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22748         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22749         this_ptr_conv.is_owned = false;
22750         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22751         int64_t ret_val = DelayedPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22752         return ret_val;
22753 }
22754
22755 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22756         LDKDelayedPaymentOutputDescriptor this_ptr_conv;
22757         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22758         this_ptr_conv.is_owned = false;
22759         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22760         DelayedPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22761 }
22762
22763 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) {
22764         LDKOutPoint outpoint_arg_conv;
22765         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22766         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22767         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22768         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22769         LDKPublicKey per_commitment_point_arg_ref;
22770         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
22771         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
22772         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
22773         CHECK_ACCESS(output_arg_ptr);
22774         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22775         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
22776         LDKPublicKey revocation_pubkey_arg_ref;
22777         CHECK((*env)->GetArrayLength(env, revocation_pubkey_arg) == 33);
22778         (*env)->GetByteArrayRegion(env, revocation_pubkey_arg, 0, 33, revocation_pubkey_arg_ref.compressed_form);
22779         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22780         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
22781         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
22782         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);
22783         uint64_t ret_ref = 0;
22784         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22785         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22786         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22787         ret_ref = (uint64_t)ret_var.inner;
22788         if (ret_var.is_owned) {
22789                 ret_ref |= 1;
22790         }
22791         return ret_ref;
22792 }
22793
22794 static inline uint64_t DelayedPaymentOutputDescriptor_clone_ptr(LDKDelayedPaymentOutputDescriptor *NONNULL_PTR arg) {
22795         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(arg);
22796 uint64_t ret_ref = 0;
22797 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22798 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22799 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22800 ret_ref = (uint64_t)ret_var.inner;
22801 if (ret_var.is_owned) {
22802         ret_ref |= 1;
22803 }
22804         return ret_ref;
22805 }
22806 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22807         LDKDelayedPaymentOutputDescriptor arg_conv;
22808         arg_conv.inner = (void*)(arg & (~1));
22809         arg_conv.is_owned = false;
22810         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22811         int64_t ret_val = DelayedPaymentOutputDescriptor_clone_ptr(&arg_conv);
22812         return ret_val;
22813 }
22814
22815 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22816         LDKDelayedPaymentOutputDescriptor orig_conv;
22817         orig_conv.inner = (void*)(orig & (~1));
22818         orig_conv.is_owned = false;
22819         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22820         LDKDelayedPaymentOutputDescriptor ret_var = DelayedPaymentOutputDescriptor_clone(&orig_conv);
22821         uint64_t ret_ref = 0;
22822         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22823         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22824         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22825         ret_ref = (uint64_t)ret_var.inner;
22826         if (ret_var.is_owned) {
22827                 ret_ref |= 1;
22828         }
22829         return ret_ref;
22830 }
22831
22832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
22833         LDKDelayedPaymentOutputDescriptor obj_conv;
22834         obj_conv.inner = (void*)(obj & (~1));
22835         obj_conv.is_owned = false;
22836         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
22837         LDKCVec_u8Z ret_var = DelayedPaymentOutputDescriptor_write(&obj_conv);
22838         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
22839         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
22840         CVec_u8Z_free(ret_var);
22841         return ret_arr;
22842 }
22843
22844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DelayedPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
22845         LDKu8slice ser_ref;
22846         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
22847         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
22848         LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_DelayedPaymentOutputDescriptorDecodeErrorZ");
22849         *ret_conv = DelayedPaymentOutputDescriptor_read(ser_ref);
22850         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
22851         return (uint64_t)ret_conv;
22852 }
22853
22854 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
22855         LDKStaticPaymentOutputDescriptor this_obj_conv;
22856         this_obj_conv.inner = (void*)(this_obj & (~1));
22857         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
22858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
22859         StaticPaymentOutputDescriptor_free(this_obj_conv);
22860 }
22861
22862 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
22863         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22865         this_ptr_conv.is_owned = false;
22866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22867         LDKOutPoint ret_var = StaticPaymentOutputDescriptor_get_outpoint(&this_ptr_conv);
22868         uint64_t ret_ref = 0;
22869         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22870         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22871         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22872         ret_ref = (uint64_t)ret_var.inner;
22873         if (ret_var.is_owned) {
22874                 ret_ref |= 1;
22875         }
22876         return ret_ref;
22877 }
22878
22879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22880         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22882         this_ptr_conv.is_owned = false;
22883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22884         LDKOutPoint val_conv;
22885         val_conv.inner = (void*)(val & (~1));
22886         val_conv.is_owned = (val & 1) || (val == 0);
22887         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
22888         val_conv = OutPoint_clone(&val_conv);
22889         StaticPaymentOutputDescriptor_set_outpoint(&this_ptr_conv, val_conv);
22890 }
22891
22892 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1output(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22893         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22894         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22895         this_ptr_conv.is_owned = false;
22896         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22897         void* val_ptr = (void*)(((uint64_t)val) & ~1);
22898         CHECK_ACCESS(val_ptr);
22899         LDKTxOut val_conv = *(LDKTxOut*)(val_ptr);
22900         val_conv = TxOut_clone((LDKTxOut*)(((uint64_t)val) & ~1));
22901         StaticPaymentOutputDescriptor_set_output(&this_ptr_conv, val_conv);
22902 }
22903
22904 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
22905         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22906         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22907         this_ptr_conv.is_owned = false;
22908         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22909         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
22910         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *StaticPaymentOutputDescriptor_get_channel_keys_id(&this_ptr_conv));
22911         return ret_arr;
22912 }
22913
22914 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1keys_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
22915         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22917         this_ptr_conv.is_owned = false;
22918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22919         LDKThirtyTwoBytes val_ref;
22920         CHECK((*env)->GetArrayLength(env, val) == 32);
22921         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
22922         StaticPaymentOutputDescriptor_set_channel_keys_id(&this_ptr_conv, val_ref);
22923 }
22924
22925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
22926         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22928         this_ptr_conv.is_owned = false;
22929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22930         int64_t ret_val = StaticPaymentOutputDescriptor_get_channel_value_satoshis(&this_ptr_conv);
22931         return ret_val;
22932 }
22933
22934 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
22935         LDKStaticPaymentOutputDescriptor this_ptr_conv;
22936         this_ptr_conv.inner = (void*)(this_ptr & (~1));
22937         this_ptr_conv.is_owned = false;
22938         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
22939         StaticPaymentOutputDescriptor_set_channel_value_satoshis(&this_ptr_conv, val);
22940 }
22941
22942 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) {
22943         LDKOutPoint outpoint_arg_conv;
22944         outpoint_arg_conv.inner = (void*)(outpoint_arg & (~1));
22945         outpoint_arg_conv.is_owned = (outpoint_arg & 1) || (outpoint_arg == 0);
22946         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_arg_conv);
22947         outpoint_arg_conv = OutPoint_clone(&outpoint_arg_conv);
22948         void* output_arg_ptr = (void*)(((uint64_t)output_arg) & ~1);
22949         CHECK_ACCESS(output_arg_ptr);
22950         LDKTxOut output_arg_conv = *(LDKTxOut*)(output_arg_ptr);
22951         output_arg_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output_arg) & ~1));
22952         LDKThirtyTwoBytes channel_keys_id_arg_ref;
22953         CHECK((*env)->GetArrayLength(env, channel_keys_id_arg) == 32);
22954         (*env)->GetByteArrayRegion(env, channel_keys_id_arg, 0, 32, channel_keys_id_arg_ref.data);
22955         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_new(outpoint_arg_conv, output_arg_conv, channel_keys_id_arg_ref, channel_value_satoshis_arg);
22956         uint64_t ret_ref = 0;
22957         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22958         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22959         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22960         ret_ref = (uint64_t)ret_var.inner;
22961         if (ret_var.is_owned) {
22962                 ret_ref |= 1;
22963         }
22964         return ret_ref;
22965 }
22966
22967 static inline uint64_t StaticPaymentOutputDescriptor_clone_ptr(LDKStaticPaymentOutputDescriptor *NONNULL_PTR arg) {
22968         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(arg);
22969 uint64_t ret_ref = 0;
22970 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22971 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22972 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22973 ret_ref = (uint64_t)ret_var.inner;
22974 if (ret_var.is_owned) {
22975         ret_ref |= 1;
22976 }
22977         return ret_ref;
22978 }
22979 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
22980         LDKStaticPaymentOutputDescriptor arg_conv;
22981         arg_conv.inner = (void*)(arg & (~1));
22982         arg_conv.is_owned = false;
22983         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
22984         int64_t ret_val = StaticPaymentOutputDescriptor_clone_ptr(&arg_conv);
22985         return ret_val;
22986 }
22987
22988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
22989         LDKStaticPaymentOutputDescriptor orig_conv;
22990         orig_conv.inner = (void*)(orig & (~1));
22991         orig_conv.is_owned = false;
22992         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
22993         LDKStaticPaymentOutputDescriptor ret_var = StaticPaymentOutputDescriptor_clone(&orig_conv);
22994         uint64_t ret_ref = 0;
22995         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
22996         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
22997         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
22998         ret_ref = (uint64_t)ret_var.inner;
22999         if (ret_var.is_owned) {
23000                 ret_ref |= 1;
23001         }
23002         return ret_ref;
23003 }
23004
23005 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
23006         LDKStaticPaymentOutputDescriptor obj_conv;
23007         obj_conv.inner = (void*)(obj & (~1));
23008         obj_conv.is_owned = false;
23009         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23010         LDKCVec_u8Z ret_var = StaticPaymentOutputDescriptor_write(&obj_conv);
23011         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23012         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23013         CVec_u8Z_free(ret_var);
23014         return ret_arr;
23015 }
23016
23017 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_StaticPaymentOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23018         LDKu8slice ser_ref;
23019         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23020         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23021         LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ), "LDKCResult_StaticPaymentOutputDescriptorDecodeErrorZ");
23022         *ret_conv = StaticPaymentOutputDescriptor_read(ser_ref);
23023         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23024         return (uint64_t)ret_conv;
23025 }
23026
23027 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23028         if ((this_ptr & 1) != 0) return;
23029         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23030         CHECK_ACCESS(this_ptr_ptr);
23031         LDKSpendableOutputDescriptor this_ptr_conv = *(LDKSpendableOutputDescriptor*)(this_ptr_ptr);
23032         FREE((void*)this_ptr);
23033         SpendableOutputDescriptor_free(this_ptr_conv);
23034 }
23035
23036 static inline uint64_t SpendableOutputDescriptor_clone_ptr(LDKSpendableOutputDescriptor *NONNULL_PTR arg) {
23037         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23038         *ret_copy = SpendableOutputDescriptor_clone(arg);
23039 uint64_t ret_ref = (uint64_t)ret_copy;
23040         return ret_ref;
23041 }
23042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23043         LDKSpendableOutputDescriptor* arg_conv = (LDKSpendableOutputDescriptor*)arg;
23044         int64_t ret_val = SpendableOutputDescriptor_clone_ptr(arg_conv);
23045         return ret_val;
23046 }
23047
23048 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23049         LDKSpendableOutputDescriptor* orig_conv = (LDKSpendableOutputDescriptor*)orig;
23050         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23051         *ret_copy = SpendableOutputDescriptor_clone(orig_conv);
23052         uint64_t ret_ref = (uint64_t)ret_copy;
23053         return ret_ref;
23054 }
23055
23056 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1output(JNIEnv *env, jclass clz, int64_t outpoint, int64_t output) {
23057         LDKOutPoint outpoint_conv;
23058         outpoint_conv.inner = (void*)(outpoint & (~1));
23059         outpoint_conv.is_owned = (outpoint & 1) || (outpoint == 0);
23060         CHECK_INNER_FIELD_ACCESS_OR_NULL(outpoint_conv);
23061         outpoint_conv = OutPoint_clone(&outpoint_conv);
23062         void* output_ptr = (void*)(((uint64_t)output) & ~1);
23063         CHECK_ACCESS(output_ptr);
23064         LDKTxOut output_conv = *(LDKTxOut*)(output_ptr);
23065         output_conv = TxOut_clone((LDKTxOut*)(((uint64_t)output) & ~1));
23066         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23067         *ret_copy = SpendableOutputDescriptor_static_output(outpoint_conv, output_conv);
23068         uint64_t ret_ref = (uint64_t)ret_copy;
23069         return ret_ref;
23070 }
23071
23072 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1delayed_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
23073         LDKDelayedPaymentOutputDescriptor a_conv;
23074         a_conv.inner = (void*)(a & (~1));
23075         a_conv.is_owned = (a & 1) || (a == 0);
23076         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23077         a_conv = DelayedPaymentOutputDescriptor_clone(&a_conv);
23078         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23079         *ret_copy = SpendableOutputDescriptor_delayed_payment_output(a_conv);
23080         uint64_t ret_ref = (uint64_t)ret_copy;
23081         return ret_ref;
23082 }
23083
23084 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1static_1payment_1output(JNIEnv *env, jclass clz, int64_t a) {
23085         LDKStaticPaymentOutputDescriptor a_conv;
23086         a_conv.inner = (void*)(a & (~1));
23087         a_conv.is_owned = (a & 1) || (a == 0);
23088         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
23089         a_conv = StaticPaymentOutputDescriptor_clone(&a_conv);
23090         LDKSpendableOutputDescriptor *ret_copy = MALLOC(sizeof(LDKSpendableOutputDescriptor), "LDKSpendableOutputDescriptor");
23091         *ret_copy = SpendableOutputDescriptor_static_payment_output(a_conv);
23092         uint64_t ret_ref = (uint64_t)ret_copy;
23093         return ret_ref;
23094 }
23095
23096 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1write(JNIEnv *env, jclass clz, int64_t obj) {
23097         LDKSpendableOutputDescriptor* obj_conv = (LDKSpendableOutputDescriptor*)obj;
23098         LDKCVec_u8Z ret_var = SpendableOutputDescriptor_write(obj_conv);
23099         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23100         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23101         CVec_u8Z_free(ret_var);
23102         return ret_arr;
23103 }
23104
23105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SpendableOutputDescriptor_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23106         LDKu8slice ser_ref;
23107         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23108         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23109         LDKCResult_SpendableOutputDescriptorDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SpendableOutputDescriptorDecodeErrorZ), "LDKCResult_SpendableOutputDescriptorDecodeErrorZ");
23110         *ret_conv = SpendableOutputDescriptor_read(ser_ref);
23111         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23112         return (uint64_t)ret_conv;
23113 }
23114
23115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BaseSign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23116         if ((this_ptr & 1) != 0) return;
23117         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23118         CHECK_ACCESS(this_ptr_ptr);
23119         LDKBaseSign this_ptr_conv = *(LDKBaseSign*)(this_ptr_ptr);
23120         FREE((void*)this_ptr);
23121         BaseSign_free(this_ptr_conv);
23122 }
23123
23124 static inline uint64_t Sign_clone_ptr(LDKSign *NONNULL_PTR arg) {
23125         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23126         *ret_ret = Sign_clone(arg);
23127         return (uint64_t)ret_ret;
23128 }
23129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23130         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
23131         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
23132         LDKSign* arg_conv = (LDKSign*)arg_ptr;
23133         int64_t ret_val = Sign_clone_ptr(arg_conv);
23134         return ret_val;
23135 }
23136
23137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sign_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23138         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
23139         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
23140         LDKSign* orig_conv = (LDKSign*)orig_ptr;
23141         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23142         *ret_ret = Sign_clone(orig_conv);
23143         return (uint64_t)ret_ret;
23144 }
23145
23146 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sign_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23147         if ((this_ptr & 1) != 0) return;
23148         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23149         CHECK_ACCESS(this_ptr_ptr);
23150         LDKSign this_ptr_conv = *(LDKSign*)(this_ptr_ptr);
23151         FREE((void*)this_ptr);
23152         Sign_free(this_ptr_conv);
23153 }
23154
23155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysInterface_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
23156         if ((this_ptr & 1) != 0) return;
23157         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
23158         CHECK_ACCESS(this_ptr_ptr);
23159         LDKKeysInterface this_ptr_conv = *(LDKKeysInterface*)(this_ptr_ptr);
23160         FREE((void*)this_ptr);
23161         KeysInterface_free(this_ptr_conv);
23162 }
23163
23164 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23165         LDKInMemorySigner this_obj_conv;
23166         this_obj_conv.inner = (void*)(this_obj & (~1));
23167         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23169         InMemorySigner_free(this_obj_conv);
23170 }
23171
23172 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23173         LDKInMemorySigner this_ptr_conv;
23174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23175         this_ptr_conv.is_owned = false;
23176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23177         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23178         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_funding_key(&this_ptr_conv));
23179         return ret_arr;
23180 }
23181
23182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1funding_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23183         LDKInMemorySigner this_ptr_conv;
23184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23185         this_ptr_conv.is_owned = false;
23186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23187         LDKSecretKey val_ref;
23188         CHECK((*env)->GetArrayLength(env, val) == 32);
23189         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23190         InMemorySigner_set_funding_key(&this_ptr_conv, val_ref);
23191 }
23192
23193 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23194         LDKInMemorySigner this_ptr_conv;
23195         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23196         this_ptr_conv.is_owned = false;
23197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23198         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23199         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_revocation_base_key(&this_ptr_conv));
23200         return ret_arr;
23201 }
23202
23203 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1revocation_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23204         LDKInMemorySigner this_ptr_conv;
23205         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23206         this_ptr_conv.is_owned = false;
23207         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23208         LDKSecretKey val_ref;
23209         CHECK((*env)->GetArrayLength(env, val) == 32);
23210         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23211         InMemorySigner_set_revocation_base_key(&this_ptr_conv, val_ref);
23212 }
23213
23214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23215         LDKInMemorySigner this_ptr_conv;
23216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23217         this_ptr_conv.is_owned = false;
23218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23219         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_payment_key(&this_ptr_conv));
23221         return ret_arr;
23222 }
23223
23224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23225         LDKInMemorySigner this_ptr_conv;
23226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23227         this_ptr_conv.is_owned = false;
23228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23229         LDKSecretKey val_ref;
23230         CHECK((*env)->GetArrayLength(env, val) == 32);
23231         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23232         InMemorySigner_set_payment_key(&this_ptr_conv, val_ref);
23233 }
23234
23235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1delayed_1payment_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23236         LDKInMemorySigner this_ptr_conv;
23237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23238         this_ptr_conv.is_owned = false;
23239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23240         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23241         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_delayed_payment_base_key(&this_ptr_conv));
23242         return ret_arr;
23243 }
23244
23245 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) {
23246         LDKInMemorySigner this_ptr_conv;
23247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23248         this_ptr_conv.is_owned = false;
23249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23250         LDKSecretKey val_ref;
23251         CHECK((*env)->GetArrayLength(env, val) == 32);
23252         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23253         InMemorySigner_set_delayed_payment_base_key(&this_ptr_conv, val_ref);
23254 }
23255
23256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
23257         LDKInMemorySigner this_ptr_conv;
23258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23259         this_ptr_conv.is_owned = false;
23260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23261         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_htlc_base_key(&this_ptr_conv));
23263         return ret_arr;
23264 }
23265
23266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1htlc_1base_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23267         LDKInMemorySigner this_ptr_conv;
23268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23269         this_ptr_conv.is_owned = false;
23270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23271         LDKSecretKey val_ref;
23272         CHECK((*env)->GetArrayLength(env, val) == 32);
23273         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.bytes);
23274         InMemorySigner_set_htlc_base_key(&this_ptr_conv, val_ref);
23275 }
23276
23277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr) {
23278         LDKInMemorySigner this_ptr_conv;
23279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23280         this_ptr_conv.is_owned = false;
23281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23282         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
23283         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *InMemorySigner_get_commitment_seed(&this_ptr_conv));
23284         return ret_arr;
23285 }
23286
23287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1set_1commitment_1seed(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23288         LDKInMemorySigner this_ptr_conv;
23289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23290         this_ptr_conv.is_owned = false;
23291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23292         LDKThirtyTwoBytes val_ref;
23293         CHECK((*env)->GetArrayLength(env, val) == 32);
23294         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
23295         InMemorySigner_set_commitment_seed(&this_ptr_conv, val_ref);
23296 }
23297
23298 static inline uint64_t InMemorySigner_clone_ptr(LDKInMemorySigner *NONNULL_PTR arg) {
23299         LDKInMemorySigner ret_var = InMemorySigner_clone(arg);
23300 uint64_t ret_ref = 0;
23301 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23302 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23303 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23304 ret_ref = (uint64_t)ret_var.inner;
23305 if (ret_var.is_owned) {
23306         ret_ref |= 1;
23307 }
23308         return ret_ref;
23309 }
23310 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23311         LDKInMemorySigner arg_conv;
23312         arg_conv.inner = (void*)(arg & (~1));
23313         arg_conv.is_owned = false;
23314         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23315         int64_t ret_val = InMemorySigner_clone_ptr(&arg_conv);
23316         return ret_val;
23317 }
23318
23319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23320         LDKInMemorySigner orig_conv;
23321         orig_conv.inner = (void*)(orig & (~1));
23322         orig_conv.is_owned = false;
23323         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23324         LDKInMemorySigner ret_var = InMemorySigner_clone(&orig_conv);
23325         uint64_t ret_ref = 0;
23326         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23327         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23328         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23329         ret_ref = (uint64_t)ret_var.inner;
23330         if (ret_var.is_owned) {
23331                 ret_ref |= 1;
23332         }
23333         return ret_ref;
23334 }
23335
23336 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) {
23337         LDKSecretKey funding_key_ref;
23338         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
23339         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_ref.bytes);
23340         LDKSecretKey revocation_base_key_ref;
23341         CHECK((*env)->GetArrayLength(env, revocation_base_key) == 32);
23342         (*env)->GetByteArrayRegion(env, revocation_base_key, 0, 32, revocation_base_key_ref.bytes);
23343         LDKSecretKey payment_key_ref;
23344         CHECK((*env)->GetArrayLength(env, payment_key) == 32);
23345         (*env)->GetByteArrayRegion(env, payment_key, 0, 32, payment_key_ref.bytes);
23346         LDKSecretKey delayed_payment_base_key_ref;
23347         CHECK((*env)->GetArrayLength(env, delayed_payment_base_key) == 32);
23348         (*env)->GetByteArrayRegion(env, delayed_payment_base_key, 0, 32, delayed_payment_base_key_ref.bytes);
23349         LDKSecretKey htlc_base_key_ref;
23350         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
23351         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_ref.bytes);
23352         LDKThirtyTwoBytes commitment_seed_ref;
23353         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
23354         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_ref.data);
23355         LDKThirtyTwoBytes channel_keys_id_ref;
23356         CHECK((*env)->GetArrayLength(env, channel_keys_id) == 32);
23357         (*env)->GetByteArrayRegion(env, channel_keys_id, 0, 32, channel_keys_id_ref.data);
23358         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);
23359         uint64_t ret_ref = 0;
23360         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23361         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23362         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23363         ret_ref = (uint64_t)ret_var.inner;
23364         if (ret_var.is_owned) {
23365                 ret_ref |= 1;
23366         }
23367         return ret_ref;
23368 }
23369
23370 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
23371         LDKInMemorySigner this_arg_conv;
23372         this_arg_conv.inner = (void*)(this_arg & (~1));
23373         this_arg_conv.is_owned = false;
23374         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23375         LDKChannelPublicKeys ret_var = InMemorySigner_counterparty_pubkeys(&this_arg_conv);
23376         uint64_t ret_ref = 0;
23377         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23378         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23379         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23380         ret_ref = (uint64_t)ret_var.inner;
23381         if (ret_var.is_owned) {
23382                 ret_ref |= 1;
23383         }
23384         return ret_ref;
23385 }
23386
23387 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1counterparty_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
23388         LDKInMemorySigner this_arg_conv;
23389         this_arg_conv.inner = (void*)(this_arg & (~1));
23390         this_arg_conv.is_owned = false;
23391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23392         int16_t ret_val = InMemorySigner_counterparty_selected_contest_delay(&this_arg_conv);
23393         return ret_val;
23394 }
23395
23396 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
23397         LDKInMemorySigner this_arg_conv;
23398         this_arg_conv.inner = (void*)(this_arg & (~1));
23399         this_arg_conv.is_owned = false;
23400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23401         int16_t ret_val = InMemorySigner_holder_selected_contest_delay(&this_arg_conv);
23402         return ret_val;
23403 }
23404
23405 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
23406         LDKInMemorySigner this_arg_conv;
23407         this_arg_conv.inner = (void*)(this_arg & (~1));
23408         this_arg_conv.is_owned = false;
23409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23410         jboolean ret_val = InMemorySigner_is_outbound(&this_arg_conv);
23411         return ret_val;
23412 }
23413
23414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
23415         LDKInMemorySigner this_arg_conv;
23416         this_arg_conv.inner = (void*)(this_arg & (~1));
23417         this_arg_conv.is_owned = false;
23418         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23419         LDKOutPoint ret_var = InMemorySigner_funding_outpoint(&this_arg_conv);
23420         uint64_t ret_ref = 0;
23421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23424         ret_ref = (uint64_t)ret_var.inner;
23425         if (ret_var.is_owned) {
23426                 ret_ref |= 1;
23427         }
23428         return ret_ref;
23429 }
23430
23431 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1get_1channel_1parameters(JNIEnv *env, jclass clz, int64_t this_arg) {
23432         LDKInMemorySigner this_arg_conv;
23433         this_arg_conv.inner = (void*)(this_arg & (~1));
23434         this_arg_conv.is_owned = false;
23435         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23436         LDKChannelTransactionParameters ret_var = InMemorySigner_get_channel_parameters(&this_arg_conv);
23437         uint64_t ret_ref = 0;
23438         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23439         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23440         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23441         ret_ref = (uint64_t)ret_var.inner;
23442         if (ret_var.is_owned) {
23443                 ret_ref |= 1;
23444         }
23445         return ret_ref;
23446 }
23447
23448 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) {
23449         LDKInMemorySigner this_arg_conv;
23450         this_arg_conv.inner = (void*)(this_arg & (~1));
23451         this_arg_conv.is_owned = false;
23452         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23453         LDKTransaction spend_tx_ref;
23454         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
23455         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23456         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
23457         spend_tx_ref.data_is_owned = true;
23458         LDKStaticPaymentOutputDescriptor descriptor_conv;
23459         descriptor_conv.inner = (void*)(descriptor & (~1));
23460         descriptor_conv.is_owned = false;
23461         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23462         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23463         *ret_conv = InMemorySigner_sign_counterparty_payment_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23464         return (uint64_t)ret_conv;
23465 }
23466
23467 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) {
23468         LDKInMemorySigner this_arg_conv;
23469         this_arg_conv.inner = (void*)(this_arg & (~1));
23470         this_arg_conv.is_owned = false;
23471         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23472         LDKTransaction spend_tx_ref;
23473         spend_tx_ref.datalen = (*env)->GetArrayLength(env, spend_tx);
23474         spend_tx_ref.data = MALLOC(spend_tx_ref.datalen, "LDKTransaction Bytes");
23475         (*env)->GetByteArrayRegion(env, spend_tx, 0, spend_tx_ref.datalen, spend_tx_ref.data);
23476         spend_tx_ref.data_is_owned = true;
23477         LDKDelayedPaymentOutputDescriptor descriptor_conv;
23478         descriptor_conv.inner = (void*)(descriptor & (~1));
23479         descriptor_conv.is_owned = false;
23480         CHECK_INNER_FIELD_ACCESS_OR_NULL(descriptor_conv);
23481         LDKCResult_CVec_CVec_u8ZZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_CVec_u8ZZNoneZ), "LDKCResult_CVec_CVec_u8ZZNoneZ");
23482         *ret_conv = InMemorySigner_sign_dynamic_p2wsh_input(&this_arg_conv, spend_tx_ref, input_idx, &descriptor_conv);
23483         return (uint64_t)ret_conv;
23484 }
23485
23486 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1BaseSign(JNIEnv *env, jclass clz, int64_t this_arg) {
23487         LDKInMemorySigner this_arg_conv;
23488         this_arg_conv.inner = (void*)(this_arg & (~1));
23489         this_arg_conv.is_owned = false;
23490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23491         LDKBaseSign* ret_ret = MALLOC(sizeof(LDKBaseSign), "LDKBaseSign");
23492         *ret_ret = InMemorySigner_as_BaseSign(&this_arg_conv);
23493         return (uint64_t)ret_ret;
23494 }
23495
23496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1as_1Sign(JNIEnv *env, jclass clz, int64_t this_arg) {
23497         LDKInMemorySigner this_arg_conv;
23498         this_arg_conv.inner = (void*)(this_arg & (~1));
23499         this_arg_conv.is_owned = false;
23500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23501         LDKSign* ret_ret = MALLOC(sizeof(LDKSign), "LDKSign");
23502         *ret_ret = InMemorySigner_as_Sign(&this_arg_conv);
23503         return (uint64_t)ret_ret;
23504 }
23505
23506 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1write(JNIEnv *env, jclass clz, int64_t obj) {
23507         LDKInMemorySigner obj_conv;
23508         obj_conv.inner = (void*)(obj & (~1));
23509         obj_conv.is_owned = false;
23510         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
23511         LDKCVec_u8Z ret_var = InMemorySigner_write(&obj_conv);
23512         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
23513         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
23514         CVec_u8Z_free(ret_var);
23515         return ret_arr;
23516 }
23517
23518 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InMemorySigner_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
23519         LDKu8slice ser_ref;
23520         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
23521         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
23522         LDKCResult_InMemorySignerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InMemorySignerDecodeErrorZ), "LDKCResult_InMemorySignerDecodeErrorZ");
23523         *ret_conv = InMemorySigner_read(ser_ref);
23524         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
23525         return (uint64_t)ret_conv;
23526 }
23527
23528 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_KeysManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23529         LDKKeysManager this_obj_conv;
23530         this_obj_conv.inner = (void*)(this_obj & (~1));
23531         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23532         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23533         KeysManager_free(this_obj_conv);
23534 }
23535
23536 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) {
23537         unsigned char seed_arr[32];
23538         CHECK((*env)->GetArrayLength(env, seed) == 32);
23539         (*env)->GetByteArrayRegion(env, seed, 0, 32, seed_arr);
23540         unsigned char (*seed_ref)[32] = &seed_arr;
23541         LDKKeysManager ret_var = KeysManager_new(seed_ref, starting_time_secs, starting_time_nanos);
23542         uint64_t ret_ref = 0;
23543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23546         ret_ref = (uint64_t)ret_var.inner;
23547         if (ret_var.is_owned) {
23548                 ret_ref |= 1;
23549         }
23550         return ret_ref;
23551 }
23552
23553 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) {
23554         LDKKeysManager this_arg_conv;
23555         this_arg_conv.inner = (void*)(this_arg & (~1));
23556         this_arg_conv.is_owned = false;
23557         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23558         unsigned char params_arr[32];
23559         CHECK((*env)->GetArrayLength(env, params) == 32);
23560         (*env)->GetByteArrayRegion(env, params, 0, 32, params_arr);
23561         unsigned char (*params_ref)[32] = &params_arr;
23562         LDKInMemorySigner ret_var = KeysManager_derive_channel_keys(&this_arg_conv, channel_value_satoshis, params_ref);
23563         uint64_t ret_ref = 0;
23564         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23565         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23566         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23567         ret_ref = (uint64_t)ret_var.inner;
23568         if (ret_var.is_owned) {
23569                 ret_ref |= 1;
23570         }
23571         return ret_ref;
23572 }
23573
23574 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) {
23575         LDKKeysManager this_arg_conv;
23576         this_arg_conv.inner = (void*)(this_arg & (~1));
23577         this_arg_conv.is_owned = false;
23578         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23579         LDKCVec_SpendableOutputDescriptorZ descriptors_constr;
23580         descriptors_constr.datalen = (*env)->GetArrayLength(env, descriptors);
23581         if (descriptors_constr.datalen > 0)
23582                 descriptors_constr.data = MALLOC(descriptors_constr.datalen * sizeof(LDKSpendableOutputDescriptor), "LDKCVec_SpendableOutputDescriptorZ Elements");
23583         else
23584                 descriptors_constr.data = NULL;
23585         int64_t* descriptors_vals = (*env)->GetLongArrayElements (env, descriptors, NULL);
23586         for (size_t b = 0; b < descriptors_constr.datalen; b++) {
23587                 int64_t descriptors_conv_27 = descriptors_vals[b];
23588                 void* descriptors_conv_27_ptr = (void*)(((uint64_t)descriptors_conv_27) & ~1);
23589                 CHECK_ACCESS(descriptors_conv_27_ptr);
23590                 LDKSpendableOutputDescriptor descriptors_conv_27_conv = *(LDKSpendableOutputDescriptor*)(descriptors_conv_27_ptr);
23591                 descriptors_conv_27_conv = SpendableOutputDescriptor_clone((LDKSpendableOutputDescriptor*)(((uint64_t)descriptors_conv_27) & ~1));
23592                 descriptors_constr.data[b] = descriptors_conv_27_conv;
23593         }
23594         (*env)->ReleaseLongArrayElements(env, descriptors, descriptors_vals, 0);
23595         LDKCVec_TxOutZ outputs_constr;
23596         outputs_constr.datalen = (*env)->GetArrayLength(env, outputs);
23597         if (outputs_constr.datalen > 0)
23598                 outputs_constr.data = MALLOC(outputs_constr.datalen * sizeof(LDKTxOut), "LDKCVec_TxOutZ Elements");
23599         else
23600                 outputs_constr.data = NULL;
23601         int64_t* outputs_vals = (*env)->GetLongArrayElements (env, outputs, NULL);
23602         for (size_t h = 0; h < outputs_constr.datalen; h++) {
23603                 int64_t outputs_conv_7 = outputs_vals[h];
23604                 void* outputs_conv_7_ptr = (void*)(((uint64_t)outputs_conv_7) & ~1);
23605                 CHECK_ACCESS(outputs_conv_7_ptr);
23606                 LDKTxOut outputs_conv_7_conv = *(LDKTxOut*)(outputs_conv_7_ptr);
23607                 outputs_conv_7_conv = TxOut_clone((LDKTxOut*)(((uint64_t)outputs_conv_7) & ~1));
23608                 outputs_constr.data[h] = outputs_conv_7_conv;
23609         }
23610         (*env)->ReleaseLongArrayElements(env, outputs, outputs_vals, 0);
23611         LDKCVec_u8Z change_destination_script_ref;
23612         change_destination_script_ref.datalen = (*env)->GetArrayLength(env, change_destination_script);
23613         change_destination_script_ref.data = MALLOC(change_destination_script_ref.datalen, "LDKCVec_u8Z Bytes");
23614         (*env)->GetByteArrayRegion(env, change_destination_script, 0, change_destination_script_ref.datalen, change_destination_script_ref.data);
23615         LDKCResult_TransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TransactionNoneZ), "LDKCResult_TransactionNoneZ");
23616         *ret_conv = KeysManager_spend_spendable_outputs(&this_arg_conv, descriptors_constr, outputs_constr, change_destination_script_ref, feerate_sat_per_1000_weight);
23617         return (uint64_t)ret_conv;
23618 }
23619
23620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_KeysManager_1as_1KeysInterface(JNIEnv *env, jclass clz, int64_t this_arg) {
23621         LDKKeysManager this_arg_conv;
23622         this_arg_conv.inner = (void*)(this_arg & (~1));
23623         this_arg_conv.is_owned = false;
23624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
23625         LDKKeysInterface* ret_ret = MALLOC(sizeof(LDKKeysInterface), "LDKKeysInterface");
23626         *ret_ret = KeysManager_as_KeysInterface(&this_arg_conv);
23627         return (uint64_t)ret_ret;
23628 }
23629
23630 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23631         LDKChannelManager this_obj_conv;
23632         this_obj_conv.inner = (void*)(this_obj & (~1));
23633         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23634         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23635         ChannelManager_free(this_obj_conv);
23636 }
23637
23638 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23639         LDKChainParameters this_obj_conv;
23640         this_obj_conv.inner = (void*)(this_obj & (~1));
23641         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23643         ChainParameters_free(this_obj_conv);
23644 }
23645
23646 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1network(JNIEnv *env, jclass clz, int64_t this_ptr) {
23647         LDKChainParameters this_ptr_conv;
23648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23649         this_ptr_conv.is_owned = false;
23650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23651         jclass ret_conv = LDKNetwork_to_java(env, ChainParameters_get_network(&this_ptr_conv));
23652         return ret_conv;
23653 }
23654
23655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1network(JNIEnv *env, jclass clz, int64_t this_ptr, jclass val) {
23656         LDKChainParameters this_ptr_conv;
23657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23658         this_ptr_conv.is_owned = false;
23659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23660         LDKNetwork val_conv = LDKNetwork_from_java(env, val);
23661         ChainParameters_set_network(&this_ptr_conv, val_conv);
23662 }
23663
23664 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1get_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr) {
23665         LDKChainParameters this_ptr_conv;
23666         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23667         this_ptr_conv.is_owned = false;
23668         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23669         LDKBestBlock ret_var = ChainParameters_get_best_block(&this_ptr_conv);
23670         uint64_t ret_ref = 0;
23671         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23672         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23673         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23674         ret_ref = (uint64_t)ret_var.inner;
23675         if (ret_var.is_owned) {
23676                 ret_ref |= 1;
23677         }
23678         return ret_ref;
23679 }
23680
23681 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChainParameters_1set_1best_1block(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23682         LDKChainParameters this_ptr_conv;
23683         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23684         this_ptr_conv.is_owned = false;
23685         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23686         LDKBestBlock val_conv;
23687         val_conv.inner = (void*)(val & (~1));
23688         val_conv.is_owned = (val & 1) || (val == 0);
23689         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23690         val_conv = BestBlock_clone(&val_conv);
23691         ChainParameters_set_best_block(&this_ptr_conv, val_conv);
23692 }
23693
23694 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1new(JNIEnv *env, jclass clz, jclass network_arg, int64_t best_block_arg) {
23695         LDKNetwork network_arg_conv = LDKNetwork_from_java(env, network_arg);
23696         LDKBestBlock best_block_arg_conv;
23697         best_block_arg_conv.inner = (void*)(best_block_arg & (~1));
23698         best_block_arg_conv.is_owned = (best_block_arg & 1) || (best_block_arg == 0);
23699         CHECK_INNER_FIELD_ACCESS_OR_NULL(best_block_arg_conv);
23700         best_block_arg_conv = BestBlock_clone(&best_block_arg_conv);
23701         LDKChainParameters ret_var = ChainParameters_new(network_arg_conv, best_block_arg_conv);
23702         uint64_t ret_ref = 0;
23703         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23704         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23705         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23706         ret_ref = (uint64_t)ret_var.inner;
23707         if (ret_var.is_owned) {
23708                 ret_ref |= 1;
23709         }
23710         return ret_ref;
23711 }
23712
23713 static inline uint64_t ChainParameters_clone_ptr(LDKChainParameters *NONNULL_PTR arg) {
23714         LDKChainParameters ret_var = ChainParameters_clone(arg);
23715 uint64_t ret_ref = 0;
23716 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23717 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23718 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23719 ret_ref = (uint64_t)ret_var.inner;
23720 if (ret_var.is_owned) {
23721         ret_ref |= 1;
23722 }
23723         return ret_ref;
23724 }
23725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23726         LDKChainParameters arg_conv;
23727         arg_conv.inner = (void*)(arg & (~1));
23728         arg_conv.is_owned = false;
23729         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23730         int64_t ret_val = ChainParameters_clone_ptr(&arg_conv);
23731         return ret_val;
23732 }
23733
23734 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChainParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23735         LDKChainParameters orig_conv;
23736         orig_conv.inner = (void*)(orig & (~1));
23737         orig_conv.is_owned = false;
23738         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23739         LDKChainParameters ret_var = ChainParameters_clone(&orig_conv);
23740         uint64_t ret_ref = 0;
23741         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23742         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23743         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23744         ret_ref = (uint64_t)ret_var.inner;
23745         if (ret_var.is_owned) {
23746                 ret_ref |= 1;
23747         }
23748         return ret_ref;
23749 }
23750
23751 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23752         LDKCounterpartyForwardingInfo this_obj_conv;
23753         this_obj_conv.inner = (void*)(this_obj & (~1));
23754         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23755         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23756         CounterpartyForwardingInfo_free(this_obj_conv);
23757 }
23758
23759 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
23760         LDKCounterpartyForwardingInfo this_ptr_conv;
23761         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23762         this_ptr_conv.is_owned = false;
23763         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23764         int32_t ret_val = CounterpartyForwardingInfo_get_fee_base_msat(&this_ptr_conv);
23765         return ret_val;
23766 }
23767
23768 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23769         LDKCounterpartyForwardingInfo this_ptr_conv;
23770         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23771         this_ptr_conv.is_owned = false;
23772         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23773         CounterpartyForwardingInfo_set_fee_base_msat(&this_ptr_conv, val);
23774 }
23775
23776 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
23777         LDKCounterpartyForwardingInfo this_ptr_conv;
23778         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23779         this_ptr_conv.is_owned = false;
23780         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23781         int32_t ret_val = CounterpartyForwardingInfo_get_fee_proportional_millionths(&this_ptr_conv);
23782         return ret_val;
23783 }
23784
23785 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
23786         LDKCounterpartyForwardingInfo this_ptr_conv;
23787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23788         this_ptr_conv.is_owned = false;
23789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23790         CounterpartyForwardingInfo_set_fee_proportional_millionths(&this_ptr_conv, val);
23791 }
23792
23793 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
23794         LDKCounterpartyForwardingInfo this_ptr_conv;
23795         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23796         this_ptr_conv.is_owned = false;
23797         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23798         int16_t ret_val = CounterpartyForwardingInfo_get_cltv_expiry_delta(&this_ptr_conv);
23799         return ret_val;
23800 }
23801
23802 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
23803         LDKCounterpartyForwardingInfo this_ptr_conv;
23804         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23805         this_ptr_conv.is_owned = false;
23806         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23807         CounterpartyForwardingInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
23808 }
23809
23810 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) {
23811         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_new(fee_base_msat_arg, fee_proportional_millionths_arg, cltv_expiry_delta_arg);
23812         uint64_t ret_ref = 0;
23813         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23814         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23815         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23816         ret_ref = (uint64_t)ret_var.inner;
23817         if (ret_var.is_owned) {
23818                 ret_ref |= 1;
23819         }
23820         return ret_ref;
23821 }
23822
23823 static inline uint64_t CounterpartyForwardingInfo_clone_ptr(LDKCounterpartyForwardingInfo *NONNULL_PTR arg) {
23824         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(arg);
23825 uint64_t ret_ref = 0;
23826 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23827 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23828 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23829 ret_ref = (uint64_t)ret_var.inner;
23830 if (ret_var.is_owned) {
23831         ret_ref |= 1;
23832 }
23833         return ret_ref;
23834 }
23835 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
23836         LDKCounterpartyForwardingInfo arg_conv;
23837         arg_conv.inner = (void*)(arg & (~1));
23838         arg_conv.is_owned = false;
23839         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
23840         int64_t ret_val = CounterpartyForwardingInfo_clone_ptr(&arg_conv);
23841         return ret_val;
23842 }
23843
23844 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyForwardingInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
23845         LDKCounterpartyForwardingInfo orig_conv;
23846         orig_conv.inner = (void*)(orig & (~1));
23847         orig_conv.is_owned = false;
23848         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
23849         LDKCounterpartyForwardingInfo ret_var = CounterpartyForwardingInfo_clone(&orig_conv);
23850         uint64_t ret_ref = 0;
23851         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23852         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23853         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23854         ret_ref = (uint64_t)ret_var.inner;
23855         if (ret_var.is_owned) {
23856                 ret_ref |= 1;
23857         }
23858         return ret_ref;
23859 }
23860
23861 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
23862         LDKChannelCounterparty this_obj_conv;
23863         this_obj_conv.inner = (void*)(this_obj & (~1));
23864         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
23865         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
23866         ChannelCounterparty_free(this_obj_conv);
23867 }
23868
23869 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
23870         LDKChannelCounterparty this_ptr_conv;
23871         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23872         this_ptr_conv.is_owned = false;
23873         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23874         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
23875         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelCounterparty_get_node_id(&this_ptr_conv).compressed_form);
23876         return ret_arr;
23877 }
23878
23879 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
23880         LDKChannelCounterparty this_ptr_conv;
23881         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23882         this_ptr_conv.is_owned = false;
23883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23884         LDKPublicKey val_ref;
23885         CHECK((*env)->GetArrayLength(env, val) == 33);
23886         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
23887         ChannelCounterparty_set_node_id(&this_ptr_conv, val_ref);
23888 }
23889
23890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
23891         LDKChannelCounterparty this_ptr_conv;
23892         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23893         this_ptr_conv.is_owned = false;
23894         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23895         LDKInitFeatures ret_var = ChannelCounterparty_get_features(&this_ptr_conv);
23896         uint64_t ret_ref = 0;
23897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23900         ret_ref = (uint64_t)ret_var.inner;
23901         if (ret_var.is_owned) {
23902                 ret_ref |= 1;
23903         }
23904         return ret_ref;
23905 }
23906
23907 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23908         LDKChannelCounterparty this_ptr_conv;
23909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23910         this_ptr_conv.is_owned = false;
23911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23912         LDKInitFeatures val_conv;
23913         val_conv.inner = (void*)(val & (~1));
23914         val_conv.is_owned = (val & 1) || (val == 0);
23915         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23916         val_conv = InitFeatures_clone(&val_conv);
23917         ChannelCounterparty_set_features(&this_ptr_conv, val_conv);
23918 }
23919
23920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
23921         LDKChannelCounterparty this_ptr_conv;
23922         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23923         this_ptr_conv.is_owned = false;
23924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23925         int64_t ret_val = ChannelCounterparty_get_unspendable_punishment_reserve(&this_ptr_conv);
23926         return ret_val;
23927 }
23928
23929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23930         LDKChannelCounterparty this_ptr_conv;
23931         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23932         this_ptr_conv.is_owned = false;
23933         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23934         ChannelCounterparty_set_unspendable_punishment_reserve(&this_ptr_conv, val);
23935 }
23936
23937 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1get_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
23938         LDKChannelCounterparty this_ptr_conv;
23939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23940         this_ptr_conv.is_owned = false;
23941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23942         LDKCounterpartyForwardingInfo ret_var = ChannelCounterparty_get_forwarding_info(&this_ptr_conv);
23943         uint64_t ret_ref = 0;
23944         if ((uint64_t)ret_var.inner > 4096) {
23945                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23946                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23947         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23948                 ret_ref = (uint64_t)ret_var.inner;
23949                 if (ret_var.is_owned) {
23950                         ret_ref |= 1;
23951                 }
23952         }
23953         return ret_ref;
23954 }
23955
23956 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1set_1forwarding_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
23957         LDKChannelCounterparty this_ptr_conv;
23958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
23959         this_ptr_conv.is_owned = false;
23960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
23961         LDKCounterpartyForwardingInfo val_conv;
23962         val_conv.inner = (void*)(val & (~1));
23963         val_conv.is_owned = (val & 1) || (val == 0);
23964         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
23965         val_conv = CounterpartyForwardingInfo_clone(&val_conv);
23966         ChannelCounterparty_set_forwarding_info(&this_ptr_conv, val_conv);
23967 }
23968
23969 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) {
23970         LDKPublicKey node_id_arg_ref;
23971         CHECK((*env)->GetArrayLength(env, node_id_arg) == 33);
23972         (*env)->GetByteArrayRegion(env, node_id_arg, 0, 33, node_id_arg_ref.compressed_form);
23973         LDKInitFeatures features_arg_conv;
23974         features_arg_conv.inner = (void*)(features_arg & (~1));
23975         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
23976         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
23977         features_arg_conv = InitFeatures_clone(&features_arg_conv);
23978         LDKCounterpartyForwardingInfo forwarding_info_arg_conv;
23979         forwarding_info_arg_conv.inner = (void*)(forwarding_info_arg & (~1));
23980         forwarding_info_arg_conv.is_owned = (forwarding_info_arg & 1) || (forwarding_info_arg == 0);
23981         CHECK_INNER_FIELD_ACCESS_OR_NULL(forwarding_info_arg_conv);
23982         forwarding_info_arg_conv = CounterpartyForwardingInfo_clone(&forwarding_info_arg_conv);
23983         LDKChannelCounterparty ret_var = ChannelCounterparty_new(node_id_arg_ref, features_arg_conv, unspendable_punishment_reserve_arg, forwarding_info_arg_conv);
23984         uint64_t ret_ref = 0;
23985         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23986         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
23987         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
23988         ret_ref = (uint64_t)ret_var.inner;
23989         if (ret_var.is_owned) {
23990                 ret_ref |= 1;
23991         }
23992         return ret_ref;
23993 }
23994
23995 static inline uint64_t ChannelCounterparty_clone_ptr(LDKChannelCounterparty *NONNULL_PTR arg) {
23996         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(arg);
23997 uint64_t ret_ref = 0;
23998 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
23999 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24000 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24001 ret_ref = (uint64_t)ret_var.inner;
24002 if (ret_var.is_owned) {
24003         ret_ref |= 1;
24004 }
24005         return ret_ref;
24006 }
24007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24008         LDKChannelCounterparty arg_conv;
24009         arg_conv.inner = (void*)(arg & (~1));
24010         arg_conv.is_owned = false;
24011         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24012         int64_t ret_val = ChannelCounterparty_clone_ptr(&arg_conv);
24013         return ret_val;
24014 }
24015
24016 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelCounterparty_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24017         LDKChannelCounterparty orig_conv;
24018         orig_conv.inner = (void*)(orig & (~1));
24019         orig_conv.is_owned = false;
24020         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24021         LDKChannelCounterparty ret_var = ChannelCounterparty_clone(&orig_conv);
24022         uint64_t ret_ref = 0;
24023         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24024         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24025         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24026         ret_ref = (uint64_t)ret_var.inner;
24027         if (ret_var.is_owned) {
24028                 ret_ref |= 1;
24029         }
24030         return ret_ref;
24031 }
24032
24033 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
24034         LDKChannelDetails this_obj_conv;
24035         this_obj_conv.inner = (void*)(this_obj & (~1));
24036         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
24037         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
24038         ChannelDetails_free(this_obj_conv);
24039 }
24040
24041 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24042         LDKChannelDetails this_ptr_conv;
24043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24044         this_ptr_conv.is_owned = false;
24045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24046         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
24047         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelDetails_get_channel_id(&this_ptr_conv));
24048         return ret_arr;
24049 }
24050
24051 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
24052         LDKChannelDetails this_ptr_conv;
24053         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24054         this_ptr_conv.is_owned = false;
24055         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24056         LDKThirtyTwoBytes val_ref;
24057         CHECK((*env)->GetArrayLength(env, val) == 32);
24058         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
24059         ChannelDetails_set_channel_id(&this_ptr_conv, val_ref);
24060 }
24061
24062 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr) {
24063         LDKChannelDetails this_ptr_conv;
24064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24065         this_ptr_conv.is_owned = false;
24066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24067         LDKChannelCounterparty ret_var = ChannelDetails_get_counterparty(&this_ptr_conv);
24068         uint64_t ret_ref = 0;
24069         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24070         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24071         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24072         ret_ref = (uint64_t)ret_var.inner;
24073         if (ret_var.is_owned) {
24074                 ret_ref |= 1;
24075         }
24076         return ret_ref;
24077 }
24078
24079 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1counterparty(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24080         LDKChannelDetails this_ptr_conv;
24081         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24082         this_ptr_conv.is_owned = false;
24083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24084         LDKChannelCounterparty val_conv;
24085         val_conv.inner = (void*)(val & (~1));
24086         val_conv.is_owned = (val & 1) || (val == 0);
24087         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24088         val_conv = ChannelCounterparty_clone(&val_conv);
24089         ChannelDetails_set_counterparty(&this_ptr_conv, val_conv);
24090 }
24091
24092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr) {
24093         LDKChannelDetails this_ptr_conv;
24094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24095         this_ptr_conv.is_owned = false;
24096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24097         LDKOutPoint ret_var = ChannelDetails_get_funding_txo(&this_ptr_conv);
24098         uint64_t ret_ref = 0;
24099         if ((uint64_t)ret_var.inner > 4096) {
24100                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24101                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24103                 ret_ref = (uint64_t)ret_var.inner;
24104                 if (ret_var.is_owned) {
24105                         ret_ref |= 1;
24106                 }
24107         }
24108         return ret_ref;
24109 }
24110
24111 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1funding_1txo(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24112         LDKChannelDetails this_ptr_conv;
24113         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24114         this_ptr_conv.is_owned = false;
24115         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24116         LDKOutPoint val_conv;
24117         val_conv.inner = (void*)(val & (~1));
24118         val_conv.is_owned = (val & 1) || (val == 0);
24119         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
24120         val_conv = OutPoint_clone(&val_conv);
24121         ChannelDetails_set_funding_txo(&this_ptr_conv, val_conv);
24122 }
24123
24124 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24125         LDKChannelDetails this_ptr_conv;
24126         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24127         this_ptr_conv.is_owned = false;
24128         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24129         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24130         *ret_copy = ChannelDetails_get_short_channel_id(&this_ptr_conv);
24131         uint64_t ret_ref = (uint64_t)ret_copy;
24132         return ret_ref;
24133 }
24134
24135 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24136         LDKChannelDetails this_ptr_conv;
24137         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24138         this_ptr_conv.is_owned = false;
24139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24140         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24141         CHECK_ACCESS(val_ptr);
24142         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24143         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24144         ChannelDetails_set_short_channel_id(&this_ptr_conv, val_conv);
24145 }
24146
24147 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
24148         LDKChannelDetails this_ptr_conv;
24149         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24150         this_ptr_conv.is_owned = false;
24151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24152         int64_t ret_val = ChannelDetails_get_channel_value_satoshis(&this_ptr_conv);
24153         return ret_val;
24154 }
24155
24156 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1channel_1value_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24157         LDKChannelDetails this_ptr_conv;
24158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24159         this_ptr_conv.is_owned = false;
24160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24161         ChannelDetails_set_channel_value_satoshis(&this_ptr_conv, val);
24162 }
24163
24164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr) {
24165         LDKChannelDetails this_ptr_conv;
24166         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24167         this_ptr_conv.is_owned = false;
24168         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24169         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
24170         *ret_copy = ChannelDetails_get_unspendable_punishment_reserve(&this_ptr_conv);
24171         uint64_t ret_ref = (uint64_t)ret_copy;
24172         return ret_ref;
24173 }
24174
24175 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1unspendable_1punishment_1reserve(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24176         LDKChannelDetails this_ptr_conv;
24177         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24178         this_ptr_conv.is_owned = false;
24179         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24180         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24181         CHECK_ACCESS(val_ptr);
24182         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
24183         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
24184         ChannelDetails_set_unspendable_punishment_reserve(&this_ptr_conv, val_conv);
24185 }
24186
24187 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
24188         LDKChannelDetails this_ptr_conv;
24189         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24190         this_ptr_conv.is_owned = false;
24191         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24192         int64_t ret_val = ChannelDetails_get_user_channel_id(&this_ptr_conv);
24193         return ret_val;
24194 }
24195
24196 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1user_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24197         LDKChannelDetails this_ptr_conv;
24198         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24199         this_ptr_conv.is_owned = false;
24200         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24201         ChannelDetails_set_user_channel_id(&this_ptr_conv, val);
24202 }
24203
24204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24205         LDKChannelDetails this_ptr_conv;
24206         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24207         this_ptr_conv.is_owned = false;
24208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24209         int64_t ret_val = ChannelDetails_get_outbound_capacity_msat(&this_ptr_conv);
24210         return ret_val;
24211 }
24212
24213 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1outbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24214         LDKChannelDetails this_ptr_conv;
24215         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24216         this_ptr_conv.is_owned = false;
24217         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24218         ChannelDetails_set_outbound_capacity_msat(&this_ptr_conv, val);
24219 }
24220
24221 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
24222         LDKChannelDetails this_ptr_conv;
24223         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24224         this_ptr_conv.is_owned = false;
24225         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24226         int64_t ret_val = ChannelDetails_get_inbound_capacity_msat(&this_ptr_conv);
24227         return ret_val;
24228 }
24229
24230 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1inbound_1capacity_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24231         LDKChannelDetails this_ptr_conv;
24232         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24233         this_ptr_conv.is_owned = false;
24234         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24235         ChannelDetails_set_inbound_capacity_msat(&this_ptr_conv, val);
24236 }
24237
24238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr) {
24239         LDKChannelDetails this_ptr_conv;
24240         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24241         this_ptr_conv.is_owned = false;
24242         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24243         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
24244         *ret_copy = ChannelDetails_get_confirmations_required(&this_ptr_conv);
24245         uint64_t ret_ref = (uint64_t)ret_copy;
24246         return ret_ref;
24247 }
24248
24249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1confirmations_1required(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
24250         LDKChannelDetails this_ptr_conv;
24251         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24252         this_ptr_conv.is_owned = false;
24253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24254         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24255         CHECK_ACCESS(val_ptr);
24256         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
24257         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
24258         ChannelDetails_set_confirmations_required(&this_ptr_conv, val_conv);
24259 }
24260
24261 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1force_1close_1spend_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
24262         LDKChannelDetails this_ptr_conv;
24263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24264         this_ptr_conv.is_owned = false;
24265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24266         LDKCOption_u16Z *ret_copy = MALLOC(sizeof(LDKCOption_u16Z), "LDKCOption_u16Z");
24267         *ret_copy = ChannelDetails_get_force_close_spend_delay(&this_ptr_conv);
24268         uint64_t ret_ref = (uint64_t)ret_copy;
24269         return ret_ref;
24270 }
24271
24272 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) {
24273         LDKChannelDetails this_ptr_conv;
24274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24275         this_ptr_conv.is_owned = false;
24276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24277         void* val_ptr = (void*)(((uint64_t)val) & ~1);
24278         CHECK_ACCESS(val_ptr);
24279         LDKCOption_u16Z val_conv = *(LDKCOption_u16Z*)(val_ptr);
24280         val_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)val) & ~1));
24281         ChannelDetails_set_force_close_spend_delay(&this_ptr_conv, val_conv);
24282 }
24283
24284 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr) {
24285         LDKChannelDetails this_ptr_conv;
24286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24287         this_ptr_conv.is_owned = false;
24288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24289         jboolean ret_val = ChannelDetails_get_is_outbound(&this_ptr_conv);
24290         return ret_val;
24291 }
24292
24293 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24294         LDKChannelDetails this_ptr_conv;
24295         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24296         this_ptr_conv.is_owned = false;
24297         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24298         ChannelDetails_set_is_outbound(&this_ptr_conv, val);
24299 }
24300
24301 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr) {
24302         LDKChannelDetails this_ptr_conv;
24303         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24304         this_ptr_conv.is_owned = false;
24305         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24306         jboolean ret_val = ChannelDetails_get_is_funding_locked(&this_ptr_conv);
24307         return ret_val;
24308 }
24309
24310 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1funding_1locked(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24311         LDKChannelDetails this_ptr_conv;
24312         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24313         this_ptr_conv.is_owned = false;
24314         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24315         ChannelDetails_set_is_funding_locked(&this_ptr_conv, val);
24316 }
24317
24318 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr) {
24319         LDKChannelDetails this_ptr_conv;
24320         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24321         this_ptr_conv.is_owned = false;
24322         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24323         jboolean ret_val = ChannelDetails_get_is_usable(&this_ptr_conv);
24324         return ret_val;
24325 }
24326
24327 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1usable(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24328         LDKChannelDetails this_ptr_conv;
24329         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24330         this_ptr_conv.is_owned = false;
24331         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24332         ChannelDetails_set_is_usable(&this_ptr_conv, val);
24333 }
24334
24335 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1get_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr) {
24336         LDKChannelDetails this_ptr_conv;
24337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24338         this_ptr_conv.is_owned = false;
24339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24340         jboolean ret_val = ChannelDetails_get_is_public(&this_ptr_conv);
24341         return ret_val;
24342 }
24343
24344 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1set_1is_1public(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
24345         LDKChannelDetails this_ptr_conv;
24346         this_ptr_conv.inner = (void*)(this_ptr & (~1));
24347         this_ptr_conv.is_owned = false;
24348         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
24349         ChannelDetails_set_is_public(&this_ptr_conv, val);
24350 }
24351
24352 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) {
24353         LDKThirtyTwoBytes channel_id_arg_ref;
24354         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
24355         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
24356         LDKChannelCounterparty counterparty_arg_conv;
24357         counterparty_arg_conv.inner = (void*)(counterparty_arg & (~1));
24358         counterparty_arg_conv.is_owned = (counterparty_arg & 1) || (counterparty_arg == 0);
24359         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_arg_conv);
24360         counterparty_arg_conv = ChannelCounterparty_clone(&counterparty_arg_conv);
24361         LDKOutPoint funding_txo_arg_conv;
24362         funding_txo_arg_conv.inner = (void*)(funding_txo_arg & (~1));
24363         funding_txo_arg_conv.is_owned = (funding_txo_arg & 1) || (funding_txo_arg == 0);
24364         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_txo_arg_conv);
24365         funding_txo_arg_conv = OutPoint_clone(&funding_txo_arg_conv);
24366         void* short_channel_id_arg_ptr = (void*)(((uint64_t)short_channel_id_arg) & ~1);
24367         CHECK_ACCESS(short_channel_id_arg_ptr);
24368         LDKCOption_u64Z short_channel_id_arg_conv = *(LDKCOption_u64Z*)(short_channel_id_arg_ptr);
24369         short_channel_id_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)short_channel_id_arg) & ~1));
24370         void* unspendable_punishment_reserve_arg_ptr = (void*)(((uint64_t)unspendable_punishment_reserve_arg) & ~1);
24371         CHECK_ACCESS(unspendable_punishment_reserve_arg_ptr);
24372         LDKCOption_u64Z unspendable_punishment_reserve_arg_conv = *(LDKCOption_u64Z*)(unspendable_punishment_reserve_arg_ptr);
24373         void* confirmations_required_arg_ptr = (void*)(((uint64_t)confirmations_required_arg) & ~1);
24374         CHECK_ACCESS(confirmations_required_arg_ptr);
24375         LDKCOption_u32Z confirmations_required_arg_conv = *(LDKCOption_u32Z*)(confirmations_required_arg_ptr);
24376         confirmations_required_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)confirmations_required_arg) & ~1));
24377         void* force_close_spend_delay_arg_ptr = (void*)(((uint64_t)force_close_spend_delay_arg) & ~1);
24378         CHECK_ACCESS(force_close_spend_delay_arg_ptr);
24379         LDKCOption_u16Z force_close_spend_delay_arg_conv = *(LDKCOption_u16Z*)(force_close_spend_delay_arg_ptr);
24380         force_close_spend_delay_arg_conv = COption_u16Z_clone((LDKCOption_u16Z*)(((uint64_t)force_close_spend_delay_arg) & ~1));
24381         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);
24382         uint64_t ret_ref = 0;
24383         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24384         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24386         ret_ref = (uint64_t)ret_var.inner;
24387         if (ret_var.is_owned) {
24388                 ret_ref |= 1;
24389         }
24390         return ret_ref;
24391 }
24392
24393 static inline uint64_t ChannelDetails_clone_ptr(LDKChannelDetails *NONNULL_PTR arg) {
24394         LDKChannelDetails ret_var = ChannelDetails_clone(arg);
24395 uint64_t ret_ref = 0;
24396 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24397 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24398 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24399 ret_ref = (uint64_t)ret_var.inner;
24400 if (ret_var.is_owned) {
24401         ret_ref |= 1;
24402 }
24403         return ret_ref;
24404 }
24405 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24406         LDKChannelDetails arg_conv;
24407         arg_conv.inner = (void*)(arg & (~1));
24408         arg_conv.is_owned = false;
24409         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
24410         int64_t ret_val = ChannelDetails_clone_ptr(&arg_conv);
24411         return ret_val;
24412 }
24413
24414 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelDetails_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24415         LDKChannelDetails orig_conv;
24416         orig_conv.inner = (void*)(orig & (~1));
24417         orig_conv.is_owned = false;
24418         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
24419         LDKChannelDetails ret_var = ChannelDetails_clone(&orig_conv);
24420         uint64_t ret_ref = 0;
24421         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24422         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24423         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24424         ret_ref = (uint64_t)ret_var.inner;
24425         if (ret_var.is_owned) {
24426                 ret_ref |= 1;
24427         }
24428         return ret_ref;
24429 }
24430
24431 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
24432         if ((this_ptr & 1) != 0) return;
24433         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
24434         CHECK_ACCESS(this_ptr_ptr);
24435         LDKPaymentSendFailure this_ptr_conv = *(LDKPaymentSendFailure*)(this_ptr_ptr);
24436         FREE((void*)this_ptr);
24437         PaymentSendFailure_free(this_ptr_conv);
24438 }
24439
24440 static inline uint64_t PaymentSendFailure_clone_ptr(LDKPaymentSendFailure *NONNULL_PTR arg) {
24441         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24442         *ret_copy = PaymentSendFailure_clone(arg);
24443 uint64_t ret_ref = (uint64_t)ret_copy;
24444         return ret_ref;
24445 }
24446 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
24447         LDKPaymentSendFailure* arg_conv = (LDKPaymentSendFailure*)arg;
24448         int64_t ret_val = PaymentSendFailure_clone_ptr(arg_conv);
24449         return ret_val;
24450 }
24451
24452 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1clone(JNIEnv *env, jclass clz, int64_t orig) {
24453         LDKPaymentSendFailure* orig_conv = (LDKPaymentSendFailure*)orig;
24454         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24455         *ret_copy = PaymentSendFailure_clone(orig_conv);
24456         uint64_t ret_ref = (uint64_t)ret_copy;
24457         return ret_ref;
24458 }
24459
24460 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1parameter_1error(JNIEnv *env, jclass clz, int64_t a) {
24461         void* a_ptr = (void*)(((uint64_t)a) & ~1);
24462         CHECK_ACCESS(a_ptr);
24463         LDKAPIError a_conv = *(LDKAPIError*)(a_ptr);
24464         a_conv = APIError_clone((LDKAPIError*)(((uint64_t)a) & ~1));
24465         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24466         *ret_copy = PaymentSendFailure_parameter_error(a_conv);
24467         uint64_t ret_ref = (uint64_t)ret_copy;
24468         return ret_ref;
24469 }
24470
24471 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1path_1parameter_1error(JNIEnv *env, jclass clz, int64_tArray a) {
24472         LDKCVec_CResult_NoneAPIErrorZZ a_constr;
24473         a_constr.datalen = (*env)->GetArrayLength(env, a);
24474         if (a_constr.datalen > 0)
24475                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24476         else
24477                 a_constr.data = NULL;
24478         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
24479         for (size_t w = 0; w < a_constr.datalen; w++) {
24480                 int64_t a_conv_22 = a_vals[w];
24481                 void* a_conv_22_ptr = (void*)(((uint64_t)a_conv_22) & ~1);
24482                 CHECK_ACCESS(a_conv_22_ptr);
24483                 LDKCResult_NoneAPIErrorZ a_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(a_conv_22_ptr);
24484                 a_conv_22_conv = CResult_NoneAPIErrorZ_clone((LDKCResult_NoneAPIErrorZ*)(((uint64_t)a_conv_22) & ~1));
24485                 a_constr.data[w] = a_conv_22_conv;
24486         }
24487         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
24488         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24489         *ret_copy = PaymentSendFailure_path_parameter_error(a_constr);
24490         uint64_t ret_ref = (uint64_t)ret_copy;
24491         return ret_ref;
24492 }
24493
24494 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentSendFailure_1all_1failed_1retry_1safe(JNIEnv *env, jclass clz, int64_tArray a) {
24495         LDKCVec_APIErrorZ a_constr;
24496         a_constr.datalen = (*env)->GetArrayLength(env, a);
24497         if (a_constr.datalen > 0)
24498                 a_constr.data = MALLOC(a_constr.datalen * sizeof(LDKAPIError), "LDKCVec_APIErrorZ Elements");
24499         else
24500                 a_constr.data = NULL;
24501         int64_t* a_vals = (*env)->GetLongArrayElements (env, a, NULL);
24502         for (size_t k = 0; k < a_constr.datalen; k++) {
24503                 int64_t a_conv_10 = a_vals[k];
24504                 void* a_conv_10_ptr = (void*)(((uint64_t)a_conv_10) & ~1);
24505                 CHECK_ACCESS(a_conv_10_ptr);
24506                 LDKAPIError a_conv_10_conv = *(LDKAPIError*)(a_conv_10_ptr);
24507                 a_conv_10_conv = APIError_clone((LDKAPIError*)(((uint64_t)a_conv_10) & ~1));
24508                 a_constr.data[k] = a_conv_10_conv;
24509         }
24510         (*env)->ReleaseLongArrayElements(env, a, a_vals, 0);
24511         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24512         *ret_copy = PaymentSendFailure_all_failed_retry_safe(a_constr);
24513         uint64_t ret_ref = (uint64_t)ret_copy;
24514         return ret_ref;
24515 }
24516
24517 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) {
24518         LDKCVec_CResult_NoneAPIErrorZZ results_constr;
24519         results_constr.datalen = (*env)->GetArrayLength(env, results);
24520         if (results_constr.datalen > 0)
24521                 results_constr.data = MALLOC(results_constr.datalen * sizeof(LDKCResult_NoneAPIErrorZ), "LDKCVec_CResult_NoneAPIErrorZZ Elements");
24522         else
24523                 results_constr.data = NULL;
24524         int64_t* results_vals = (*env)->GetLongArrayElements (env, results, NULL);
24525         for (size_t w = 0; w < results_constr.datalen; w++) {
24526                 int64_t results_conv_22 = results_vals[w];
24527                 void* results_conv_22_ptr = (void*)(((uint64_t)results_conv_22) & ~1);
24528                 CHECK_ACCESS(results_conv_22_ptr);
24529                 LDKCResult_NoneAPIErrorZ results_conv_22_conv = *(LDKCResult_NoneAPIErrorZ*)(results_conv_22_ptr);
24530                 results_constr.data[w] = results_conv_22_conv;
24531         }
24532         (*env)->ReleaseLongArrayElements(env, results, results_vals, 0);
24533         LDKRouteParameters failed_paths_retry_conv;
24534         failed_paths_retry_conv.inner = (void*)(failed_paths_retry & (~1));
24535         failed_paths_retry_conv.is_owned = (failed_paths_retry & 1) || (failed_paths_retry == 0);
24536         CHECK_INNER_FIELD_ACCESS_OR_NULL(failed_paths_retry_conv);
24537         failed_paths_retry_conv = RouteParameters_clone(&failed_paths_retry_conv);
24538         LDKThirtyTwoBytes payment_id_ref;
24539         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24540         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24541         LDKPaymentSendFailure *ret_copy = MALLOC(sizeof(LDKPaymentSendFailure), "LDKPaymentSendFailure");
24542         *ret_copy = PaymentSendFailure_partial_failure(results_constr, failed_paths_retry_conv, payment_id_ref);
24543         uint64_t ret_ref = (uint64_t)ret_copy;
24544         return ret_ref;
24545 }
24546
24547 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) {
24548         void* fee_est_ptr = (void*)(((uint64_t)fee_est) & ~1);
24549         CHECK_ACCESS(fee_est_ptr);
24550         LDKFeeEstimator fee_est_conv = *(LDKFeeEstimator*)(fee_est_ptr);
24551         if (fee_est_conv.free == LDKFeeEstimator_JCalls_free) {
24552                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24553                 LDKFeeEstimator_JCalls_cloned(&fee_est_conv);
24554         }
24555         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
24556         CHECK_ACCESS(chain_monitor_ptr);
24557         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
24558         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
24559                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24560                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
24561         }
24562         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
24563         CHECK_ACCESS(tx_broadcaster_ptr);
24564         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
24565         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
24566                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24567                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
24568         }
24569         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
24570         CHECK_ACCESS(logger_ptr);
24571         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
24572         if (logger_conv.free == LDKLogger_JCalls_free) {
24573                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24574                 LDKLogger_JCalls_cloned(&logger_conv);
24575         }
24576         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
24577         CHECK_ACCESS(keys_manager_ptr);
24578         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
24579         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
24580                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
24581                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
24582         }
24583         LDKUserConfig config_conv;
24584         config_conv.inner = (void*)(config & (~1));
24585         config_conv.is_owned = (config & 1) || (config == 0);
24586         CHECK_INNER_FIELD_ACCESS_OR_NULL(config_conv);
24587         config_conv = UserConfig_clone(&config_conv);
24588         LDKChainParameters params_conv;
24589         params_conv.inner = (void*)(params & (~1));
24590         params_conv.is_owned = (params & 1) || (params == 0);
24591         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
24592         params_conv = ChainParameters_clone(&params_conv);
24593         LDKChannelManager ret_var = ChannelManager_new(fee_est_conv, chain_monitor_conv, tx_broadcaster_conv, logger_conv, keys_manager_conv, config_conv, params_conv);
24594         uint64_t ret_ref = 0;
24595         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24596         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24597         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24598         ret_ref = (uint64_t)ret_var.inner;
24599         if (ret_var.is_owned) {
24600                 ret_ref |= 1;
24601         }
24602         return ret_ref;
24603 }
24604
24605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1current_1default_1configuration(JNIEnv *env, jclass clz, int64_t this_arg) {
24606         LDKChannelManager this_arg_conv;
24607         this_arg_conv.inner = (void*)(this_arg & (~1));
24608         this_arg_conv.is_owned = false;
24609         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24610         LDKUserConfig ret_var = ChannelManager_get_current_default_configuration(&this_arg_conv);
24611         uint64_t ret_ref = 0;
24612         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24613         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24614         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24615         ret_ref = (uint64_t)ret_var.inner;
24616         if (ret_var.is_owned) {
24617                 ret_ref |= 1;
24618         }
24619         return ret_ref;
24620 }
24621
24622 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) {
24623         LDKChannelManager this_arg_conv;
24624         this_arg_conv.inner = (void*)(this_arg & (~1));
24625         this_arg_conv.is_owned = false;
24626         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24627         LDKPublicKey their_network_key_ref;
24628         CHECK((*env)->GetArrayLength(env, their_network_key) == 33);
24629         (*env)->GetByteArrayRegion(env, their_network_key, 0, 33, their_network_key_ref.compressed_form);
24630         LDKUserConfig override_config_conv;
24631         override_config_conv.inner = (void*)(override_config & (~1));
24632         override_config_conv.is_owned = (override_config & 1) || (override_config == 0);
24633         CHECK_INNER_FIELD_ACCESS_OR_NULL(override_config_conv);
24634         override_config_conv = UserConfig_clone(&override_config_conv);
24635         LDKCResult__u832APIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult__u832APIErrorZ), "LDKCResult__u832APIErrorZ");
24636         *ret_conv = ChannelManager_create_channel(&this_arg_conv, their_network_key_ref, channel_value_satoshis, push_msat, user_channel_id, override_config_conv);
24637         return (uint64_t)ret_conv;
24638 }
24639
24640 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
24641         LDKChannelManager this_arg_conv;
24642         this_arg_conv.inner = (void*)(this_arg & (~1));
24643         this_arg_conv.is_owned = false;
24644         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24645         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_channels(&this_arg_conv);
24646         int64_tArray ret_arr = NULL;
24647         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24648         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24649         for (size_t q = 0; q < ret_var.datalen; q++) {
24650                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24651                 uint64_t ret_conv_16_ref = 0;
24652                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24653                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24654                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24655                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
24656                 if (ret_conv_16_var.is_owned) {
24657                         ret_conv_16_ref |= 1;
24658                 }
24659                 ret_arr_ptr[q] = ret_conv_16_ref;
24660         }
24661         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24662         FREE(ret_var.data);
24663         return ret_arr;
24664 }
24665
24666 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1list_1usable_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
24667         LDKChannelManager this_arg_conv;
24668         this_arg_conv.inner = (void*)(this_arg & (~1));
24669         this_arg_conv.is_owned = false;
24670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24671         LDKCVec_ChannelDetailsZ ret_var = ChannelManager_list_usable_channels(&this_arg_conv);
24672         int64_tArray ret_arr = NULL;
24673         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
24674         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
24675         for (size_t q = 0; q < ret_var.datalen; q++) {
24676                 LDKChannelDetails ret_conv_16_var = ret_var.data[q];
24677                 uint64_t ret_conv_16_ref = 0;
24678                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24679                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24680                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
24681                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
24682                 if (ret_conv_16_var.is_owned) {
24683                         ret_conv_16_ref |= 1;
24684                 }
24685                 ret_arr_ptr[q] = ret_conv_16_ref;
24686         }
24687         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
24688         FREE(ret_var.data);
24689         return ret_arr;
24690 }
24691
24692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1close_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray channel_id) {
24693         LDKChannelManager this_arg_conv;
24694         this_arg_conv.inner = (void*)(this_arg & (~1));
24695         this_arg_conv.is_owned = false;
24696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24697         unsigned char channel_id_arr[32];
24698         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24699         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
24700         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24701         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24702         *ret_conv = ChannelManager_close_channel(&this_arg_conv, channel_id_ref);
24703         return (uint64_t)ret_conv;
24704 }
24705
24706 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) {
24707         LDKChannelManager this_arg_conv;
24708         this_arg_conv.inner = (void*)(this_arg & (~1));
24709         this_arg_conv.is_owned = false;
24710         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24711         unsigned char channel_id_arr[32];
24712         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24713         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
24714         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24715         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24716         *ret_conv = ChannelManager_close_channel_with_target_feerate(&this_arg_conv, channel_id_ref, target_feerate_sats_per_1000_weight);
24717         return (uint64_t)ret_conv;
24718 }
24719
24720 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) {
24721         LDKChannelManager this_arg_conv;
24722         this_arg_conv.inner = (void*)(this_arg & (~1));
24723         this_arg_conv.is_owned = false;
24724         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24725         unsigned char channel_id_arr[32];
24726         CHECK((*env)->GetArrayLength(env, channel_id) == 32);
24727         (*env)->GetByteArrayRegion(env, channel_id, 0, 32, channel_id_arr);
24728         unsigned char (*channel_id_ref)[32] = &channel_id_arr;
24729         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24730         *ret_conv = ChannelManager_force_close_channel(&this_arg_conv, channel_id_ref);
24731         return (uint64_t)ret_conv;
24732 }
24733
24734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1force_1close_1all_1channels(JNIEnv *env, jclass clz, int64_t this_arg) {
24735         LDKChannelManager this_arg_conv;
24736         this_arg_conv.inner = (void*)(this_arg & (~1));
24737         this_arg_conv.is_owned = false;
24738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24739         ChannelManager_force_close_all_channels(&this_arg_conv);
24740 }
24741
24742 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) {
24743         LDKChannelManager this_arg_conv;
24744         this_arg_conv.inner = (void*)(this_arg & (~1));
24745         this_arg_conv.is_owned = false;
24746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24747         LDKRoute route_conv;
24748         route_conv.inner = (void*)(route & (~1));
24749         route_conv.is_owned = false;
24750         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24751         LDKThirtyTwoBytes payment_hash_ref;
24752         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24753         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24754         LDKThirtyTwoBytes payment_secret_ref;
24755         CHECK((*env)->GetArrayLength(env, payment_secret) == 32);
24756         (*env)->GetByteArrayRegion(env, payment_secret, 0, 32, payment_secret_ref.data);
24757         LDKCResult_PaymentIdPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentSendFailureZ), "LDKCResult_PaymentIdPaymentSendFailureZ");
24758         *ret_conv = ChannelManager_send_payment(&this_arg_conv, &route_conv, payment_hash_ref, payment_secret_ref);
24759         return (uint64_t)ret_conv;
24760 }
24761
24762 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) {
24763         LDKChannelManager this_arg_conv;
24764         this_arg_conv.inner = (void*)(this_arg & (~1));
24765         this_arg_conv.is_owned = false;
24766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24767         LDKRoute route_conv;
24768         route_conv.inner = (void*)(route & (~1));
24769         route_conv.is_owned = false;
24770         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24771         LDKThirtyTwoBytes payment_id_ref;
24772         CHECK((*env)->GetArrayLength(env, payment_id) == 32);
24773         (*env)->GetByteArrayRegion(env, payment_id, 0, 32, payment_id_ref.data);
24774         LDKCResult_NonePaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePaymentSendFailureZ), "LDKCResult_NonePaymentSendFailureZ");
24775         *ret_conv = ChannelManager_retry_payment(&this_arg_conv, &route_conv, payment_id_ref);
24776         return (uint64_t)ret_conv;
24777 }
24778
24779 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) {
24780         LDKChannelManager this_arg_conv;
24781         this_arg_conv.inner = (void*)(this_arg & (~1));
24782         this_arg_conv.is_owned = false;
24783         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24784         LDKRoute route_conv;
24785         route_conv.inner = (void*)(route & (~1));
24786         route_conv.is_owned = false;
24787         CHECK_INNER_FIELD_ACCESS_OR_NULL(route_conv);
24788         LDKThirtyTwoBytes payment_preimage_ref;
24789         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24790         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24791         LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ), "LDKCResult_C2Tuple_PaymentHashPaymentIdZPaymentSendFailureZ");
24792         *ret_conv = ChannelManager_send_spontaneous_payment(&this_arg_conv, &route_conv, payment_preimage_ref);
24793         return (uint64_t)ret_conv;
24794 }
24795
24796 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) {
24797         LDKChannelManager this_arg_conv;
24798         this_arg_conv.inner = (void*)(this_arg & (~1));
24799         this_arg_conv.is_owned = false;
24800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24801         unsigned char temporary_channel_id_arr[32];
24802         CHECK((*env)->GetArrayLength(env, temporary_channel_id) == 32);
24803         (*env)->GetByteArrayRegion(env, temporary_channel_id, 0, 32, temporary_channel_id_arr);
24804         unsigned char (*temporary_channel_id_ref)[32] = &temporary_channel_id_arr;
24805         LDKTransaction funding_transaction_ref;
24806         funding_transaction_ref.datalen = (*env)->GetArrayLength(env, funding_transaction);
24807         funding_transaction_ref.data = MALLOC(funding_transaction_ref.datalen, "LDKTransaction Bytes");
24808         (*env)->GetByteArrayRegion(env, funding_transaction, 0, funding_transaction_ref.datalen, funding_transaction_ref.data);
24809         funding_transaction_ref.data_is_owned = true;
24810         LDKCResult_NoneAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneAPIErrorZ), "LDKCResult_NoneAPIErrorZ");
24811         *ret_conv = ChannelManager_funding_transaction_generated(&this_arg_conv, temporary_channel_id_ref, funding_transaction_ref);
24812         return (uint64_t)ret_conv;
24813 }
24814
24815 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) {
24816         LDKChannelManager this_arg_conv;
24817         this_arg_conv.inner = (void*)(this_arg & (~1));
24818         this_arg_conv.is_owned = false;
24819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24820         LDKThreeBytes rgb_ref;
24821         CHECK((*env)->GetArrayLength(env, rgb) == 3);
24822         (*env)->GetByteArrayRegion(env, rgb, 0, 3, rgb_ref.data);
24823         LDKThirtyTwoBytes alias_ref;
24824         CHECK((*env)->GetArrayLength(env, alias) == 32);
24825         (*env)->GetByteArrayRegion(env, alias, 0, 32, alias_ref.data);
24826         LDKCVec_NetAddressZ addresses_constr;
24827         addresses_constr.datalen = (*env)->GetArrayLength(env, addresses);
24828         if (addresses_constr.datalen > 0)
24829                 addresses_constr.data = MALLOC(addresses_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
24830         else
24831                 addresses_constr.data = NULL;
24832         int64_t* addresses_vals = (*env)->GetLongArrayElements (env, addresses, NULL);
24833         for (size_t m = 0; m < addresses_constr.datalen; m++) {
24834                 int64_t addresses_conv_12 = addresses_vals[m];
24835                 void* addresses_conv_12_ptr = (void*)(((uint64_t)addresses_conv_12) & ~1);
24836                 CHECK_ACCESS(addresses_conv_12_ptr);
24837                 LDKNetAddress addresses_conv_12_conv = *(LDKNetAddress*)(addresses_conv_12_ptr);
24838                 addresses_constr.data[m] = addresses_conv_12_conv;
24839         }
24840         (*env)->ReleaseLongArrayElements(env, addresses, addresses_vals, 0);
24841         ChannelManager_broadcast_node_announcement(&this_arg_conv, rgb_ref, alias_ref, addresses_constr);
24842 }
24843
24844 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1process_1pending_1htlc_1forwards(JNIEnv *env, jclass clz, int64_t this_arg) {
24845         LDKChannelManager this_arg_conv;
24846         this_arg_conv.inner = (void*)(this_arg & (~1));
24847         this_arg_conv.is_owned = false;
24848         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24849         ChannelManager_process_pending_htlc_forwards(&this_arg_conv);
24850 }
24851
24852 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
24853         LDKChannelManager this_arg_conv;
24854         this_arg_conv.inner = (void*)(this_arg & (~1));
24855         this_arg_conv.is_owned = false;
24856         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24857         ChannelManager_timer_tick_occurred(&this_arg_conv);
24858 }
24859
24860 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1fail_1htlc_1backwards(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
24861         LDKChannelManager this_arg_conv;
24862         this_arg_conv.inner = (void*)(this_arg & (~1));
24863         this_arg_conv.is_owned = false;
24864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24865         unsigned char payment_hash_arr[32];
24866         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24867         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
24868         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
24869         jboolean ret_val = ChannelManager_fail_htlc_backwards(&this_arg_conv, payment_hash_ref);
24870         return ret_val;
24871 }
24872
24873 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelManager_1claim_1funds(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_preimage) {
24874         LDKChannelManager this_arg_conv;
24875         this_arg_conv.inner = (void*)(this_arg & (~1));
24876         this_arg_conv.is_owned = false;
24877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24878         LDKThirtyTwoBytes payment_preimage_ref;
24879         CHECK((*env)->GetArrayLength(env, payment_preimage) == 32);
24880         (*env)->GetByteArrayRegion(env, payment_preimage, 0, 32, payment_preimage_ref.data);
24881         jboolean ret_val = ChannelManager_claim_funds(&this_arg_conv, payment_preimage_ref);
24882         return ret_val;
24883 }
24884
24885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1get_1our_1node_1id(JNIEnv *env, jclass clz, int64_t this_arg) {
24886         LDKChannelManager this_arg_conv;
24887         this_arg_conv.inner = (void*)(this_arg & (~1));
24888         this_arg_conv.is_owned = false;
24889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24890         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
24891         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelManager_get_our_node_id(&this_arg_conv).compressed_form);
24892         return ret_arr;
24893 }
24894
24895 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) {
24896         LDKChannelManager this_arg_conv;
24897         this_arg_conv.inner = (void*)(this_arg & (~1));
24898         this_arg_conv.is_owned = false;
24899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24900         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
24901         CHECK_ACCESS(min_value_msat_ptr);
24902         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
24903         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
24904         LDKC2Tuple_PaymentHashPaymentSecretZ* ret_conv = MALLOC(sizeof(LDKC2Tuple_PaymentHashPaymentSecretZ), "LDKC2Tuple_PaymentHashPaymentSecretZ");
24905         *ret_conv = ChannelManager_create_inbound_payment(&this_arg_conv, min_value_msat_conv, invoice_expiry_delta_secs, user_payment_id);
24906         return ((uint64_t)ret_conv);
24907 }
24908
24909 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) {
24910         LDKChannelManager this_arg_conv;
24911         this_arg_conv.inner = (void*)(this_arg & (~1));
24912         this_arg_conv.is_owned = false;
24913         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24914         LDKThirtyTwoBytes payment_hash_ref;
24915         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
24916         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_ref.data);
24917         void* min_value_msat_ptr = (void*)(((uint64_t)min_value_msat) & ~1);
24918         CHECK_ACCESS(min_value_msat_ptr);
24919         LDKCOption_u64Z min_value_msat_conv = *(LDKCOption_u64Z*)(min_value_msat_ptr);
24920         min_value_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)min_value_msat) & ~1));
24921         LDKCResult_PaymentSecretAPIErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentSecretAPIErrorZ), "LDKCResult_PaymentSecretAPIErrorZ");
24922         *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);
24923         return (uint64_t)ret_conv;
24924 }
24925
24926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24927         LDKChannelManager this_arg_conv;
24928         this_arg_conv.inner = (void*)(this_arg & (~1));
24929         this_arg_conv.is_owned = false;
24930         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24931         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
24932         *ret_ret = ChannelManager_as_MessageSendEventsProvider(&this_arg_conv);
24933         return (uint64_t)ret_ret;
24934 }
24935
24936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1EventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
24937         LDKChannelManager this_arg_conv;
24938         this_arg_conv.inner = (void*)(this_arg & (~1));
24939         this_arg_conv.is_owned = false;
24940         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24941         LDKEventsProvider* ret_ret = MALLOC(sizeof(LDKEventsProvider), "LDKEventsProvider");
24942         *ret_ret = ChannelManager_as_EventsProvider(&this_arg_conv);
24943         return (uint64_t)ret_ret;
24944 }
24945
24946 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Listen(JNIEnv *env, jclass clz, int64_t this_arg) {
24947         LDKChannelManager this_arg_conv;
24948         this_arg_conv.inner = (void*)(this_arg & (~1));
24949         this_arg_conv.is_owned = false;
24950         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24951         LDKListen* ret_ret = MALLOC(sizeof(LDKListen), "LDKListen");
24952         *ret_ret = ChannelManager_as_Listen(&this_arg_conv);
24953         return (uint64_t)ret_ret;
24954 }
24955
24956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Confirm(JNIEnv *env, jclass clz, int64_t this_arg) {
24957         LDKChannelManager this_arg_conv;
24958         this_arg_conv.inner = (void*)(this_arg & (~1));
24959         this_arg_conv.is_owned = false;
24960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24961         LDKConfirm* ret_ret = MALLOC(sizeof(LDKConfirm), "LDKConfirm");
24962         *ret_ret = ChannelManager_as_Confirm(&this_arg_conv);
24963         return (uint64_t)ret_ret;
24964 }
24965
24966 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) {
24967         LDKChannelManager this_arg_conv;
24968         this_arg_conv.inner = (void*)(this_arg & (~1));
24969         this_arg_conv.is_owned = false;
24970         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24971         jboolean ret_val = ChannelManager_await_persistable_update_timeout(&this_arg_conv, max_wait);
24972         return ret_val;
24973 }
24974
24975 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManager_1await_1persistable_1update(JNIEnv *env, jclass clz, int64_t this_arg) {
24976         LDKChannelManager this_arg_conv;
24977         this_arg_conv.inner = (void*)(this_arg & (~1));
24978         this_arg_conv.is_owned = false;
24979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24980         ChannelManager_await_persistable_update(&this_arg_conv);
24981 }
24982
24983 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1current_1best_1block(JNIEnv *env, jclass clz, int64_t this_arg) {
24984         LDKChannelManager this_arg_conv;
24985         this_arg_conv.inner = (void*)(this_arg & (~1));
24986         this_arg_conv.is_owned = false;
24987         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
24988         LDKBestBlock ret_var = ChannelManager_current_best_block(&this_arg_conv);
24989         uint64_t ret_ref = 0;
24990         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
24991         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
24992         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
24993         ret_ref = (uint64_t)ret_var.inner;
24994         if (ret_var.is_owned) {
24995                 ret_ref |= 1;
24996         }
24997         return ret_ref;
24998 }
24999
25000 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
25001         LDKChannelManager this_arg_conv;
25002         this_arg_conv.inner = (void*)(this_arg & (~1));
25003         this_arg_conv.is_owned = false;
25004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
25005         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
25006         *ret_ret = ChannelManager_as_ChannelMessageHandler(&this_arg_conv);
25007         return (uint64_t)ret_ret;
25008 }
25009
25010 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelManager_1write(JNIEnv *env, jclass clz, int64_t obj) {
25011         LDKChannelManager obj_conv;
25012         obj_conv.inner = (void*)(obj & (~1));
25013         obj_conv.is_owned = false;
25014         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
25015         LDKCVec_u8Z ret_var = ChannelManager_write(&obj_conv);
25016         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
25017         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
25018         CVec_u8Z_free(ret_var);
25019         return ret_arr;
25020 }
25021
25022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25023         LDKChannelManagerReadArgs this_obj_conv;
25024         this_obj_conv.inner = (void*)(this_obj & (~1));
25025         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25027         ChannelManagerReadArgs_free(this_obj_conv);
25028 }
25029
25030 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr) {
25031         LDKChannelManagerReadArgs this_ptr_conv;
25032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25033         this_ptr_conv.is_owned = false;
25034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25035         // WARNING: This object doesn't live past this scope, needs clone!
25036         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_keys_manager(&this_ptr_conv)) | 1;
25037         return ret_ret;
25038 }
25039
25040 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1keys_1manager(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25041         LDKChannelManagerReadArgs this_ptr_conv;
25042         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25043         this_ptr_conv.is_owned = false;
25044         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25045         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25046         CHECK_ACCESS(val_ptr);
25047         LDKKeysInterface val_conv = *(LDKKeysInterface*)(val_ptr);
25048         if (val_conv.free == LDKKeysInterface_JCalls_free) {
25049                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25050                 LDKKeysInterface_JCalls_cloned(&val_conv);
25051         }
25052         ChannelManagerReadArgs_set_keys_manager(&this_ptr_conv, val_conv);
25053 }
25054
25055 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr) {
25056         LDKChannelManagerReadArgs this_ptr_conv;
25057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25058         this_ptr_conv.is_owned = false;
25059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25060         // WARNING: This object doesn't live past this scope, needs clone!
25061         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_fee_estimator(&this_ptr_conv)) | 1;
25062         return ret_ret;
25063 }
25064
25065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1fee_1estimator(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25066         LDKChannelManagerReadArgs this_ptr_conv;
25067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25068         this_ptr_conv.is_owned = false;
25069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25070         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25071         CHECK_ACCESS(val_ptr);
25072         LDKFeeEstimator val_conv = *(LDKFeeEstimator*)(val_ptr);
25073         if (val_conv.free == LDKFeeEstimator_JCalls_free) {
25074                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25075                 LDKFeeEstimator_JCalls_cloned(&val_conv);
25076         }
25077         ChannelManagerReadArgs_set_fee_estimator(&this_ptr_conv, val_conv);
25078 }
25079
25080 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr) {
25081         LDKChannelManagerReadArgs this_ptr_conv;
25082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25083         this_ptr_conv.is_owned = false;
25084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25085         // WARNING: This object doesn't live past this scope, needs clone!
25086         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_chain_monitor(&this_ptr_conv)) | 1;
25087         return ret_ret;
25088 }
25089
25090 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1chain_1monitor(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25091         LDKChannelManagerReadArgs this_ptr_conv;
25092         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25093         this_ptr_conv.is_owned = false;
25094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25095         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25096         CHECK_ACCESS(val_ptr);
25097         LDKWatch val_conv = *(LDKWatch*)(val_ptr);
25098         if (val_conv.free == LDKWatch_JCalls_free) {
25099                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25100                 LDKWatch_JCalls_cloned(&val_conv);
25101         }
25102         ChannelManagerReadArgs_set_chain_monitor(&this_ptr_conv, val_conv);
25103 }
25104
25105 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr) {
25106         LDKChannelManagerReadArgs this_ptr_conv;
25107         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25108         this_ptr_conv.is_owned = false;
25109         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25110         // WARNING: This object doesn't live past this scope, needs clone!
25111         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_tx_broadcaster(&this_ptr_conv)) | 1;
25112         return ret_ret;
25113 }
25114
25115 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1tx_1broadcaster(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25116         LDKChannelManagerReadArgs this_ptr_conv;
25117         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25118         this_ptr_conv.is_owned = false;
25119         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25120         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25121         CHECK_ACCESS(val_ptr);
25122         LDKBroadcasterInterface val_conv = *(LDKBroadcasterInterface*)(val_ptr);
25123         if (val_conv.free == LDKBroadcasterInterface_JCalls_free) {
25124                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25125                 LDKBroadcasterInterface_JCalls_cloned(&val_conv);
25126         }
25127         ChannelManagerReadArgs_set_tx_broadcaster(&this_ptr_conv, val_conv);
25128 }
25129
25130 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1logger(JNIEnv *env, jclass clz, int64_t this_ptr) {
25131         LDKChannelManagerReadArgs this_ptr_conv;
25132         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25133         this_ptr_conv.is_owned = false;
25134         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25135         // WARNING: This object doesn't live past this scope, needs clone!
25136         uint64_t ret_ret = ((uint64_t)ChannelManagerReadArgs_get_logger(&this_ptr_conv)) | 1;
25137         return ret_ret;
25138 }
25139
25140 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1logger(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25141         LDKChannelManagerReadArgs this_ptr_conv;
25142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25143         this_ptr_conv.is_owned = false;
25144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25145         void* val_ptr = (void*)(((uint64_t)val) & ~1);
25146         CHECK_ACCESS(val_ptr);
25147         LDKLogger val_conv = *(LDKLogger*)(val_ptr);
25148         if (val_conv.free == LDKLogger_JCalls_free) {
25149                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25150                 LDKLogger_JCalls_cloned(&val_conv);
25151         }
25152         ChannelManagerReadArgs_set_logger(&this_ptr_conv, val_conv);
25153 }
25154
25155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1get_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr) {
25156         LDKChannelManagerReadArgs this_ptr_conv;
25157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25158         this_ptr_conv.is_owned = false;
25159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25160         LDKUserConfig ret_var = ChannelManagerReadArgs_get_default_config(&this_ptr_conv);
25161         uint64_t ret_ref = 0;
25162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25165         ret_ref = (uint64_t)ret_var.inner;
25166         if (ret_var.is_owned) {
25167                 ret_ref |= 1;
25168         }
25169         return ret_ref;
25170 }
25171
25172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerReadArgs_1set_1default_1config(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25173         LDKChannelManagerReadArgs this_ptr_conv;
25174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25175         this_ptr_conv.is_owned = false;
25176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25177         LDKUserConfig val_conv;
25178         val_conv.inner = (void*)(val & (~1));
25179         val_conv.is_owned = (val & 1) || (val == 0);
25180         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25181         val_conv = UserConfig_clone(&val_conv);
25182         ChannelManagerReadArgs_set_default_config(&this_ptr_conv, val_conv);
25183 }
25184
25185 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) {
25186         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
25187         CHECK_ACCESS(keys_manager_ptr);
25188         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
25189         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
25190                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25191                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
25192         }
25193         void* fee_estimator_ptr = (void*)(((uint64_t)fee_estimator) & ~1);
25194         CHECK_ACCESS(fee_estimator_ptr);
25195         LDKFeeEstimator fee_estimator_conv = *(LDKFeeEstimator*)(fee_estimator_ptr);
25196         if (fee_estimator_conv.free == LDKFeeEstimator_JCalls_free) {
25197                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25198                 LDKFeeEstimator_JCalls_cloned(&fee_estimator_conv);
25199         }
25200         void* chain_monitor_ptr = (void*)(((uint64_t)chain_monitor) & ~1);
25201         CHECK_ACCESS(chain_monitor_ptr);
25202         LDKWatch chain_monitor_conv = *(LDKWatch*)(chain_monitor_ptr);
25203         if (chain_monitor_conv.free == LDKWatch_JCalls_free) {
25204                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25205                 LDKWatch_JCalls_cloned(&chain_monitor_conv);
25206         }
25207         void* tx_broadcaster_ptr = (void*)(((uint64_t)tx_broadcaster) & ~1);
25208         CHECK_ACCESS(tx_broadcaster_ptr);
25209         LDKBroadcasterInterface tx_broadcaster_conv = *(LDKBroadcasterInterface*)(tx_broadcaster_ptr);
25210         if (tx_broadcaster_conv.free == LDKBroadcasterInterface_JCalls_free) {
25211                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25212                 LDKBroadcasterInterface_JCalls_cloned(&tx_broadcaster_conv);
25213         }
25214         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
25215         CHECK_ACCESS(logger_ptr);
25216         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
25217         if (logger_conv.free == LDKLogger_JCalls_free) {
25218                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
25219                 LDKLogger_JCalls_cloned(&logger_conv);
25220         }
25221         LDKUserConfig default_config_conv;
25222         default_config_conv.inner = (void*)(default_config & (~1));
25223         default_config_conv.is_owned = (default_config & 1) || (default_config == 0);
25224         CHECK_INNER_FIELD_ACCESS_OR_NULL(default_config_conv);
25225         default_config_conv = UserConfig_clone(&default_config_conv);
25226         LDKCVec_ChannelMonitorZ channel_monitors_constr;
25227         channel_monitors_constr.datalen = (*env)->GetArrayLength(env, channel_monitors);
25228         if (channel_monitors_constr.datalen > 0)
25229                 channel_monitors_constr.data = MALLOC(channel_monitors_constr.datalen * sizeof(LDKChannelMonitor), "LDKCVec_ChannelMonitorZ Elements");
25230         else
25231                 channel_monitors_constr.data = NULL;
25232         int64_t* channel_monitors_vals = (*env)->GetLongArrayElements (env, channel_monitors, NULL);
25233         for (size_t q = 0; q < channel_monitors_constr.datalen; q++) {
25234                 int64_t channel_monitors_conv_16 = channel_monitors_vals[q];
25235                 LDKChannelMonitor channel_monitors_conv_16_conv;
25236                 channel_monitors_conv_16_conv.inner = (void*)(channel_monitors_conv_16 & (~1));
25237                 channel_monitors_conv_16_conv.is_owned = (channel_monitors_conv_16 & 1) || (channel_monitors_conv_16 == 0);
25238                 CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_monitors_conv_16_conv);
25239                 channel_monitors_constr.data[q] = channel_monitors_conv_16_conv;
25240         }
25241         (*env)->ReleaseLongArrayElements(env, channel_monitors, channel_monitors_vals, 0);
25242         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);
25243         uint64_t ret_ref = 0;
25244         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25245         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25246         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25247         ret_ref = (uint64_t)ret_var.inner;
25248         if (ret_var.is_owned) {
25249                 ret_ref |= 1;
25250         }
25251         return ret_ref;
25252 }
25253
25254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_C2Tuple_1BlockHashChannelManagerZ_1read(JNIEnv *env, jclass clz, int8_tArray ser, int64_t arg) {
25255         LDKu8slice ser_ref;
25256         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
25257         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
25258         LDKChannelManagerReadArgs arg_conv;
25259         arg_conv.inner = (void*)(arg & (~1));
25260         arg_conv.is_owned = (arg & 1) || (arg == 0);
25261         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25262         // Warning: we need a move here but no clone is available for LDKChannelManagerReadArgs
25263         LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ), "LDKCResult_C2Tuple_BlockHashChannelManagerZDecodeErrorZ");
25264         *ret_conv = C2Tuple_BlockHashChannelManagerZ_read(ser_ref, arg_conv);
25265         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
25266         return (uint64_t)ret_conv;
25267 }
25268
25269 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DecodeError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25270         LDKDecodeError this_obj_conv;
25271         this_obj_conv.inner = (void*)(this_obj & (~1));
25272         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25274         DecodeError_free(this_obj_conv);
25275 }
25276
25277 static inline uint64_t DecodeError_clone_ptr(LDKDecodeError *NONNULL_PTR arg) {
25278         LDKDecodeError ret_var = DecodeError_clone(arg);
25279 uint64_t ret_ref = 0;
25280 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25281 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25282 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25283 ret_ref = (uint64_t)ret_var.inner;
25284 if (ret_var.is_owned) {
25285         ret_ref |= 1;
25286 }
25287         return ret_ref;
25288 }
25289 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25290         LDKDecodeError arg_conv;
25291         arg_conv.inner = (void*)(arg & (~1));
25292         arg_conv.is_owned = false;
25293         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25294         int64_t ret_val = DecodeError_clone_ptr(&arg_conv);
25295         return ret_val;
25296 }
25297
25298 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DecodeError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25299         LDKDecodeError orig_conv;
25300         orig_conv.inner = (void*)(orig & (~1));
25301         orig_conv.is_owned = false;
25302         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25303         LDKDecodeError ret_var = DecodeError_clone(&orig_conv);
25304         uint64_t ret_ref = 0;
25305         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25306         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25307         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25308         ret_ref = (uint64_t)ret_var.inner;
25309         if (ret_var.is_owned) {
25310                 ret_ref |= 1;
25311         }
25312         return ret_ref;
25313 }
25314
25315 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25316         LDKInit this_obj_conv;
25317         this_obj_conv.inner = (void*)(this_obj & (~1));
25318         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25319         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25320         Init_free(this_obj_conv);
25321 }
25322
25323 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
25324         LDKInit this_ptr_conv;
25325         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25326         this_ptr_conv.is_owned = false;
25327         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25328         LDKInitFeatures ret_var = Init_get_features(&this_ptr_conv);
25329         uint64_t ret_ref = 0;
25330         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25331         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25332         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25333         ret_ref = (uint64_t)ret_var.inner;
25334         if (ret_var.is_owned) {
25335                 ret_ref |= 1;
25336         }
25337         return ret_ref;
25338 }
25339
25340 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Init_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25341         LDKInit this_ptr_conv;
25342         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25343         this_ptr_conv.is_owned = false;
25344         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25345         LDKInitFeatures val_conv;
25346         val_conv.inner = (void*)(val & (~1));
25347         val_conv.is_owned = (val & 1) || (val == 0);
25348         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
25349         val_conv = InitFeatures_clone(&val_conv);
25350         Init_set_features(&this_ptr_conv, val_conv);
25351 }
25352
25353 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1new(JNIEnv *env, jclass clz, int64_t features_arg) {
25354         LDKInitFeatures features_arg_conv;
25355         features_arg_conv.inner = (void*)(features_arg & (~1));
25356         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
25357         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
25358         features_arg_conv = InitFeatures_clone(&features_arg_conv);
25359         LDKInit ret_var = Init_new(features_arg_conv);
25360         uint64_t ret_ref = 0;
25361         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25362         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25363         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25364         ret_ref = (uint64_t)ret_var.inner;
25365         if (ret_var.is_owned) {
25366                 ret_ref |= 1;
25367         }
25368         return ret_ref;
25369 }
25370
25371 static inline uint64_t Init_clone_ptr(LDKInit *NONNULL_PTR arg) {
25372         LDKInit ret_var = Init_clone(arg);
25373 uint64_t ret_ref = 0;
25374 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25375 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25376 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25377 ret_ref = (uint64_t)ret_var.inner;
25378 if (ret_var.is_owned) {
25379         ret_ref |= 1;
25380 }
25381         return ret_ref;
25382 }
25383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25384         LDKInit arg_conv;
25385         arg_conv.inner = (void*)(arg & (~1));
25386         arg_conv.is_owned = false;
25387         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25388         int64_t ret_val = Init_clone_ptr(&arg_conv);
25389         return ret_val;
25390 }
25391
25392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25393         LDKInit orig_conv;
25394         orig_conv.inner = (void*)(orig & (~1));
25395         orig_conv.is_owned = false;
25396         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25397         LDKInit ret_var = Init_clone(&orig_conv);
25398         uint64_t ret_ref = 0;
25399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25402         ret_ref = (uint64_t)ret_var.inner;
25403         if (ret_var.is_owned) {
25404                 ret_ref |= 1;
25405         }
25406         return ret_ref;
25407 }
25408
25409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25410         LDKErrorMessage this_obj_conv;
25411         this_obj_conv.inner = (void*)(this_obj & (~1));
25412         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25414         ErrorMessage_free(this_obj_conv);
25415 }
25416
25417 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25418         LDKErrorMessage this_ptr_conv;
25419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25420         this_ptr_conv.is_owned = false;
25421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25422         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25423         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ErrorMessage_get_channel_id(&this_ptr_conv));
25424         return ret_arr;
25425 }
25426
25427 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25428         LDKErrorMessage this_ptr_conv;
25429         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25430         this_ptr_conv.is_owned = false;
25431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25432         LDKThirtyTwoBytes val_ref;
25433         CHECK((*env)->GetArrayLength(env, val) == 32);
25434         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25435         ErrorMessage_set_channel_id(&this_ptr_conv, val_ref);
25436 }
25437
25438 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
25439         LDKErrorMessage this_ptr_conv;
25440         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25441         this_ptr_conv.is_owned = false;
25442         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25443         LDKStr ret_str = ErrorMessage_get_data(&this_ptr_conv);
25444         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
25445         Str_free(ret_str);
25446         return ret_conv;
25447 }
25448
25449 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
25450         LDKErrorMessage this_ptr_conv;
25451         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25452         this_ptr_conv.is_owned = false;
25453         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25454         LDKStr val_conv = java_to_owned_str(env, val);
25455         ErrorMessage_set_data(&this_ptr_conv, val_conv);
25456 }
25457
25458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, jstring data_arg) {
25459         LDKThirtyTwoBytes channel_id_arg_ref;
25460         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
25461         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
25462         LDKStr data_arg_conv = java_to_owned_str(env, data_arg);
25463         LDKErrorMessage ret_var = ErrorMessage_new(channel_id_arg_ref, data_arg_conv);
25464         uint64_t ret_ref = 0;
25465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25468         ret_ref = (uint64_t)ret_var.inner;
25469         if (ret_var.is_owned) {
25470                 ret_ref |= 1;
25471         }
25472         return ret_ref;
25473 }
25474
25475 static inline uint64_t ErrorMessage_clone_ptr(LDKErrorMessage *NONNULL_PTR arg) {
25476         LDKErrorMessage ret_var = ErrorMessage_clone(arg);
25477 uint64_t ret_ref = 0;
25478 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25479 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25480 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25481 ret_ref = (uint64_t)ret_var.inner;
25482 if (ret_var.is_owned) {
25483         ret_ref |= 1;
25484 }
25485         return ret_ref;
25486 }
25487 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25488         LDKErrorMessage arg_conv;
25489         arg_conv.inner = (void*)(arg & (~1));
25490         arg_conv.is_owned = false;
25491         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25492         int64_t ret_val = ErrorMessage_clone_ptr(&arg_conv);
25493         return ret_val;
25494 }
25495
25496 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25497         LDKErrorMessage orig_conv;
25498         orig_conv.inner = (void*)(orig & (~1));
25499         orig_conv.is_owned = false;
25500         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25501         LDKErrorMessage ret_var = ErrorMessage_clone(&orig_conv);
25502         uint64_t ret_ref = 0;
25503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25506         ret_ref = (uint64_t)ret_var.inner;
25507         if (ret_var.is_owned) {
25508                 ret_ref |= 1;
25509         }
25510         return ret_ref;
25511 }
25512
25513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25514         LDKPing this_obj_conv;
25515         this_obj_conv.inner = (void*)(this_obj & (~1));
25516         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25518         Ping_free(this_obj_conv);
25519 }
25520
25521 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr) {
25522         LDKPing this_ptr_conv;
25523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25524         this_ptr_conv.is_owned = false;
25525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25526         int16_t ret_val = Ping_get_ponglen(&this_ptr_conv);
25527         return ret_val;
25528 }
25529
25530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1ponglen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25531         LDKPing this_ptr_conv;
25532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25533         this_ptr_conv.is_owned = false;
25534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25535         Ping_set_ponglen(&this_ptr_conv, val);
25536 }
25537
25538 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Ping_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
25539         LDKPing this_ptr_conv;
25540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25541         this_ptr_conv.is_owned = false;
25542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25543         int16_t ret_val = Ping_get_byteslen(&this_ptr_conv);
25544         return ret_val;
25545 }
25546
25547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Ping_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25548         LDKPing this_ptr_conv;
25549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25550         this_ptr_conv.is_owned = false;
25551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25552         Ping_set_byteslen(&this_ptr_conv, val);
25553 }
25554
25555 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1new(JNIEnv *env, jclass clz, int16_t ponglen_arg, int16_t byteslen_arg) {
25556         LDKPing ret_var = Ping_new(ponglen_arg, byteslen_arg);
25557         uint64_t ret_ref = 0;
25558         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25559         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25560         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25561         ret_ref = (uint64_t)ret_var.inner;
25562         if (ret_var.is_owned) {
25563                 ret_ref |= 1;
25564         }
25565         return ret_ref;
25566 }
25567
25568 static inline uint64_t Ping_clone_ptr(LDKPing *NONNULL_PTR arg) {
25569         LDKPing ret_var = Ping_clone(arg);
25570 uint64_t ret_ref = 0;
25571 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25572 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25573 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25574 ret_ref = (uint64_t)ret_var.inner;
25575 if (ret_var.is_owned) {
25576         ret_ref |= 1;
25577 }
25578         return ret_ref;
25579 }
25580 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25581         LDKPing arg_conv;
25582         arg_conv.inner = (void*)(arg & (~1));
25583         arg_conv.is_owned = false;
25584         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25585         int64_t ret_val = Ping_clone_ptr(&arg_conv);
25586         return ret_val;
25587 }
25588
25589 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25590         LDKPing orig_conv;
25591         orig_conv.inner = (void*)(orig & (~1));
25592         orig_conv.is_owned = false;
25593         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25594         LDKPing ret_var = Ping_clone(&orig_conv);
25595         uint64_t ret_ref = 0;
25596         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25597         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25598         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25599         ret_ref = (uint64_t)ret_var.inner;
25600         if (ret_var.is_owned) {
25601                 ret_ref |= 1;
25602         }
25603         return ret_ref;
25604 }
25605
25606 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25607         LDKPong this_obj_conv;
25608         this_obj_conv.inner = (void*)(this_obj & (~1));
25609         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25610         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25611         Pong_free(this_obj_conv);
25612 }
25613
25614 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_Pong_1get_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr) {
25615         LDKPong this_ptr_conv;
25616         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25617         this_ptr_conv.is_owned = false;
25618         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25619         int16_t ret_val = Pong_get_byteslen(&this_ptr_conv);
25620         return ret_val;
25621 }
25622
25623 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Pong_1set_1byteslen(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25624         LDKPong this_ptr_conv;
25625         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25626         this_ptr_conv.is_owned = false;
25627         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25628         Pong_set_byteslen(&this_ptr_conv, val);
25629 }
25630
25631 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1new(JNIEnv *env, jclass clz, int16_t byteslen_arg) {
25632         LDKPong ret_var = Pong_new(byteslen_arg);
25633         uint64_t ret_ref = 0;
25634         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25635         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25636         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25637         ret_ref = (uint64_t)ret_var.inner;
25638         if (ret_var.is_owned) {
25639                 ret_ref |= 1;
25640         }
25641         return ret_ref;
25642 }
25643
25644 static inline uint64_t Pong_clone_ptr(LDKPong *NONNULL_PTR arg) {
25645         LDKPong ret_var = Pong_clone(arg);
25646 uint64_t ret_ref = 0;
25647 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25648 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25649 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25650 ret_ref = (uint64_t)ret_var.inner;
25651 if (ret_var.is_owned) {
25652         ret_ref |= 1;
25653 }
25654         return ret_ref;
25655 }
25656 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
25657         LDKPong arg_conv;
25658         arg_conv.inner = (void*)(arg & (~1));
25659         arg_conv.is_owned = false;
25660         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
25661         int64_t ret_val = Pong_clone_ptr(&arg_conv);
25662         return ret_val;
25663 }
25664
25665 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1clone(JNIEnv *env, jclass clz, int64_t orig) {
25666         LDKPong orig_conv;
25667         orig_conv.inner = (void*)(orig & (~1));
25668         orig_conv.is_owned = false;
25669         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
25670         LDKPong ret_var = Pong_clone(&orig_conv);
25671         uint64_t ret_ref = 0;
25672         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
25673         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
25674         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
25675         ret_ref = (uint64_t)ret_var.inner;
25676         if (ret_var.is_owned) {
25677                 ret_ref |= 1;
25678         }
25679         return ret_ref;
25680 }
25681
25682 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
25683         LDKOpenChannel this_obj_conv;
25684         this_obj_conv.inner = (void*)(this_obj & (~1));
25685         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
25686         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
25687         OpenChannel_free(this_obj_conv);
25688 }
25689
25690 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
25691         LDKOpenChannel this_ptr_conv;
25692         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25693         this_ptr_conv.is_owned = false;
25694         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25695         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25696         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_chain_hash(&this_ptr_conv));
25697         return ret_arr;
25698 }
25699
25700 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25701         LDKOpenChannel this_ptr_conv;
25702         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25703         this_ptr_conv.is_owned = false;
25704         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25705         LDKThirtyTwoBytes val_ref;
25706         CHECK((*env)->GetArrayLength(env, val) == 32);
25707         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25708         OpenChannel_set_chain_hash(&this_ptr_conv, val_ref);
25709 }
25710
25711 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
25712         LDKOpenChannel this_ptr_conv;
25713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25714         this_ptr_conv.is_owned = false;
25715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25716         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
25717         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *OpenChannel_get_temporary_channel_id(&this_ptr_conv));
25718         return ret_arr;
25719 }
25720
25721 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25722         LDKOpenChannel this_ptr_conv;
25723         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25724         this_ptr_conv.is_owned = false;
25725         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25726         LDKThirtyTwoBytes val_ref;
25727         CHECK((*env)->GetArrayLength(env, val) == 32);
25728         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
25729         OpenChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
25730 }
25731
25732 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25733         LDKOpenChannel this_ptr_conv;
25734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25735         this_ptr_conv.is_owned = false;
25736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25737         int64_t ret_val = OpenChannel_get_funding_satoshis(&this_ptr_conv);
25738         return ret_val;
25739 }
25740
25741 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25742         LDKOpenChannel this_ptr_conv;
25743         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25744         this_ptr_conv.is_owned = false;
25745         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25746         OpenChannel_set_funding_satoshis(&this_ptr_conv, val);
25747 }
25748
25749 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25750         LDKOpenChannel this_ptr_conv;
25751         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25752         this_ptr_conv.is_owned = false;
25753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25754         int64_t ret_val = OpenChannel_get_push_msat(&this_ptr_conv);
25755         return ret_val;
25756 }
25757
25758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1push_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25759         LDKOpenChannel this_ptr_conv;
25760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25761         this_ptr_conv.is_owned = false;
25762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25763         OpenChannel_set_push_msat(&this_ptr_conv, val);
25764 }
25765
25766 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25767         LDKOpenChannel this_ptr_conv;
25768         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25769         this_ptr_conv.is_owned = false;
25770         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25771         int64_t ret_val = OpenChannel_get_dust_limit_satoshis(&this_ptr_conv);
25772         return ret_val;
25773 }
25774
25775 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25776         LDKOpenChannel this_ptr_conv;
25777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25778         this_ptr_conv.is_owned = false;
25779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25780         OpenChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
25781 }
25782
25783 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) {
25784         LDKOpenChannel this_ptr_conv;
25785         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25786         this_ptr_conv.is_owned = false;
25787         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25788         int64_t ret_val = OpenChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
25789         return ret_val;
25790 }
25791
25792 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) {
25793         LDKOpenChannel this_ptr_conv;
25794         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25795         this_ptr_conv.is_owned = false;
25796         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25797         OpenChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
25798 }
25799
25800 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
25801         LDKOpenChannel this_ptr_conv;
25802         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25803         this_ptr_conv.is_owned = false;
25804         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25805         int64_t ret_val = OpenChannel_get_channel_reserve_satoshis(&this_ptr_conv);
25806         return ret_val;
25807 }
25808
25809 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25810         LDKOpenChannel this_ptr_conv;
25811         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25812         this_ptr_conv.is_owned = false;
25813         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25814         OpenChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
25815 }
25816
25817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
25818         LDKOpenChannel this_ptr_conv;
25819         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25820         this_ptr_conv.is_owned = false;
25821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25822         int64_t ret_val = OpenChannel_get_htlc_minimum_msat(&this_ptr_conv);
25823         return ret_val;
25824 }
25825
25826 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
25827         LDKOpenChannel this_ptr_conv;
25828         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25829         this_ptr_conv.is_owned = false;
25830         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25831         OpenChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
25832 }
25833
25834 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
25835         LDKOpenChannel this_ptr_conv;
25836         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25837         this_ptr_conv.is_owned = false;
25838         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25839         int32_t ret_val = OpenChannel_get_feerate_per_kw(&this_ptr_conv);
25840         return ret_val;
25841 }
25842
25843 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
25844         LDKOpenChannel this_ptr_conv;
25845         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25846         this_ptr_conv.is_owned = false;
25847         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25848         OpenChannel_set_feerate_per_kw(&this_ptr_conv, val);
25849 }
25850
25851 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
25852         LDKOpenChannel this_ptr_conv;
25853         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25854         this_ptr_conv.is_owned = false;
25855         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25856         int16_t ret_val = OpenChannel_get_to_self_delay(&this_ptr_conv);
25857         return ret_val;
25858 }
25859
25860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25861         LDKOpenChannel this_ptr_conv;
25862         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25863         this_ptr_conv.is_owned = false;
25864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25865         OpenChannel_set_to_self_delay(&this_ptr_conv, val);
25866 }
25867
25868 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
25869         LDKOpenChannel this_ptr_conv;
25870         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25871         this_ptr_conv.is_owned = false;
25872         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25873         int16_t ret_val = OpenChannel_get_max_accepted_htlcs(&this_ptr_conv);
25874         return ret_val;
25875 }
25876
25877 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
25878         LDKOpenChannel this_ptr_conv;
25879         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25880         this_ptr_conv.is_owned = false;
25881         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25882         OpenChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
25883 }
25884
25885 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
25886         LDKOpenChannel this_ptr_conv;
25887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25888         this_ptr_conv.is_owned = false;
25889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25890         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25891         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
25892         return ret_arr;
25893 }
25894
25895 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25896         LDKOpenChannel this_ptr_conv;
25897         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25898         this_ptr_conv.is_owned = false;
25899         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25900         LDKPublicKey val_ref;
25901         CHECK((*env)->GetArrayLength(env, val) == 33);
25902         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25903         OpenChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
25904 }
25905
25906 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25907         LDKOpenChannel this_ptr_conv;
25908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25909         this_ptr_conv.is_owned = false;
25910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25911         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25912         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
25913         return ret_arr;
25914 }
25915
25916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25917         LDKOpenChannel this_ptr_conv;
25918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25919         this_ptr_conv.is_owned = false;
25920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25921         LDKPublicKey val_ref;
25922         CHECK((*env)->GetArrayLength(env, val) == 33);
25923         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25924         OpenChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
25925 }
25926
25927 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
25928         LDKOpenChannel this_ptr_conv;
25929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25930         this_ptr_conv.is_owned = false;
25931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25932         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25933         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_payment_point(&this_ptr_conv).compressed_form);
25934         return ret_arr;
25935 }
25936
25937 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25938         LDKOpenChannel this_ptr_conv;
25939         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25940         this_ptr_conv.is_owned = false;
25941         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25942         LDKPublicKey val_ref;
25943         CHECK((*env)->GetArrayLength(env, val) == 33);
25944         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25945         OpenChannel_set_payment_point(&this_ptr_conv, val_ref);
25946 }
25947
25948 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25949         LDKOpenChannel this_ptr_conv;
25950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25951         this_ptr_conv.is_owned = false;
25952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25953         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25954         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
25955         return ret_arr;
25956 }
25957
25958 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25959         LDKOpenChannel this_ptr_conv;
25960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25961         this_ptr_conv.is_owned = false;
25962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25963         LDKPublicKey val_ref;
25964         CHECK((*env)->GetArrayLength(env, val) == 33);
25965         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25966         OpenChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
25967 }
25968
25969 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
25970         LDKOpenChannel this_ptr_conv;
25971         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25972         this_ptr_conv.is_owned = false;
25973         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25974         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25975         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
25976         return ret_arr;
25977 }
25978
25979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
25980         LDKOpenChannel this_ptr_conv;
25981         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25982         this_ptr_conv.is_owned = false;
25983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25984         LDKPublicKey val_ref;
25985         CHECK((*env)->GetArrayLength(env, val) == 33);
25986         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
25987         OpenChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
25988 }
25989
25990 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
25991         LDKOpenChannel this_ptr_conv;
25992         this_ptr_conv.inner = (void*)(this_ptr & (~1));
25993         this_ptr_conv.is_owned = false;
25994         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
25995         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
25996         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, OpenChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
25997         return ret_arr;
25998 }
25999
26000 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) {
26001         LDKOpenChannel this_ptr_conv;
26002         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26003         this_ptr_conv.is_owned = false;
26004         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26005         LDKPublicKey val_ref;
26006         CHECK((*env)->GetArrayLength(env, val) == 33);
26007         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26008         OpenChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26009 }
26010
26011 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1get_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
26012         LDKOpenChannel this_ptr_conv;
26013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26014         this_ptr_conv.is_owned = false;
26015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26016         int8_t ret_val = OpenChannel_get_channel_flags(&this_ptr_conv);
26017         return ret_val;
26018 }
26019
26020 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_OpenChannel_1set_1channel_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
26021         LDKOpenChannel this_ptr_conv;
26022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26023         this_ptr_conv.is_owned = false;
26024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26025         OpenChannel_set_channel_flags(&this_ptr_conv, val);
26026 }
26027
26028 static inline uint64_t OpenChannel_clone_ptr(LDKOpenChannel *NONNULL_PTR arg) {
26029         LDKOpenChannel ret_var = OpenChannel_clone(arg);
26030 uint64_t ret_ref = 0;
26031 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26032 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26033 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26034 ret_ref = (uint64_t)ret_var.inner;
26035 if (ret_var.is_owned) {
26036         ret_ref |= 1;
26037 }
26038         return ret_ref;
26039 }
26040 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26041         LDKOpenChannel arg_conv;
26042         arg_conv.inner = (void*)(arg & (~1));
26043         arg_conv.is_owned = false;
26044         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26045         int64_t ret_val = OpenChannel_clone_ptr(&arg_conv);
26046         return ret_val;
26047 }
26048
26049 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26050         LDKOpenChannel orig_conv;
26051         orig_conv.inner = (void*)(orig & (~1));
26052         orig_conv.is_owned = false;
26053         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26054         LDKOpenChannel ret_var = OpenChannel_clone(&orig_conv);
26055         uint64_t ret_ref = 0;
26056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26059         ret_ref = (uint64_t)ret_var.inner;
26060         if (ret_var.is_owned) {
26061                 ret_ref |= 1;
26062         }
26063         return ret_ref;
26064 }
26065
26066 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26067         LDKAcceptChannel this_obj_conv;
26068         this_obj_conv.inner = (void*)(this_obj & (~1));
26069         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26070         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26071         AcceptChannel_free(this_obj_conv);
26072 }
26073
26074 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26075         LDKAcceptChannel this_ptr_conv;
26076         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26077         this_ptr_conv.is_owned = false;
26078         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26079         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26080         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AcceptChannel_get_temporary_channel_id(&this_ptr_conv));
26081         return ret_arr;
26082 }
26083
26084 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26085         LDKAcceptChannel this_ptr_conv;
26086         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26087         this_ptr_conv.is_owned = false;
26088         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26089         LDKThirtyTwoBytes val_ref;
26090         CHECK((*env)->GetArrayLength(env, val) == 32);
26091         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26092         AcceptChannel_set_temporary_channel_id(&this_ptr_conv, val_ref);
26093 }
26094
26095 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26096         LDKAcceptChannel this_ptr_conv;
26097         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26098         this_ptr_conv.is_owned = false;
26099         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26100         int64_t ret_val = AcceptChannel_get_dust_limit_satoshis(&this_ptr_conv);
26101         return ret_val;
26102 }
26103
26104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1dust_1limit_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26105         LDKAcceptChannel this_ptr_conv;
26106         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26107         this_ptr_conv.is_owned = false;
26108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26109         AcceptChannel_set_dust_limit_satoshis(&this_ptr_conv, val);
26110 }
26111
26112 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) {
26113         LDKAcceptChannel this_ptr_conv;
26114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26115         this_ptr_conv.is_owned = false;
26116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26117         int64_t ret_val = AcceptChannel_get_max_htlc_value_in_flight_msat(&this_ptr_conv);
26118         return ret_val;
26119 }
26120
26121 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) {
26122         LDKAcceptChannel this_ptr_conv;
26123         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26124         this_ptr_conv.is_owned = false;
26125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26126         AcceptChannel_set_max_htlc_value_in_flight_msat(&this_ptr_conv, val);
26127 }
26128
26129 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26130         LDKAcceptChannel this_ptr_conv;
26131         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26132         this_ptr_conv.is_owned = false;
26133         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26134         int64_t ret_val = AcceptChannel_get_channel_reserve_satoshis(&this_ptr_conv);
26135         return ret_val;
26136 }
26137
26138 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1channel_1reserve_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26139         LDKAcceptChannel this_ptr_conv;
26140         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26141         this_ptr_conv.is_owned = false;
26142         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26143         AcceptChannel_set_channel_reserve_satoshis(&this_ptr_conv, val);
26144 }
26145
26146 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
26147         LDKAcceptChannel this_ptr_conv;
26148         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26149         this_ptr_conv.is_owned = false;
26150         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26151         int64_t ret_val = AcceptChannel_get_htlc_minimum_msat(&this_ptr_conv);
26152         return ret_val;
26153 }
26154
26155 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26156         LDKAcceptChannel this_ptr_conv;
26157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26158         this_ptr_conv.is_owned = false;
26159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26160         AcceptChannel_set_htlc_minimum_msat(&this_ptr_conv, val);
26161 }
26162
26163 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr) {
26164         LDKAcceptChannel this_ptr_conv;
26165         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26166         this_ptr_conv.is_owned = false;
26167         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26168         int32_t ret_val = AcceptChannel_get_minimum_depth(&this_ptr_conv);
26169         return ret_val;
26170 }
26171
26172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1minimum_1depth(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
26173         LDKAcceptChannel this_ptr_conv;
26174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26175         this_ptr_conv.is_owned = false;
26176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26177         AcceptChannel_set_minimum_depth(&this_ptr_conv, val);
26178 }
26179
26180 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
26181         LDKAcceptChannel this_ptr_conv;
26182         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26183         this_ptr_conv.is_owned = false;
26184         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26185         int16_t ret_val = AcceptChannel_get_to_self_delay(&this_ptr_conv);
26186         return ret_val;
26187 }
26188
26189 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1to_1self_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26190         LDKAcceptChannel this_ptr_conv;
26191         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26192         this_ptr_conv.is_owned = false;
26193         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26194         AcceptChannel_set_to_self_delay(&this_ptr_conv, val);
26195 }
26196
26197 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
26198         LDKAcceptChannel this_ptr_conv;
26199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26200         this_ptr_conv.is_owned = false;
26201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26202         int16_t ret_val = AcceptChannel_get_max_accepted_htlcs(&this_ptr_conv);
26203         return ret_val;
26204 }
26205
26206 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1max_1accepted_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26207         LDKAcceptChannel this_ptr_conv;
26208         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26209         this_ptr_conv.is_owned = false;
26210         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26211         AcceptChannel_set_max_accepted_htlcs(&this_ptr_conv, val);
26212 }
26213
26214 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26215         LDKAcceptChannel this_ptr_conv;
26216         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26217         this_ptr_conv.is_owned = false;
26218         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26219         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26220         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_funding_pubkey(&this_ptr_conv).compressed_form);
26221         return ret_arr;
26222 }
26223
26224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26225         LDKAcceptChannel this_ptr_conv;
26226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26227         this_ptr_conv.is_owned = false;
26228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26229         LDKPublicKey val_ref;
26230         CHECK((*env)->GetArrayLength(env, val) == 33);
26231         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26232         AcceptChannel_set_funding_pubkey(&this_ptr_conv, val_ref);
26233 }
26234
26235 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26236         LDKAcceptChannel this_ptr_conv;
26237         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26238         this_ptr_conv.is_owned = false;
26239         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26240         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26241         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_revocation_basepoint(&this_ptr_conv).compressed_form);
26242         return ret_arr;
26243 }
26244
26245 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26246         LDKAcceptChannel this_ptr_conv;
26247         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26248         this_ptr_conv.is_owned = false;
26249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26250         LDKPublicKey val_ref;
26251         CHECK((*env)->GetArrayLength(env, val) == 33);
26252         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26253         AcceptChannel_set_revocation_basepoint(&this_ptr_conv, val_ref);
26254 }
26255
26256 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26257         LDKAcceptChannel this_ptr_conv;
26258         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26259         this_ptr_conv.is_owned = false;
26260         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26261         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26262         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_payment_point(&this_ptr_conv).compressed_form);
26263         return ret_arr;
26264 }
26265
26266 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26267         LDKAcceptChannel this_ptr_conv;
26268         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26269         this_ptr_conv.is_owned = false;
26270         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26271         LDKPublicKey val_ref;
26272         CHECK((*env)->GetArrayLength(env, val) == 33);
26273         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26274         AcceptChannel_set_payment_point(&this_ptr_conv, val_ref);
26275 }
26276
26277 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26278         LDKAcceptChannel this_ptr_conv;
26279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26280         this_ptr_conv.is_owned = false;
26281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26282         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26283         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
26284         return ret_arr;
26285 }
26286
26287 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26288         LDKAcceptChannel this_ptr_conv;
26289         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26290         this_ptr_conv.is_owned = false;
26291         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26292         LDKPublicKey val_ref;
26293         CHECK((*env)->GetArrayLength(env, val) == 33);
26294         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26295         AcceptChannel_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
26296 }
26297
26298 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
26299         LDKAcceptChannel this_ptr_conv;
26300         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26301         this_ptr_conv.is_owned = false;
26302         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26303         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26304         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_htlc_basepoint(&this_ptr_conv).compressed_form);
26305         return ret_arr;
26306 }
26307
26308 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26309         LDKAcceptChannel this_ptr_conv;
26310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26311         this_ptr_conv.is_owned = false;
26312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26313         LDKPublicKey val_ref;
26314         CHECK((*env)->GetArrayLength(env, val) == 33);
26315         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26316         AcceptChannel_set_htlc_basepoint(&this_ptr_conv, val_ref);
26317 }
26318
26319 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1get_1first_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26320         LDKAcceptChannel this_ptr_conv;
26321         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26322         this_ptr_conv.is_owned = false;
26323         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26324         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26325         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, AcceptChannel_get_first_per_commitment_point(&this_ptr_conv).compressed_form);
26326         return ret_arr;
26327 }
26328
26329 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) {
26330         LDKAcceptChannel this_ptr_conv;
26331         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26332         this_ptr_conv.is_owned = false;
26333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26334         LDKPublicKey val_ref;
26335         CHECK((*env)->GetArrayLength(env, val) == 33);
26336         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26337         AcceptChannel_set_first_per_commitment_point(&this_ptr_conv, val_ref);
26338 }
26339
26340 static inline uint64_t AcceptChannel_clone_ptr(LDKAcceptChannel *NONNULL_PTR arg) {
26341         LDKAcceptChannel ret_var = AcceptChannel_clone(arg);
26342 uint64_t ret_ref = 0;
26343 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26344 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26345 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26346 ret_ref = (uint64_t)ret_var.inner;
26347 if (ret_var.is_owned) {
26348         ret_ref |= 1;
26349 }
26350         return ret_ref;
26351 }
26352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26353         LDKAcceptChannel arg_conv;
26354         arg_conv.inner = (void*)(arg & (~1));
26355         arg_conv.is_owned = false;
26356         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26357         int64_t ret_val = AcceptChannel_clone_ptr(&arg_conv);
26358         return ret_val;
26359 }
26360
26361 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26362         LDKAcceptChannel orig_conv;
26363         orig_conv.inner = (void*)(orig & (~1));
26364         orig_conv.is_owned = false;
26365         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26366         LDKAcceptChannel ret_var = AcceptChannel_clone(&orig_conv);
26367         uint64_t ret_ref = 0;
26368         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26369         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26371         ret_ref = (uint64_t)ret_var.inner;
26372         if (ret_var.is_owned) {
26373                 ret_ref |= 1;
26374         }
26375         return ret_ref;
26376 }
26377
26378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26379         LDKFundingCreated this_obj_conv;
26380         this_obj_conv.inner = (void*)(this_obj & (~1));
26381         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26383         FundingCreated_free(this_obj_conv);
26384 }
26385
26386 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26387         LDKFundingCreated this_ptr_conv;
26388         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26389         this_ptr_conv.is_owned = false;
26390         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26391         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26392         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_temporary_channel_id(&this_ptr_conv));
26393         return ret_arr;
26394 }
26395
26396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1temporary_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26397         LDKFundingCreated this_ptr_conv;
26398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26399         this_ptr_conv.is_owned = false;
26400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26401         LDKThirtyTwoBytes val_ref;
26402         CHECK((*env)->GetArrayLength(env, val) == 32);
26403         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26404         FundingCreated_set_temporary_channel_id(&this_ptr_conv, val_ref);
26405 }
26406
26407 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
26408         LDKFundingCreated this_ptr_conv;
26409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26410         this_ptr_conv.is_owned = false;
26411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26412         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26413         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingCreated_get_funding_txid(&this_ptr_conv));
26414         return ret_arr;
26415 }
26416
26417 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26418         LDKFundingCreated this_ptr_conv;
26419         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26420         this_ptr_conv.is_owned = false;
26421         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26422         LDKThirtyTwoBytes val_ref;
26423         CHECK((*env)->GetArrayLength(env, val) == 32);
26424         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26425         FundingCreated_set_funding_txid(&this_ptr_conv, val_ref);
26426 }
26427
26428 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
26429         LDKFundingCreated this_ptr_conv;
26430         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26431         this_ptr_conv.is_owned = false;
26432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26433         int16_t ret_val = FundingCreated_get_funding_output_index(&this_ptr_conv);
26434         return ret_val;
26435 }
26436
26437 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1funding_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
26438         LDKFundingCreated this_ptr_conv;
26439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26440         this_ptr_conv.is_owned = false;
26441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26442         FundingCreated_set_funding_output_index(&this_ptr_conv, val);
26443 }
26444
26445 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
26446         LDKFundingCreated this_ptr_conv;
26447         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26448         this_ptr_conv.is_owned = false;
26449         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26450         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26451         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingCreated_get_signature(&this_ptr_conv).compact_form);
26452         return ret_arr;
26453 }
26454
26455 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingCreated_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26456         LDKFundingCreated this_ptr_conv;
26457         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26458         this_ptr_conv.is_owned = false;
26459         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26460         LDKSignature val_ref;
26461         CHECK((*env)->GetArrayLength(env, val) == 64);
26462         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
26463         FundingCreated_set_signature(&this_ptr_conv, val_ref);
26464 }
26465
26466 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) {
26467         LDKThirtyTwoBytes temporary_channel_id_arg_ref;
26468         CHECK((*env)->GetArrayLength(env, temporary_channel_id_arg) == 32);
26469         (*env)->GetByteArrayRegion(env, temporary_channel_id_arg, 0, 32, temporary_channel_id_arg_ref.data);
26470         LDKThirtyTwoBytes funding_txid_arg_ref;
26471         CHECK((*env)->GetArrayLength(env, funding_txid_arg) == 32);
26472         (*env)->GetByteArrayRegion(env, funding_txid_arg, 0, 32, funding_txid_arg_ref.data);
26473         LDKSignature signature_arg_ref;
26474         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
26475         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
26476         LDKFundingCreated ret_var = FundingCreated_new(temporary_channel_id_arg_ref, funding_txid_arg_ref, funding_output_index_arg, signature_arg_ref);
26477         uint64_t ret_ref = 0;
26478         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26479         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26480         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26481         ret_ref = (uint64_t)ret_var.inner;
26482         if (ret_var.is_owned) {
26483                 ret_ref |= 1;
26484         }
26485         return ret_ref;
26486 }
26487
26488 static inline uint64_t FundingCreated_clone_ptr(LDKFundingCreated *NONNULL_PTR arg) {
26489         LDKFundingCreated ret_var = FundingCreated_clone(arg);
26490 uint64_t ret_ref = 0;
26491 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26492 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26493 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26494 ret_ref = (uint64_t)ret_var.inner;
26495 if (ret_var.is_owned) {
26496         ret_ref |= 1;
26497 }
26498         return ret_ref;
26499 }
26500 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26501         LDKFundingCreated arg_conv;
26502         arg_conv.inner = (void*)(arg & (~1));
26503         arg_conv.is_owned = false;
26504         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26505         int64_t ret_val = FundingCreated_clone_ptr(&arg_conv);
26506         return ret_val;
26507 }
26508
26509 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26510         LDKFundingCreated orig_conv;
26511         orig_conv.inner = (void*)(orig & (~1));
26512         orig_conv.is_owned = false;
26513         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26514         LDKFundingCreated ret_var = FundingCreated_clone(&orig_conv);
26515         uint64_t ret_ref = 0;
26516         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26517         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26519         ret_ref = (uint64_t)ret_var.inner;
26520         if (ret_var.is_owned) {
26521                 ret_ref |= 1;
26522         }
26523         return ret_ref;
26524 }
26525
26526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26527         LDKFundingSigned this_obj_conv;
26528         this_obj_conv.inner = (void*)(this_obj & (~1));
26529         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26531         FundingSigned_free(this_obj_conv);
26532 }
26533
26534 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26535         LDKFundingSigned this_ptr_conv;
26536         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26537         this_ptr_conv.is_owned = false;
26538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26539         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26540         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingSigned_get_channel_id(&this_ptr_conv));
26541         return ret_arr;
26542 }
26543
26544 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26545         LDKFundingSigned this_ptr_conv;
26546         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26547         this_ptr_conv.is_owned = false;
26548         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26549         LDKThirtyTwoBytes val_ref;
26550         CHECK((*env)->GetArrayLength(env, val) == 32);
26551         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26552         FundingSigned_set_channel_id(&this_ptr_conv, val_ref);
26553 }
26554
26555 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
26556         LDKFundingSigned this_ptr_conv;
26557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26558         this_ptr_conv.is_owned = false;
26559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26560         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26561         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, FundingSigned_get_signature(&this_ptr_conv).compact_form);
26562         return ret_arr;
26563 }
26564
26565 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26566         LDKFundingSigned this_ptr_conv;
26567         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26568         this_ptr_conv.is_owned = false;
26569         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26570         LDKSignature val_ref;
26571         CHECK((*env)->GetArrayLength(env, val) == 64);
26572         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
26573         FundingSigned_set_signature(&this_ptr_conv, val_ref);
26574 }
26575
26576 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray signature_arg) {
26577         LDKThirtyTwoBytes channel_id_arg_ref;
26578         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
26579         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
26580         LDKSignature signature_arg_ref;
26581         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
26582         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
26583         LDKFundingSigned ret_var = FundingSigned_new(channel_id_arg_ref, signature_arg_ref);
26584         uint64_t ret_ref = 0;
26585         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26586         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26587         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26588         ret_ref = (uint64_t)ret_var.inner;
26589         if (ret_var.is_owned) {
26590                 ret_ref |= 1;
26591         }
26592         return ret_ref;
26593 }
26594
26595 static inline uint64_t FundingSigned_clone_ptr(LDKFundingSigned *NONNULL_PTR arg) {
26596         LDKFundingSigned ret_var = FundingSigned_clone(arg);
26597 uint64_t ret_ref = 0;
26598 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26599 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26600 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26601 ret_ref = (uint64_t)ret_var.inner;
26602 if (ret_var.is_owned) {
26603         ret_ref |= 1;
26604 }
26605         return ret_ref;
26606 }
26607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26608         LDKFundingSigned arg_conv;
26609         arg_conv.inner = (void*)(arg & (~1));
26610         arg_conv.is_owned = false;
26611         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26612         int64_t ret_val = FundingSigned_clone_ptr(&arg_conv);
26613         return ret_val;
26614 }
26615
26616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26617         LDKFundingSigned orig_conv;
26618         orig_conv.inner = (void*)(orig & (~1));
26619         orig_conv.is_owned = false;
26620         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26621         LDKFundingSigned ret_var = FundingSigned_clone(&orig_conv);
26622         uint64_t ret_ref = 0;
26623         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26624         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26626         ret_ref = (uint64_t)ret_var.inner;
26627         if (ret_var.is_owned) {
26628                 ret_ref |= 1;
26629         }
26630         return ret_ref;
26631 }
26632
26633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26634         LDKFundingLocked this_obj_conv;
26635         this_obj_conv.inner = (void*)(this_obj & (~1));
26636         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26638         FundingLocked_free(this_obj_conv);
26639 }
26640
26641 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26642         LDKFundingLocked this_ptr_conv;
26643         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26644         this_ptr_conv.is_owned = false;
26645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26646         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26647         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *FundingLocked_get_channel_id(&this_ptr_conv));
26648         return ret_arr;
26649 }
26650
26651 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FundingLocked_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26652         LDKFundingLocked this_ptr_conv;
26653         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26654         this_ptr_conv.is_owned = false;
26655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26656         LDKThirtyTwoBytes val_ref;
26657         CHECK((*env)->GetArrayLength(env, val) == 32);
26658         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26659         FundingLocked_set_channel_id(&this_ptr_conv, val_ref);
26660 }
26661
26662 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
26663         LDKFundingLocked this_ptr_conv;
26664         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26665         this_ptr_conv.is_owned = false;
26666         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26667         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
26668         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, FundingLocked_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
26669         return ret_arr;
26670 }
26671
26672 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) {
26673         LDKFundingLocked this_ptr_conv;
26674         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26675         this_ptr_conv.is_owned = false;
26676         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26677         LDKPublicKey val_ref;
26678         CHECK((*env)->GetArrayLength(env, val) == 33);
26679         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
26680         FundingLocked_set_next_per_commitment_point(&this_ptr_conv, val_ref);
26681 }
26682
26683 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) {
26684         LDKThirtyTwoBytes channel_id_arg_ref;
26685         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
26686         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
26687         LDKPublicKey next_per_commitment_point_arg_ref;
26688         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
26689         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
26690         LDKFundingLocked ret_var = FundingLocked_new(channel_id_arg_ref, next_per_commitment_point_arg_ref);
26691         uint64_t ret_ref = 0;
26692         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26693         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26694         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26695         ret_ref = (uint64_t)ret_var.inner;
26696         if (ret_var.is_owned) {
26697                 ret_ref |= 1;
26698         }
26699         return ret_ref;
26700 }
26701
26702 static inline uint64_t FundingLocked_clone_ptr(LDKFundingLocked *NONNULL_PTR arg) {
26703         LDKFundingLocked ret_var = FundingLocked_clone(arg);
26704 uint64_t ret_ref = 0;
26705 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26706 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26707 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26708 ret_ref = (uint64_t)ret_var.inner;
26709 if (ret_var.is_owned) {
26710         ret_ref |= 1;
26711 }
26712         return ret_ref;
26713 }
26714 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26715         LDKFundingLocked arg_conv;
26716         arg_conv.inner = (void*)(arg & (~1));
26717         arg_conv.is_owned = false;
26718         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26719         int64_t ret_val = FundingLocked_clone_ptr(&arg_conv);
26720         return ret_val;
26721 }
26722
26723 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26724         LDKFundingLocked orig_conv;
26725         orig_conv.inner = (void*)(orig & (~1));
26726         orig_conv.is_owned = false;
26727         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26728         LDKFundingLocked ret_var = FundingLocked_clone(&orig_conv);
26729         uint64_t ret_ref = 0;
26730         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26731         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26732         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26733         ret_ref = (uint64_t)ret_var.inner;
26734         if (ret_var.is_owned) {
26735                 ret_ref |= 1;
26736         }
26737         return ret_ref;
26738 }
26739
26740 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26741         LDKShutdown this_obj_conv;
26742         this_obj_conv.inner = (void*)(this_obj & (~1));
26743         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26744         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26745         Shutdown_free(this_obj_conv);
26746 }
26747
26748 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26749         LDKShutdown this_ptr_conv;
26750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26751         this_ptr_conv.is_owned = false;
26752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26753         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26754         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Shutdown_get_channel_id(&this_ptr_conv));
26755         return ret_arr;
26756 }
26757
26758 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26759         LDKShutdown this_ptr_conv;
26760         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26761         this_ptr_conv.is_owned = false;
26762         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26763         LDKThirtyTwoBytes val_ref;
26764         CHECK((*env)->GetArrayLength(env, val) == 32);
26765         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26766         Shutdown_set_channel_id(&this_ptr_conv, val_ref);
26767 }
26768
26769 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1get_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
26770         LDKShutdown this_ptr_conv;
26771         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26772         this_ptr_conv.is_owned = false;
26773         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26774         LDKu8slice ret_var = Shutdown_get_scriptpubkey(&this_ptr_conv);
26775         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
26776         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
26777         return ret_arr;
26778 }
26779
26780 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Shutdown_1set_1scriptpubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26781         LDKShutdown this_ptr_conv;
26782         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26783         this_ptr_conv.is_owned = false;
26784         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26785         LDKCVec_u8Z val_ref;
26786         val_ref.datalen = (*env)->GetArrayLength(env, val);
26787         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
26788         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
26789         Shutdown_set_scriptpubkey(&this_ptr_conv, val_ref);
26790 }
26791
26792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1new(JNIEnv *env, jclass clz, int8_tArray channel_id_arg, int8_tArray scriptpubkey_arg) {
26793         LDKThirtyTwoBytes channel_id_arg_ref;
26794         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
26795         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
26796         LDKCVec_u8Z scriptpubkey_arg_ref;
26797         scriptpubkey_arg_ref.datalen = (*env)->GetArrayLength(env, scriptpubkey_arg);
26798         scriptpubkey_arg_ref.data = MALLOC(scriptpubkey_arg_ref.datalen, "LDKCVec_u8Z Bytes");
26799         (*env)->GetByteArrayRegion(env, scriptpubkey_arg, 0, scriptpubkey_arg_ref.datalen, scriptpubkey_arg_ref.data);
26800         LDKShutdown ret_var = Shutdown_new(channel_id_arg_ref, scriptpubkey_arg_ref);
26801         uint64_t ret_ref = 0;
26802         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26803         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26804         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26805         ret_ref = (uint64_t)ret_var.inner;
26806         if (ret_var.is_owned) {
26807                 ret_ref |= 1;
26808         }
26809         return ret_ref;
26810 }
26811
26812 static inline uint64_t Shutdown_clone_ptr(LDKShutdown *NONNULL_PTR arg) {
26813         LDKShutdown ret_var = Shutdown_clone(arg);
26814 uint64_t ret_ref = 0;
26815 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26816 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26817 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26818 ret_ref = (uint64_t)ret_var.inner;
26819 if (ret_var.is_owned) {
26820         ret_ref |= 1;
26821 }
26822         return ret_ref;
26823 }
26824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26825         LDKShutdown arg_conv;
26826         arg_conv.inner = (void*)(arg & (~1));
26827         arg_conv.is_owned = false;
26828         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26829         int64_t ret_val = Shutdown_clone_ptr(&arg_conv);
26830         return ret_val;
26831 }
26832
26833 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26834         LDKShutdown orig_conv;
26835         orig_conv.inner = (void*)(orig & (~1));
26836         orig_conv.is_owned = false;
26837         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26838         LDKShutdown ret_var = Shutdown_clone(&orig_conv);
26839         uint64_t ret_ref = 0;
26840         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26841         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26842         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26843         ret_ref = (uint64_t)ret_var.inner;
26844         if (ret_var.is_owned) {
26845                 ret_ref |= 1;
26846         }
26847         return ret_ref;
26848 }
26849
26850 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26851         LDKClosingSignedFeeRange this_obj_conv;
26852         this_obj_conv.inner = (void*)(this_obj & (~1));
26853         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26854         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26855         ClosingSignedFeeRange_free(this_obj_conv);
26856 }
26857
26858 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26859         LDKClosingSignedFeeRange this_ptr_conv;
26860         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26861         this_ptr_conv.is_owned = false;
26862         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26863         int64_t ret_val = ClosingSignedFeeRange_get_min_fee_satoshis(&this_ptr_conv);
26864         return ret_val;
26865 }
26866
26867 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1min_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26868         LDKClosingSignedFeeRange this_ptr_conv;
26869         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26870         this_ptr_conv.is_owned = false;
26871         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26872         ClosingSignedFeeRange_set_min_fee_satoshis(&this_ptr_conv, val);
26873 }
26874
26875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1get_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26876         LDKClosingSignedFeeRange this_ptr_conv;
26877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26878         this_ptr_conv.is_owned = false;
26879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26880         int64_t ret_val = ClosingSignedFeeRange_get_max_fee_satoshis(&this_ptr_conv);
26881         return ret_val;
26882 }
26883
26884 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1set_1max_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26885         LDKClosingSignedFeeRange this_ptr_conv;
26886         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26887         this_ptr_conv.is_owned = false;
26888         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26889         ClosingSignedFeeRange_set_max_fee_satoshis(&this_ptr_conv, val);
26890 }
26891
26892 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) {
26893         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_new(min_fee_satoshis_arg, max_fee_satoshis_arg);
26894         uint64_t ret_ref = 0;
26895         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26896         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26897         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26898         ret_ref = (uint64_t)ret_var.inner;
26899         if (ret_var.is_owned) {
26900                 ret_ref |= 1;
26901         }
26902         return ret_ref;
26903 }
26904
26905 static inline uint64_t ClosingSignedFeeRange_clone_ptr(LDKClosingSignedFeeRange *NONNULL_PTR arg) {
26906         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(arg);
26907 uint64_t ret_ref = 0;
26908 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26909 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26910 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26911 ret_ref = (uint64_t)ret_var.inner;
26912 if (ret_var.is_owned) {
26913         ret_ref |= 1;
26914 }
26915         return ret_ref;
26916 }
26917 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
26918         LDKClosingSignedFeeRange arg_conv;
26919         arg_conv.inner = (void*)(arg & (~1));
26920         arg_conv.is_owned = false;
26921         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
26922         int64_t ret_val = ClosingSignedFeeRange_clone_ptr(&arg_conv);
26923         return ret_val;
26924 }
26925
26926 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
26927         LDKClosingSignedFeeRange orig_conv;
26928         orig_conv.inner = (void*)(orig & (~1));
26929         orig_conv.is_owned = false;
26930         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
26931         LDKClosingSignedFeeRange ret_var = ClosingSignedFeeRange_clone(&orig_conv);
26932         uint64_t ret_ref = 0;
26933         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
26934         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
26935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
26936         ret_ref = (uint64_t)ret_var.inner;
26937         if (ret_var.is_owned) {
26938                 ret_ref |= 1;
26939         }
26940         return ret_ref;
26941 }
26942
26943 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
26944         LDKClosingSigned this_obj_conv;
26945         this_obj_conv.inner = (void*)(this_obj & (~1));
26946         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
26947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
26948         ClosingSigned_free(this_obj_conv);
26949 }
26950
26951 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
26952         LDKClosingSigned this_ptr_conv;
26953         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26954         this_ptr_conv.is_owned = false;
26955         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26956         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
26957         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ClosingSigned_get_channel_id(&this_ptr_conv));
26958         return ret_arr;
26959 }
26960
26961 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
26962         LDKClosingSigned this_ptr_conv;
26963         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26964         this_ptr_conv.is_owned = false;
26965         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26966         LDKThirtyTwoBytes val_ref;
26967         CHECK((*env)->GetArrayLength(env, val) == 32);
26968         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
26969         ClosingSigned_set_channel_id(&this_ptr_conv, val_ref);
26970 }
26971
26972 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr) {
26973         LDKClosingSigned this_ptr_conv;
26974         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26975         this_ptr_conv.is_owned = false;
26976         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26977         int64_t ret_val = ClosingSigned_get_fee_satoshis(&this_ptr_conv);
26978         return ret_val;
26979 }
26980
26981 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1satoshis(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
26982         LDKClosingSigned this_ptr_conv;
26983         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26984         this_ptr_conv.is_owned = false;
26985         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26986         ClosingSigned_set_fee_satoshis(&this_ptr_conv, val);
26987 }
26988
26989 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
26990         LDKClosingSigned this_ptr_conv;
26991         this_ptr_conv.inner = (void*)(this_ptr & (~1));
26992         this_ptr_conv.is_owned = false;
26993         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
26994         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
26995         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ClosingSigned_get_signature(&this_ptr_conv).compact_form);
26996         return ret_arr;
26997 }
26998
26999 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27000         LDKClosingSigned this_ptr_conv;
27001         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27002         this_ptr_conv.is_owned = false;
27003         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27004         LDKSignature val_ref;
27005         CHECK((*env)->GetArrayLength(env, val) == 64);
27006         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
27007         ClosingSigned_set_signature(&this_ptr_conv, val_ref);
27008 }
27009
27010 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1get_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
27011         LDKClosingSigned this_ptr_conv;
27012         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27013         this_ptr_conv.is_owned = false;
27014         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27015         LDKClosingSignedFeeRange ret_var = ClosingSigned_get_fee_range(&this_ptr_conv);
27016         uint64_t ret_ref = 0;
27017         if ((uint64_t)ret_var.inner > 4096) {
27018                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27019                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27020         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27021                 ret_ref = (uint64_t)ret_var.inner;
27022                 if (ret_var.is_owned) {
27023                         ret_ref |= 1;
27024                 }
27025         }
27026         return ret_ref;
27027 }
27028
27029 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1set_1fee_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27030         LDKClosingSigned this_ptr_conv;
27031         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27032         this_ptr_conv.is_owned = false;
27033         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27034         LDKClosingSignedFeeRange val_conv;
27035         val_conv.inner = (void*)(val & (~1));
27036         val_conv.is_owned = (val & 1) || (val == 0);
27037         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
27038         val_conv = ClosingSignedFeeRange_clone(&val_conv);
27039         ClosingSigned_set_fee_range(&this_ptr_conv, val_conv);
27040 }
27041
27042 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) {
27043         LDKThirtyTwoBytes channel_id_arg_ref;
27044         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27045         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27046         LDKSignature signature_arg_ref;
27047         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
27048         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
27049         LDKClosingSignedFeeRange fee_range_arg_conv;
27050         fee_range_arg_conv.inner = (void*)(fee_range_arg & (~1));
27051         fee_range_arg_conv.is_owned = (fee_range_arg & 1) || (fee_range_arg == 0);
27052         CHECK_INNER_FIELD_ACCESS_OR_NULL(fee_range_arg_conv);
27053         fee_range_arg_conv = ClosingSignedFeeRange_clone(&fee_range_arg_conv);
27054         LDKClosingSigned ret_var = ClosingSigned_new(channel_id_arg_ref, fee_satoshis_arg, signature_arg_ref, fee_range_arg_conv);
27055         uint64_t ret_ref = 0;
27056         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27057         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27058         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27059         ret_ref = (uint64_t)ret_var.inner;
27060         if (ret_var.is_owned) {
27061                 ret_ref |= 1;
27062         }
27063         return ret_ref;
27064 }
27065
27066 static inline uint64_t ClosingSigned_clone_ptr(LDKClosingSigned *NONNULL_PTR arg) {
27067         LDKClosingSigned ret_var = ClosingSigned_clone(arg);
27068 uint64_t ret_ref = 0;
27069 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27070 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27071 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27072 ret_ref = (uint64_t)ret_var.inner;
27073 if (ret_var.is_owned) {
27074         ret_ref |= 1;
27075 }
27076         return ret_ref;
27077 }
27078 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27079         LDKClosingSigned arg_conv;
27080         arg_conv.inner = (void*)(arg & (~1));
27081         arg_conv.is_owned = false;
27082         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27083         int64_t ret_val = ClosingSigned_clone_ptr(&arg_conv);
27084         return ret_val;
27085 }
27086
27087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27088         LDKClosingSigned orig_conv;
27089         orig_conv.inner = (void*)(orig & (~1));
27090         orig_conv.is_owned = false;
27091         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27092         LDKClosingSigned ret_var = ClosingSigned_clone(&orig_conv);
27093         uint64_t ret_ref = 0;
27094         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27095         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27096         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27097         ret_ref = (uint64_t)ret_var.inner;
27098         if (ret_var.is_owned) {
27099                 ret_ref |= 1;
27100         }
27101         return ret_ref;
27102 }
27103
27104 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27105         LDKUpdateAddHTLC this_obj_conv;
27106         this_obj_conv.inner = (void*)(this_obj & (~1));
27107         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27108         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27109         UpdateAddHTLC_free(this_obj_conv);
27110 }
27111
27112 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27113         LDKUpdateAddHTLC this_ptr_conv;
27114         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27115         this_ptr_conv.is_owned = false;
27116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27117         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27118         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_channel_id(&this_ptr_conv));
27119         return ret_arr;
27120 }
27121
27122 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27123         LDKUpdateAddHTLC this_ptr_conv;
27124         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27125         this_ptr_conv.is_owned = false;
27126         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27127         LDKThirtyTwoBytes val_ref;
27128         CHECK((*env)->GetArrayLength(env, val) == 32);
27129         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27130         UpdateAddHTLC_set_channel_id(&this_ptr_conv, val_ref);
27131 }
27132
27133 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27134         LDKUpdateAddHTLC this_ptr_conv;
27135         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27136         this_ptr_conv.is_owned = false;
27137         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27138         int64_t ret_val = UpdateAddHTLC_get_htlc_id(&this_ptr_conv);
27139         return ret_val;
27140 }
27141
27142 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27143         LDKUpdateAddHTLC this_ptr_conv;
27144         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27145         this_ptr_conv.is_owned = false;
27146         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27147         UpdateAddHTLC_set_htlc_id(&this_ptr_conv, val);
27148 }
27149
27150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
27151         LDKUpdateAddHTLC this_ptr_conv;
27152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27153         this_ptr_conv.is_owned = false;
27154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27155         int64_t ret_val = UpdateAddHTLC_get_amount_msat(&this_ptr_conv);
27156         return ret_val;
27157 }
27158
27159 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27160         LDKUpdateAddHTLC this_ptr_conv;
27161         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27162         this_ptr_conv.is_owned = false;
27163         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27164         UpdateAddHTLC_set_amount_msat(&this_ptr_conv, val);
27165 }
27166
27167 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
27168         LDKUpdateAddHTLC this_ptr_conv;
27169         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27170         this_ptr_conv.is_owned = false;
27171         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27172         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27173         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateAddHTLC_get_payment_hash(&this_ptr_conv));
27174         return ret_arr;
27175 }
27176
27177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27178         LDKUpdateAddHTLC this_ptr_conv;
27179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27180         this_ptr_conv.is_owned = false;
27181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27182         LDKThirtyTwoBytes val_ref;
27183         CHECK((*env)->GetArrayLength(env, val) == 32);
27184         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27185         UpdateAddHTLC_set_payment_hash(&this_ptr_conv, val_ref);
27186 }
27187
27188 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
27189         LDKUpdateAddHTLC this_ptr_conv;
27190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27191         this_ptr_conv.is_owned = false;
27192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27193         int32_t ret_val = UpdateAddHTLC_get_cltv_expiry(&this_ptr_conv);
27194         return ret_val;
27195 }
27196
27197 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27198         LDKUpdateAddHTLC this_ptr_conv;
27199         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27200         this_ptr_conv.is_owned = false;
27201         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27202         UpdateAddHTLC_set_cltv_expiry(&this_ptr_conv, val);
27203 }
27204
27205 static inline uint64_t UpdateAddHTLC_clone_ptr(LDKUpdateAddHTLC *NONNULL_PTR arg) {
27206         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(arg);
27207 uint64_t ret_ref = 0;
27208 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27209 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27210 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27211 ret_ref = (uint64_t)ret_var.inner;
27212 if (ret_var.is_owned) {
27213         ret_ref |= 1;
27214 }
27215         return ret_ref;
27216 }
27217 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27218         LDKUpdateAddHTLC arg_conv;
27219         arg_conv.inner = (void*)(arg & (~1));
27220         arg_conv.is_owned = false;
27221         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27222         int64_t ret_val = UpdateAddHTLC_clone_ptr(&arg_conv);
27223         return ret_val;
27224 }
27225
27226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27227         LDKUpdateAddHTLC orig_conv;
27228         orig_conv.inner = (void*)(orig & (~1));
27229         orig_conv.is_owned = false;
27230         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27231         LDKUpdateAddHTLC ret_var = UpdateAddHTLC_clone(&orig_conv);
27232         uint64_t ret_ref = 0;
27233         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27234         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27235         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27236         ret_ref = (uint64_t)ret_var.inner;
27237         if (ret_var.is_owned) {
27238                 ret_ref |= 1;
27239         }
27240         return ret_ref;
27241 }
27242
27243 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27244         LDKUpdateFulfillHTLC this_obj_conv;
27245         this_obj_conv.inner = (void*)(this_obj & (~1));
27246         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27247         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27248         UpdateFulfillHTLC_free(this_obj_conv);
27249 }
27250
27251 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27252         LDKUpdateFulfillHTLC this_ptr_conv;
27253         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27254         this_ptr_conv.is_owned = false;
27255         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27256         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27257         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_channel_id(&this_ptr_conv));
27258         return ret_arr;
27259 }
27260
27261 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27262         LDKUpdateFulfillHTLC this_ptr_conv;
27263         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27264         this_ptr_conv.is_owned = false;
27265         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27266         LDKThirtyTwoBytes val_ref;
27267         CHECK((*env)->GetArrayLength(env, val) == 32);
27268         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27269         UpdateFulfillHTLC_set_channel_id(&this_ptr_conv, val_ref);
27270 }
27271
27272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27273         LDKUpdateFulfillHTLC this_ptr_conv;
27274         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27275         this_ptr_conv.is_owned = false;
27276         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27277         int64_t ret_val = UpdateFulfillHTLC_get_htlc_id(&this_ptr_conv);
27278         return ret_val;
27279 }
27280
27281 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27282         LDKUpdateFulfillHTLC this_ptr_conv;
27283         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27284         this_ptr_conv.is_owned = false;
27285         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27286         UpdateFulfillHTLC_set_htlc_id(&this_ptr_conv, val);
27287 }
27288
27289 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1get_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr) {
27290         LDKUpdateFulfillHTLC this_ptr_conv;
27291         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27292         this_ptr_conv.is_owned = false;
27293         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27294         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27295         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFulfillHTLC_get_payment_preimage(&this_ptr_conv));
27296         return ret_arr;
27297 }
27298
27299 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1set_1payment_1preimage(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27300         LDKUpdateFulfillHTLC this_ptr_conv;
27301         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27302         this_ptr_conv.is_owned = false;
27303         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27304         LDKThirtyTwoBytes val_ref;
27305         CHECK((*env)->GetArrayLength(env, val) == 32);
27306         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27307         UpdateFulfillHTLC_set_payment_preimage(&this_ptr_conv, val_ref);
27308 }
27309
27310 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) {
27311         LDKThirtyTwoBytes channel_id_arg_ref;
27312         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27313         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27314         LDKThirtyTwoBytes payment_preimage_arg_ref;
27315         CHECK((*env)->GetArrayLength(env, payment_preimage_arg) == 32);
27316         (*env)->GetByteArrayRegion(env, payment_preimage_arg, 0, 32, payment_preimage_arg_ref.data);
27317         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_new(channel_id_arg_ref, htlc_id_arg, payment_preimage_arg_ref);
27318         uint64_t ret_ref = 0;
27319         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27320         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27321         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27322         ret_ref = (uint64_t)ret_var.inner;
27323         if (ret_var.is_owned) {
27324                 ret_ref |= 1;
27325         }
27326         return ret_ref;
27327 }
27328
27329 static inline uint64_t UpdateFulfillHTLC_clone_ptr(LDKUpdateFulfillHTLC *NONNULL_PTR arg) {
27330         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(arg);
27331 uint64_t ret_ref = 0;
27332 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27333 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27334 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27335 ret_ref = (uint64_t)ret_var.inner;
27336 if (ret_var.is_owned) {
27337         ret_ref |= 1;
27338 }
27339         return ret_ref;
27340 }
27341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27342         LDKUpdateFulfillHTLC arg_conv;
27343         arg_conv.inner = (void*)(arg & (~1));
27344         arg_conv.is_owned = false;
27345         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27346         int64_t ret_val = UpdateFulfillHTLC_clone_ptr(&arg_conv);
27347         return ret_val;
27348 }
27349
27350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27351         LDKUpdateFulfillHTLC orig_conv;
27352         orig_conv.inner = (void*)(orig & (~1));
27353         orig_conv.is_owned = false;
27354         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27355         LDKUpdateFulfillHTLC ret_var = UpdateFulfillHTLC_clone(&orig_conv);
27356         uint64_t ret_ref = 0;
27357         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27358         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27359         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27360         ret_ref = (uint64_t)ret_var.inner;
27361         if (ret_var.is_owned) {
27362                 ret_ref |= 1;
27363         }
27364         return ret_ref;
27365 }
27366
27367 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27368         LDKUpdateFailHTLC this_obj_conv;
27369         this_obj_conv.inner = (void*)(this_obj & (~1));
27370         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27371         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27372         UpdateFailHTLC_free(this_obj_conv);
27373 }
27374
27375 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27376         LDKUpdateFailHTLC this_ptr_conv;
27377         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27378         this_ptr_conv.is_owned = false;
27379         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27380         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27381         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailHTLC_get_channel_id(&this_ptr_conv));
27382         return ret_arr;
27383 }
27384
27385 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27386         LDKUpdateFailHTLC this_ptr_conv;
27387         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27388         this_ptr_conv.is_owned = false;
27389         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27390         LDKThirtyTwoBytes val_ref;
27391         CHECK((*env)->GetArrayLength(env, val) == 32);
27392         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27393         UpdateFailHTLC_set_channel_id(&this_ptr_conv, val_ref);
27394 }
27395
27396 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27397         LDKUpdateFailHTLC this_ptr_conv;
27398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27399         this_ptr_conv.is_owned = false;
27400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27401         int64_t ret_val = UpdateFailHTLC_get_htlc_id(&this_ptr_conv);
27402         return ret_val;
27403 }
27404
27405 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27406         LDKUpdateFailHTLC this_ptr_conv;
27407         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27408         this_ptr_conv.is_owned = false;
27409         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27410         UpdateFailHTLC_set_htlc_id(&this_ptr_conv, val);
27411 }
27412
27413 static inline uint64_t UpdateFailHTLC_clone_ptr(LDKUpdateFailHTLC *NONNULL_PTR arg) {
27414         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(arg);
27415 uint64_t ret_ref = 0;
27416 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27417 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27418 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27419 ret_ref = (uint64_t)ret_var.inner;
27420 if (ret_var.is_owned) {
27421         ret_ref |= 1;
27422 }
27423         return ret_ref;
27424 }
27425 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27426         LDKUpdateFailHTLC arg_conv;
27427         arg_conv.inner = (void*)(arg & (~1));
27428         arg_conv.is_owned = false;
27429         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27430         int64_t ret_val = UpdateFailHTLC_clone_ptr(&arg_conv);
27431         return ret_val;
27432 }
27433
27434 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27435         LDKUpdateFailHTLC orig_conv;
27436         orig_conv.inner = (void*)(orig & (~1));
27437         orig_conv.is_owned = false;
27438         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27439         LDKUpdateFailHTLC ret_var = UpdateFailHTLC_clone(&orig_conv);
27440         uint64_t ret_ref = 0;
27441         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27442         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27443         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27444         ret_ref = (uint64_t)ret_var.inner;
27445         if (ret_var.is_owned) {
27446                 ret_ref |= 1;
27447         }
27448         return ret_ref;
27449 }
27450
27451 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27452         LDKUpdateFailMalformedHTLC this_obj_conv;
27453         this_obj_conv.inner = (void*)(this_obj & (~1));
27454         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27456         UpdateFailMalformedHTLC_free(this_obj_conv);
27457 }
27458
27459 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27460         LDKUpdateFailMalformedHTLC this_ptr_conv;
27461         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27462         this_ptr_conv.is_owned = false;
27463         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27464         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27465         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFailMalformedHTLC_get_channel_id(&this_ptr_conv));
27466         return ret_arr;
27467 }
27468
27469 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27470         LDKUpdateFailMalformedHTLC this_ptr_conv;
27471         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27472         this_ptr_conv.is_owned = false;
27473         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27474         LDKThirtyTwoBytes val_ref;
27475         CHECK((*env)->GetArrayLength(env, val) == 32);
27476         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27477         UpdateFailMalformedHTLC_set_channel_id(&this_ptr_conv, val_ref);
27478 }
27479
27480 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27481         LDKUpdateFailMalformedHTLC this_ptr_conv;
27482         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27483         this_ptr_conv.is_owned = false;
27484         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27485         int64_t ret_val = UpdateFailMalformedHTLC_get_htlc_id(&this_ptr_conv);
27486         return ret_val;
27487 }
27488
27489 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1htlc_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
27490         LDKUpdateFailMalformedHTLC this_ptr_conv;
27491         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27492         this_ptr_conv.is_owned = false;
27493         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27494         UpdateFailMalformedHTLC_set_htlc_id(&this_ptr_conv, val);
27495 }
27496
27497 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1get_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr) {
27498         LDKUpdateFailMalformedHTLC this_ptr_conv;
27499         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27500         this_ptr_conv.is_owned = false;
27501         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27502         int16_t ret_val = UpdateFailMalformedHTLC_get_failure_code(&this_ptr_conv);
27503         return ret_val;
27504 }
27505
27506 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1set_1failure_1code(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
27507         LDKUpdateFailMalformedHTLC this_ptr_conv;
27508         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27509         this_ptr_conv.is_owned = false;
27510         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27511         UpdateFailMalformedHTLC_set_failure_code(&this_ptr_conv, val);
27512 }
27513
27514 static inline uint64_t UpdateFailMalformedHTLC_clone_ptr(LDKUpdateFailMalformedHTLC *NONNULL_PTR arg) {
27515         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(arg);
27516 uint64_t ret_ref = 0;
27517 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27518 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27519 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27520 ret_ref = (uint64_t)ret_var.inner;
27521 if (ret_var.is_owned) {
27522         ret_ref |= 1;
27523 }
27524         return ret_ref;
27525 }
27526 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27527         LDKUpdateFailMalformedHTLC arg_conv;
27528         arg_conv.inner = (void*)(arg & (~1));
27529         arg_conv.is_owned = false;
27530         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27531         int64_t ret_val = UpdateFailMalformedHTLC_clone_ptr(&arg_conv);
27532         return ret_val;
27533 }
27534
27535 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27536         LDKUpdateFailMalformedHTLC orig_conv;
27537         orig_conv.inner = (void*)(orig & (~1));
27538         orig_conv.is_owned = false;
27539         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27540         LDKUpdateFailMalformedHTLC ret_var = UpdateFailMalformedHTLC_clone(&orig_conv);
27541         uint64_t ret_ref = 0;
27542         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27543         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27544         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27545         ret_ref = (uint64_t)ret_var.inner;
27546         if (ret_var.is_owned) {
27547                 ret_ref |= 1;
27548         }
27549         return ret_ref;
27550 }
27551
27552 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27553         LDKCommitmentSigned this_obj_conv;
27554         this_obj_conv.inner = (void*)(this_obj & (~1));
27555         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27556         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27557         CommitmentSigned_free(this_obj_conv);
27558 }
27559
27560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27561         LDKCommitmentSigned this_ptr_conv;
27562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27563         this_ptr_conv.is_owned = false;
27564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27565         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27566         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *CommitmentSigned_get_channel_id(&this_ptr_conv));
27567         return ret_arr;
27568 }
27569
27570 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27571         LDKCommitmentSigned this_ptr_conv;
27572         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27573         this_ptr_conv.is_owned = false;
27574         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27575         LDKThirtyTwoBytes val_ref;
27576         CHECK((*env)->GetArrayLength(env, val) == 32);
27577         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27578         CommitmentSigned_set_channel_id(&this_ptr_conv, val_ref);
27579 }
27580
27581 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
27582         LDKCommitmentSigned this_ptr_conv;
27583         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27584         this_ptr_conv.is_owned = false;
27585         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27586         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
27587         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, CommitmentSigned_get_signature(&this_ptr_conv).compact_form);
27588         return ret_arr;
27589 }
27590
27591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27592         LDKCommitmentSigned this_ptr_conv;
27593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27594         this_ptr_conv.is_owned = false;
27595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27596         LDKSignature val_ref;
27597         CHECK((*env)->GetArrayLength(env, val) == 64);
27598         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
27599         CommitmentSigned_set_signature(&this_ptr_conv, val_ref);
27600 }
27601
27602 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1set_1htlc_1signatures(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
27603         LDKCommitmentSigned this_ptr_conv;
27604         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27605         this_ptr_conv.is_owned = false;
27606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27607         LDKCVec_SignatureZ val_constr;
27608         val_constr.datalen = (*env)->GetArrayLength(env, val);
27609         if (val_constr.datalen > 0)
27610                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
27611         else
27612                 val_constr.data = NULL;
27613         for (size_t i = 0; i < val_constr.datalen; i++) {
27614                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
27615                 LDKSignature val_conv_8_ref;
27616                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
27617                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
27618                 val_constr.data[i] = val_conv_8_ref;
27619         }
27620         CommitmentSigned_set_htlc_signatures(&this_ptr_conv, val_constr);
27621 }
27622
27623 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) {
27624         LDKThirtyTwoBytes channel_id_arg_ref;
27625         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27626         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27627         LDKSignature signature_arg_ref;
27628         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
27629         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
27630         LDKCVec_SignatureZ htlc_signatures_arg_constr;
27631         htlc_signatures_arg_constr.datalen = (*env)->GetArrayLength(env, htlc_signatures_arg);
27632         if (htlc_signatures_arg_constr.datalen > 0)
27633                 htlc_signatures_arg_constr.data = MALLOC(htlc_signatures_arg_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
27634         else
27635                 htlc_signatures_arg_constr.data = NULL;
27636         for (size_t i = 0; i < htlc_signatures_arg_constr.datalen; i++) {
27637                 int8_tArray htlc_signatures_arg_conv_8 = (*env)->GetObjectArrayElement(env, htlc_signatures_arg, i);
27638                 LDKSignature htlc_signatures_arg_conv_8_ref;
27639                 CHECK((*env)->GetArrayLength(env, htlc_signatures_arg_conv_8) == 64);
27640                 (*env)->GetByteArrayRegion(env, htlc_signatures_arg_conv_8, 0, 64, htlc_signatures_arg_conv_8_ref.compact_form);
27641                 htlc_signatures_arg_constr.data[i] = htlc_signatures_arg_conv_8_ref;
27642         }
27643         LDKCommitmentSigned ret_var = CommitmentSigned_new(channel_id_arg_ref, signature_arg_ref, htlc_signatures_arg_constr);
27644         uint64_t ret_ref = 0;
27645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27648         ret_ref = (uint64_t)ret_var.inner;
27649         if (ret_var.is_owned) {
27650                 ret_ref |= 1;
27651         }
27652         return ret_ref;
27653 }
27654
27655 static inline uint64_t CommitmentSigned_clone_ptr(LDKCommitmentSigned *NONNULL_PTR arg) {
27656         LDKCommitmentSigned ret_var = CommitmentSigned_clone(arg);
27657 uint64_t ret_ref = 0;
27658 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27659 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27660 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27661 ret_ref = (uint64_t)ret_var.inner;
27662 if (ret_var.is_owned) {
27663         ret_ref |= 1;
27664 }
27665         return ret_ref;
27666 }
27667 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27668         LDKCommitmentSigned arg_conv;
27669         arg_conv.inner = (void*)(arg & (~1));
27670         arg_conv.is_owned = false;
27671         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27672         int64_t ret_val = CommitmentSigned_clone_ptr(&arg_conv);
27673         return ret_val;
27674 }
27675
27676 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27677         LDKCommitmentSigned orig_conv;
27678         orig_conv.inner = (void*)(orig & (~1));
27679         orig_conv.is_owned = false;
27680         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27681         LDKCommitmentSigned ret_var = CommitmentSigned_clone(&orig_conv);
27682         uint64_t ret_ref = 0;
27683         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27684         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27685         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27686         ret_ref = (uint64_t)ret_var.inner;
27687         if (ret_var.is_owned) {
27688                 ret_ref |= 1;
27689         }
27690         return ret_ref;
27691 }
27692
27693 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27694         LDKRevokeAndACK this_obj_conv;
27695         this_obj_conv.inner = (void*)(this_obj & (~1));
27696         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27697         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27698         RevokeAndACK_free(this_obj_conv);
27699 }
27700
27701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27702         LDKRevokeAndACK this_ptr_conv;
27703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27704         this_ptr_conv.is_owned = false;
27705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27706         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27707         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_channel_id(&this_ptr_conv));
27708         return ret_arr;
27709 }
27710
27711 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27712         LDKRevokeAndACK this_ptr_conv;
27713         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27714         this_ptr_conv.is_owned = false;
27715         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27716         LDKThirtyTwoBytes val_ref;
27717         CHECK((*env)->GetArrayLength(env, val) == 32);
27718         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27719         RevokeAndACK_set_channel_id(&this_ptr_conv, val_ref);
27720 }
27721
27722 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
27723         LDKRevokeAndACK this_ptr_conv;
27724         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27725         this_ptr_conv.is_owned = false;
27726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27727         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27728         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *RevokeAndACK_get_per_commitment_secret(&this_ptr_conv));
27729         return ret_arr;
27730 }
27731
27732 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1set_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27733         LDKRevokeAndACK this_ptr_conv;
27734         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27735         this_ptr_conv.is_owned = false;
27736         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27737         LDKThirtyTwoBytes val_ref;
27738         CHECK((*env)->GetArrayLength(env, val) == 32);
27739         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27740         RevokeAndACK_set_per_commitment_secret(&this_ptr_conv, val_ref);
27741 }
27742
27743 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1get_1next_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27744         LDKRevokeAndACK this_ptr_conv;
27745         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27746         this_ptr_conv.is_owned = false;
27747         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27748         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27749         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RevokeAndACK_get_next_per_commitment_point(&this_ptr_conv).compressed_form);
27750         return ret_arr;
27751 }
27752
27753 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) {
27754         LDKRevokeAndACK this_ptr_conv;
27755         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27756         this_ptr_conv.is_owned = false;
27757         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27758         LDKPublicKey val_ref;
27759         CHECK((*env)->GetArrayLength(env, val) == 33);
27760         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27761         RevokeAndACK_set_next_per_commitment_point(&this_ptr_conv, val_ref);
27762 }
27763
27764 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) {
27765         LDKThirtyTwoBytes channel_id_arg_ref;
27766         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27767         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27768         LDKThirtyTwoBytes per_commitment_secret_arg_ref;
27769         CHECK((*env)->GetArrayLength(env, per_commitment_secret_arg) == 32);
27770         (*env)->GetByteArrayRegion(env, per_commitment_secret_arg, 0, 32, per_commitment_secret_arg_ref.data);
27771         LDKPublicKey next_per_commitment_point_arg_ref;
27772         CHECK((*env)->GetArrayLength(env, next_per_commitment_point_arg) == 33);
27773         (*env)->GetByteArrayRegion(env, next_per_commitment_point_arg, 0, 33, next_per_commitment_point_arg_ref.compressed_form);
27774         LDKRevokeAndACK ret_var = RevokeAndACK_new(channel_id_arg_ref, per_commitment_secret_arg_ref, next_per_commitment_point_arg_ref);
27775         uint64_t ret_ref = 0;
27776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27779         ret_ref = (uint64_t)ret_var.inner;
27780         if (ret_var.is_owned) {
27781                 ret_ref |= 1;
27782         }
27783         return ret_ref;
27784 }
27785
27786 static inline uint64_t RevokeAndACK_clone_ptr(LDKRevokeAndACK *NONNULL_PTR arg) {
27787         LDKRevokeAndACK ret_var = RevokeAndACK_clone(arg);
27788 uint64_t ret_ref = 0;
27789 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27790 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27791 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27792 ret_ref = (uint64_t)ret_var.inner;
27793 if (ret_var.is_owned) {
27794         ret_ref |= 1;
27795 }
27796         return ret_ref;
27797 }
27798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27799         LDKRevokeAndACK arg_conv;
27800         arg_conv.inner = (void*)(arg & (~1));
27801         arg_conv.is_owned = false;
27802         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27803         int64_t ret_val = RevokeAndACK_clone_ptr(&arg_conv);
27804         return ret_val;
27805 }
27806
27807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27808         LDKRevokeAndACK orig_conv;
27809         orig_conv.inner = (void*)(orig & (~1));
27810         orig_conv.is_owned = false;
27811         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27812         LDKRevokeAndACK ret_var = RevokeAndACK_clone(&orig_conv);
27813         uint64_t ret_ref = 0;
27814         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27815         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27817         ret_ref = (uint64_t)ret_var.inner;
27818         if (ret_var.is_owned) {
27819                 ret_ref |= 1;
27820         }
27821         return ret_ref;
27822 }
27823
27824 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27825         LDKUpdateFee this_obj_conv;
27826         this_obj_conv.inner = (void*)(this_obj & (~1));
27827         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27828         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27829         UpdateFee_free(this_obj_conv);
27830 }
27831
27832 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
27833         LDKUpdateFee this_ptr_conv;
27834         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27835         this_ptr_conv.is_owned = false;
27836         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27837         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27838         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UpdateFee_get_channel_id(&this_ptr_conv));
27839         return ret_arr;
27840 }
27841
27842 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
27843         LDKUpdateFee this_ptr_conv;
27844         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27845         this_ptr_conv.is_owned = false;
27846         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27847         LDKThirtyTwoBytes val_ref;
27848         CHECK((*env)->GetArrayLength(env, val) == 32);
27849         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27850         UpdateFee_set_channel_id(&this_ptr_conv, val_ref);
27851 }
27852
27853 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1get_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr) {
27854         LDKUpdateFee this_ptr_conv;
27855         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27856         this_ptr_conv.is_owned = false;
27857         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27858         int32_t ret_val = UpdateFee_get_feerate_per_kw(&this_ptr_conv);
27859         return ret_val;
27860 }
27861
27862 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UpdateFee_1set_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
27863         LDKUpdateFee this_ptr_conv;
27864         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27865         this_ptr_conv.is_owned = false;
27866         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27867         UpdateFee_set_feerate_per_kw(&this_ptr_conv, val);
27868 }
27869
27870 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) {
27871         LDKThirtyTwoBytes channel_id_arg_ref;
27872         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
27873         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
27874         LDKUpdateFee ret_var = UpdateFee_new(channel_id_arg_ref, feerate_per_kw_arg);
27875         uint64_t ret_ref = 0;
27876         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27877         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27879         ret_ref = (uint64_t)ret_var.inner;
27880         if (ret_var.is_owned) {
27881                 ret_ref |= 1;
27882         }
27883         return ret_ref;
27884 }
27885
27886 static inline uint64_t UpdateFee_clone_ptr(LDKUpdateFee *NONNULL_PTR arg) {
27887         LDKUpdateFee ret_var = UpdateFee_clone(arg);
27888 uint64_t ret_ref = 0;
27889 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27890 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27891 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27892 ret_ref = (uint64_t)ret_var.inner;
27893 if (ret_var.is_owned) {
27894         ret_ref |= 1;
27895 }
27896         return ret_ref;
27897 }
27898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
27899         LDKUpdateFee arg_conv;
27900         arg_conv.inner = (void*)(arg & (~1));
27901         arg_conv.is_owned = false;
27902         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
27903         int64_t ret_val = UpdateFee_clone_ptr(&arg_conv);
27904         return ret_val;
27905 }
27906
27907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
27908         LDKUpdateFee orig_conv;
27909         orig_conv.inner = (void*)(orig & (~1));
27910         orig_conv.is_owned = false;
27911         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
27912         LDKUpdateFee ret_var = UpdateFee_clone(&orig_conv);
27913         uint64_t ret_ref = 0;
27914         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27915         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27917         ret_ref = (uint64_t)ret_var.inner;
27918         if (ret_var.is_owned) {
27919                 ret_ref |= 1;
27920         }
27921         return ret_ref;
27922 }
27923
27924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
27925         LDKDataLossProtect this_obj_conv;
27926         this_obj_conv.inner = (void*)(this_obj & (~1));
27927         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
27928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
27929         DataLossProtect_free(this_obj_conv);
27930 }
27931
27932 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1your_1last_1per_1commitment_1secret(JNIEnv *env, jclass clz, int64_t this_ptr) {
27933         LDKDataLossProtect this_ptr_conv;
27934         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27935         this_ptr_conv.is_owned = false;
27936         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27937         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
27938         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *DataLossProtect_get_your_last_per_commitment_secret(&this_ptr_conv));
27939         return ret_arr;
27940 }
27941
27942 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) {
27943         LDKDataLossProtect this_ptr_conv;
27944         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27945         this_ptr_conv.is_owned = false;
27946         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27947         LDKThirtyTwoBytes val_ref;
27948         CHECK((*env)->GetArrayLength(env, val) == 32);
27949         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
27950         DataLossProtect_set_your_last_per_commitment_secret(&this_ptr_conv, val_ref);
27951 }
27952
27953 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1get_1my_1current_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
27954         LDKDataLossProtect this_ptr_conv;
27955         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27956         this_ptr_conv.is_owned = false;
27957         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27958         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
27959         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, DataLossProtect_get_my_current_per_commitment_point(&this_ptr_conv).compressed_form);
27960         return ret_arr;
27961 }
27962
27963 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) {
27964         LDKDataLossProtect this_ptr_conv;
27965         this_ptr_conv.inner = (void*)(this_ptr & (~1));
27966         this_ptr_conv.is_owned = false;
27967         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
27968         LDKPublicKey val_ref;
27969         CHECK((*env)->GetArrayLength(env, val) == 33);
27970         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
27971         DataLossProtect_set_my_current_per_commitment_point(&this_ptr_conv, val_ref);
27972 }
27973
27974 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) {
27975         LDKThirtyTwoBytes your_last_per_commitment_secret_arg_ref;
27976         CHECK((*env)->GetArrayLength(env, your_last_per_commitment_secret_arg) == 32);
27977         (*env)->GetByteArrayRegion(env, your_last_per_commitment_secret_arg, 0, 32, your_last_per_commitment_secret_arg_ref.data);
27978         LDKPublicKey my_current_per_commitment_point_arg_ref;
27979         CHECK((*env)->GetArrayLength(env, my_current_per_commitment_point_arg) == 33);
27980         (*env)->GetByteArrayRegion(env, my_current_per_commitment_point_arg, 0, 33, my_current_per_commitment_point_arg_ref.compressed_form);
27981         LDKDataLossProtect ret_var = DataLossProtect_new(your_last_per_commitment_secret_arg_ref, my_current_per_commitment_point_arg_ref);
27982         uint64_t ret_ref = 0;
27983         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27984         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27985         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27986         ret_ref = (uint64_t)ret_var.inner;
27987         if (ret_var.is_owned) {
27988                 ret_ref |= 1;
27989         }
27990         return ret_ref;
27991 }
27992
27993 static inline uint64_t DataLossProtect_clone_ptr(LDKDataLossProtect *NONNULL_PTR arg) {
27994         LDKDataLossProtect ret_var = DataLossProtect_clone(arg);
27995 uint64_t ret_ref = 0;
27996 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
27997 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
27998 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
27999 ret_ref = (uint64_t)ret_var.inner;
28000 if (ret_var.is_owned) {
28001         ret_ref |= 1;
28002 }
28003         return ret_ref;
28004 }
28005 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28006         LDKDataLossProtect arg_conv;
28007         arg_conv.inner = (void*)(arg & (~1));
28008         arg_conv.is_owned = false;
28009         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28010         int64_t ret_val = DataLossProtect_clone_ptr(&arg_conv);
28011         return ret_val;
28012 }
28013
28014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DataLossProtect_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28015         LDKDataLossProtect orig_conv;
28016         orig_conv.inner = (void*)(orig & (~1));
28017         orig_conv.is_owned = false;
28018         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28019         LDKDataLossProtect ret_var = DataLossProtect_clone(&orig_conv);
28020         uint64_t ret_ref = 0;
28021         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28022         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28023         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28024         ret_ref = (uint64_t)ret_var.inner;
28025         if (ret_var.is_owned) {
28026                 ret_ref |= 1;
28027         }
28028         return ret_ref;
28029 }
28030
28031 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28032         LDKChannelReestablish this_obj_conv;
28033         this_obj_conv.inner = (void*)(this_obj & (~1));
28034         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28035         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28036         ChannelReestablish_free(this_obj_conv);
28037 }
28038
28039 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28040         LDKChannelReestablish this_ptr_conv;
28041         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28042         this_ptr_conv.is_owned = false;
28043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28044         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28045         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ChannelReestablish_get_channel_id(&this_ptr_conv));
28046         return ret_arr;
28047 }
28048
28049 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28050         LDKChannelReestablish this_ptr_conv;
28051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28052         this_ptr_conv.is_owned = false;
28053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28054         LDKThirtyTwoBytes val_ref;
28055         CHECK((*env)->GetArrayLength(env, val) == 32);
28056         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28057         ChannelReestablish_set_channel_id(&this_ptr_conv, val_ref);
28058 }
28059
28060 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1local_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
28061         LDKChannelReestablish this_ptr_conv;
28062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28063         this_ptr_conv.is_owned = false;
28064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28065         int64_t ret_val = ChannelReestablish_get_next_local_commitment_number(&this_ptr_conv);
28066         return ret_val;
28067 }
28068
28069 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) {
28070         LDKChannelReestablish this_ptr_conv;
28071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28072         this_ptr_conv.is_owned = false;
28073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28074         ChannelReestablish_set_next_local_commitment_number(&this_ptr_conv, val);
28075 }
28076
28077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1get_1next_1remote_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_ptr) {
28078         LDKChannelReestablish this_ptr_conv;
28079         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28080         this_ptr_conv.is_owned = false;
28081         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28082         int64_t ret_val = ChannelReestablish_get_next_remote_commitment_number(&this_ptr_conv);
28083         return ret_val;
28084 }
28085
28086 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) {
28087         LDKChannelReestablish this_ptr_conv;
28088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28089         this_ptr_conv.is_owned = false;
28090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28091         ChannelReestablish_set_next_remote_commitment_number(&this_ptr_conv, val);
28092 }
28093
28094 static inline uint64_t ChannelReestablish_clone_ptr(LDKChannelReestablish *NONNULL_PTR arg) {
28095         LDKChannelReestablish ret_var = ChannelReestablish_clone(arg);
28096 uint64_t ret_ref = 0;
28097 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28098 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28099 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28100 ret_ref = (uint64_t)ret_var.inner;
28101 if (ret_var.is_owned) {
28102         ret_ref |= 1;
28103 }
28104         return ret_ref;
28105 }
28106 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28107         LDKChannelReestablish arg_conv;
28108         arg_conv.inner = (void*)(arg & (~1));
28109         arg_conv.is_owned = false;
28110         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28111         int64_t ret_val = ChannelReestablish_clone_ptr(&arg_conv);
28112         return ret_val;
28113 }
28114
28115 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28116         LDKChannelReestablish orig_conv;
28117         orig_conv.inner = (void*)(orig & (~1));
28118         orig_conv.is_owned = false;
28119         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28120         LDKChannelReestablish ret_var = ChannelReestablish_clone(&orig_conv);
28121         uint64_t ret_ref = 0;
28122         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28123         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28124         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28125         ret_ref = (uint64_t)ret_var.inner;
28126         if (ret_var.is_owned) {
28127                 ret_ref |= 1;
28128         }
28129         return ret_ref;
28130 }
28131
28132 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28133         LDKAnnouncementSignatures this_obj_conv;
28134         this_obj_conv.inner = (void*)(this_obj & (~1));
28135         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28136         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28137         AnnouncementSignatures_free(this_obj_conv);
28138 }
28139
28140 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28141         LDKAnnouncementSignatures this_ptr_conv;
28142         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28143         this_ptr_conv.is_owned = false;
28144         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28145         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28146         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *AnnouncementSignatures_get_channel_id(&this_ptr_conv));
28147         return ret_arr;
28148 }
28149
28150 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28151         LDKAnnouncementSignatures this_ptr_conv;
28152         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28153         this_ptr_conv.is_owned = false;
28154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28155         LDKThirtyTwoBytes val_ref;
28156         CHECK((*env)->GetArrayLength(env, val) == 32);
28157         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28158         AnnouncementSignatures_set_channel_id(&this_ptr_conv, val_ref);
28159 }
28160
28161 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28162         LDKAnnouncementSignatures this_ptr_conv;
28163         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28164         this_ptr_conv.is_owned = false;
28165         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28166         int64_t ret_val = AnnouncementSignatures_get_short_channel_id(&this_ptr_conv);
28167         return ret_val;
28168 }
28169
28170 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28171         LDKAnnouncementSignatures this_ptr_conv;
28172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28173         this_ptr_conv.is_owned = false;
28174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28175         AnnouncementSignatures_set_short_channel_id(&this_ptr_conv, val);
28176 }
28177
28178 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28179         LDKAnnouncementSignatures this_ptr_conv;
28180         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28181         this_ptr_conv.is_owned = false;
28182         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28183         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28184         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_node_signature(&this_ptr_conv).compact_form);
28185         return ret_arr;
28186 }
28187
28188 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1node_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28189         LDKAnnouncementSignatures this_ptr_conv;
28190         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28191         this_ptr_conv.is_owned = false;
28192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28193         LDKSignature val_ref;
28194         CHECK((*env)->GetArrayLength(env, val) == 64);
28195         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28196         AnnouncementSignatures_set_node_signature(&this_ptr_conv, val_ref);
28197 }
28198
28199 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1get_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28200         LDKAnnouncementSignatures this_ptr_conv;
28201         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28202         this_ptr_conv.is_owned = false;
28203         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28204         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28205         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, AnnouncementSignatures_get_bitcoin_signature(&this_ptr_conv).compact_form);
28206         return ret_arr;
28207 }
28208
28209 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1set_1bitcoin_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28210         LDKAnnouncementSignatures this_ptr_conv;
28211         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28212         this_ptr_conv.is_owned = false;
28213         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28214         LDKSignature val_ref;
28215         CHECK((*env)->GetArrayLength(env, val) == 64);
28216         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28217         AnnouncementSignatures_set_bitcoin_signature(&this_ptr_conv, val_ref);
28218 }
28219
28220 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) {
28221         LDKThirtyTwoBytes channel_id_arg_ref;
28222         CHECK((*env)->GetArrayLength(env, channel_id_arg) == 32);
28223         (*env)->GetByteArrayRegion(env, channel_id_arg, 0, 32, channel_id_arg_ref.data);
28224         LDKSignature node_signature_arg_ref;
28225         CHECK((*env)->GetArrayLength(env, node_signature_arg) == 64);
28226         (*env)->GetByteArrayRegion(env, node_signature_arg, 0, 64, node_signature_arg_ref.compact_form);
28227         LDKSignature bitcoin_signature_arg_ref;
28228         CHECK((*env)->GetArrayLength(env, bitcoin_signature_arg) == 64);
28229         (*env)->GetByteArrayRegion(env, bitcoin_signature_arg, 0, 64, bitcoin_signature_arg_ref.compact_form);
28230         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_new(channel_id_arg_ref, short_channel_id_arg, node_signature_arg_ref, bitcoin_signature_arg_ref);
28231         uint64_t ret_ref = 0;
28232         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28233         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28234         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28235         ret_ref = (uint64_t)ret_var.inner;
28236         if (ret_var.is_owned) {
28237                 ret_ref |= 1;
28238         }
28239         return ret_ref;
28240 }
28241
28242 static inline uint64_t AnnouncementSignatures_clone_ptr(LDKAnnouncementSignatures *NONNULL_PTR arg) {
28243         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(arg);
28244 uint64_t ret_ref = 0;
28245 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28246 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28247 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28248 ret_ref = (uint64_t)ret_var.inner;
28249 if (ret_var.is_owned) {
28250         ret_ref |= 1;
28251 }
28252         return ret_ref;
28253 }
28254 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28255         LDKAnnouncementSignatures arg_conv;
28256         arg_conv.inner = (void*)(arg & (~1));
28257         arg_conv.is_owned = false;
28258         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28259         int64_t ret_val = AnnouncementSignatures_clone_ptr(&arg_conv);
28260         return ret_val;
28261 }
28262
28263 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28264         LDKAnnouncementSignatures orig_conv;
28265         orig_conv.inner = (void*)(orig & (~1));
28266         orig_conv.is_owned = false;
28267         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28268         LDKAnnouncementSignatures ret_var = AnnouncementSignatures_clone(&orig_conv);
28269         uint64_t ret_ref = 0;
28270         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28271         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28272         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28273         ret_ref = (uint64_t)ret_var.inner;
28274         if (ret_var.is_owned) {
28275                 ret_ref |= 1;
28276         }
28277         return ret_ref;
28278 }
28279
28280 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetAddress_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
28281         if ((this_ptr & 1) != 0) return;
28282         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
28283         CHECK_ACCESS(this_ptr_ptr);
28284         LDKNetAddress this_ptr_conv = *(LDKNetAddress*)(this_ptr_ptr);
28285         FREE((void*)this_ptr);
28286         NetAddress_free(this_ptr_conv);
28287 }
28288
28289 static inline uint64_t NetAddress_clone_ptr(LDKNetAddress *NONNULL_PTR arg) {
28290         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28291         *ret_copy = NetAddress_clone(arg);
28292 uint64_t ret_ref = (uint64_t)ret_copy;
28293         return ret_ref;
28294 }
28295 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28296         LDKNetAddress* arg_conv = (LDKNetAddress*)arg;
28297         int64_t ret_val = NetAddress_clone_ptr(arg_conv);
28298         return ret_val;
28299 }
28300
28301 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28302         LDKNetAddress* orig_conv = (LDKNetAddress*)orig;
28303         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28304         *ret_copy = NetAddress_clone(orig_conv);
28305         uint64_t ret_ref = (uint64_t)ret_copy;
28306         return ret_ref;
28307 }
28308
28309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv4(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
28310         LDKFourBytes addr_ref;
28311         CHECK((*env)->GetArrayLength(env, addr) == 4);
28312         (*env)->GetByteArrayRegion(env, addr, 0, 4, addr_ref.data);
28313         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28314         *ret_copy = NetAddress_ipv4(addr_ref, port);
28315         uint64_t ret_ref = (uint64_t)ret_copy;
28316         return ret_ref;
28317 }
28318
28319 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1ipv6(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
28320         LDKSixteenBytes addr_ref;
28321         CHECK((*env)->GetArrayLength(env, addr) == 16);
28322         (*env)->GetByteArrayRegion(env, addr, 0, 16, addr_ref.data);
28323         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28324         *ret_copy = NetAddress_ipv6(addr_ref, port);
28325         uint64_t ret_ref = (uint64_t)ret_copy;
28326         return ret_ref;
28327 }
28328
28329 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1onion_1v2(JNIEnv *env, jclass clz, int8_tArray addr, int16_t port) {
28330         LDKTenBytes addr_ref;
28331         CHECK((*env)->GetArrayLength(env, addr) == 10);
28332         (*env)->GetByteArrayRegion(env, addr, 0, 10, addr_ref.data);
28333         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28334         *ret_copy = NetAddress_onion_v2(addr_ref, port);
28335         uint64_t ret_ref = (uint64_t)ret_copy;
28336         return ret_ref;
28337 }
28338
28339 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) {
28340         LDKThirtyTwoBytes ed25519_pubkey_ref;
28341         CHECK((*env)->GetArrayLength(env, ed25519_pubkey) == 32);
28342         (*env)->GetByteArrayRegion(env, ed25519_pubkey, 0, 32, ed25519_pubkey_ref.data);
28343         LDKNetAddress *ret_copy = MALLOC(sizeof(LDKNetAddress), "LDKNetAddress");
28344         *ret_copy = NetAddress_onion_v3(ed25519_pubkey_ref, checksum, version, port);
28345         uint64_t ret_ref = (uint64_t)ret_copy;
28346         return ret_ref;
28347 }
28348
28349 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetAddress_1write(JNIEnv *env, jclass clz, int64_t obj) {
28350         LDKNetAddress* obj_conv = (LDKNetAddress*)obj;
28351         LDKCVec_u8Z ret_var = NetAddress_write(obj_conv);
28352         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
28353         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
28354         CVec_u8Z_free(ret_var);
28355         return ret_arr;
28356 }
28357
28358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetAddress_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
28359         LDKu8slice ser_ref;
28360         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
28361         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
28362         LDKCResult_NetAddressDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetAddressDecodeErrorZ), "LDKCResult_NetAddressDecodeErrorZ");
28363         *ret_conv = NetAddress_read(ser_ref);
28364         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
28365         return (uint64_t)ret_conv;
28366 }
28367
28368 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28369         LDKUnsignedNodeAnnouncement this_obj_conv;
28370         this_obj_conv.inner = (void*)(this_obj & (~1));
28371         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28373         UnsignedNodeAnnouncement_free(this_obj_conv);
28374 }
28375
28376 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28377         LDKUnsignedNodeAnnouncement this_ptr_conv;
28378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28379         this_ptr_conv.is_owned = false;
28380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28381         LDKNodeFeatures ret_var = UnsignedNodeAnnouncement_get_features(&this_ptr_conv);
28382         uint64_t ret_ref = 0;
28383         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28384         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28385         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28386         ret_ref = (uint64_t)ret_var.inner;
28387         if (ret_var.is_owned) {
28388                 ret_ref |= 1;
28389         }
28390         return ret_ref;
28391 }
28392
28393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28394         LDKUnsignedNodeAnnouncement this_ptr_conv;
28395         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28396         this_ptr_conv.is_owned = false;
28397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28398         LDKNodeFeatures val_conv;
28399         val_conv.inner = (void*)(val & (~1));
28400         val_conv.is_owned = (val & 1) || (val == 0);
28401         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28402         val_conv = NodeFeatures_clone(&val_conv);
28403         UnsignedNodeAnnouncement_set_features(&this_ptr_conv, val_conv);
28404 }
28405
28406 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
28407         LDKUnsignedNodeAnnouncement this_ptr_conv;
28408         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28409         this_ptr_conv.is_owned = false;
28410         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28411         int32_t ret_val = UnsignedNodeAnnouncement_get_timestamp(&this_ptr_conv);
28412         return ret_val;
28413 }
28414
28415 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
28416         LDKUnsignedNodeAnnouncement this_ptr_conv;
28417         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28418         this_ptr_conv.is_owned = false;
28419         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28420         UnsignedNodeAnnouncement_set_timestamp(&this_ptr_conv, val);
28421 }
28422
28423 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28424         LDKUnsignedNodeAnnouncement this_ptr_conv;
28425         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28426         this_ptr_conv.is_owned = false;
28427         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28428         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28429         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedNodeAnnouncement_get_node_id(&this_ptr_conv).compressed_form);
28430         return ret_arr;
28431 }
28432
28433 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28434         LDKUnsignedNodeAnnouncement this_ptr_conv;
28435         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28436         this_ptr_conv.is_owned = false;
28437         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28438         LDKPublicKey val_ref;
28439         CHECK((*env)->GetArrayLength(env, val) == 33);
28440         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28441         UnsignedNodeAnnouncement_set_node_id(&this_ptr_conv, val_ref);
28442 }
28443
28444 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
28445         LDKUnsignedNodeAnnouncement this_ptr_conv;
28446         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28447         this_ptr_conv.is_owned = false;
28448         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28449         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
28450         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *UnsignedNodeAnnouncement_get_rgb(&this_ptr_conv));
28451         return ret_arr;
28452 }
28453
28454 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28455         LDKUnsignedNodeAnnouncement this_ptr_conv;
28456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28457         this_ptr_conv.is_owned = false;
28458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28459         LDKThreeBytes val_ref;
28460         CHECK((*env)->GetArrayLength(env, val) == 3);
28461         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
28462         UnsignedNodeAnnouncement_set_rgb(&this_ptr_conv, val_ref);
28463 }
28464
28465 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
28466         LDKUnsignedNodeAnnouncement this_ptr_conv;
28467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28468         this_ptr_conv.is_owned = false;
28469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28470         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28471         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedNodeAnnouncement_get_alias(&this_ptr_conv));
28472         return ret_arr;
28473 }
28474
28475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28476         LDKUnsignedNodeAnnouncement this_ptr_conv;
28477         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28478         this_ptr_conv.is_owned = false;
28479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28480         LDKThirtyTwoBytes val_ref;
28481         CHECK((*env)->GetArrayLength(env, val) == 32);
28482         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28483         UnsignedNodeAnnouncement_set_alias(&this_ptr_conv, val_ref);
28484 }
28485
28486 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
28487         LDKUnsignedNodeAnnouncement this_ptr_conv;
28488         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28489         this_ptr_conv.is_owned = false;
28490         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28491         LDKCVec_NetAddressZ val_constr;
28492         val_constr.datalen = (*env)->GetArrayLength(env, val);
28493         if (val_constr.datalen > 0)
28494                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
28495         else
28496                 val_constr.data = NULL;
28497         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
28498         for (size_t m = 0; m < val_constr.datalen; m++) {
28499                 int64_t val_conv_12 = val_vals[m];
28500                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
28501                 CHECK_ACCESS(val_conv_12_ptr);
28502                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
28503                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
28504                 val_constr.data[m] = val_conv_12_conv;
28505         }
28506         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
28507         UnsignedNodeAnnouncement_set_addresses(&this_ptr_conv, val_constr);
28508 }
28509
28510 static inline uint64_t UnsignedNodeAnnouncement_clone_ptr(LDKUnsignedNodeAnnouncement *NONNULL_PTR arg) {
28511         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(arg);
28512 uint64_t ret_ref = 0;
28513 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28514 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28515 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28516 ret_ref = (uint64_t)ret_var.inner;
28517 if (ret_var.is_owned) {
28518         ret_ref |= 1;
28519 }
28520         return ret_ref;
28521 }
28522 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28523         LDKUnsignedNodeAnnouncement arg_conv;
28524         arg_conv.inner = (void*)(arg & (~1));
28525         arg_conv.is_owned = false;
28526         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28527         int64_t ret_val = UnsignedNodeAnnouncement_clone_ptr(&arg_conv);
28528         return ret_val;
28529 }
28530
28531 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28532         LDKUnsignedNodeAnnouncement orig_conv;
28533         orig_conv.inner = (void*)(orig & (~1));
28534         orig_conv.is_owned = false;
28535         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28536         LDKUnsignedNodeAnnouncement ret_var = UnsignedNodeAnnouncement_clone(&orig_conv);
28537         uint64_t ret_ref = 0;
28538         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28539         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28540         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28541         ret_ref = (uint64_t)ret_var.inner;
28542         if (ret_var.is_owned) {
28543                 ret_ref |= 1;
28544         }
28545         return ret_ref;
28546 }
28547
28548 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28549         LDKNodeAnnouncement this_obj_conv;
28550         this_obj_conv.inner = (void*)(this_obj & (~1));
28551         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28552         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28553         NodeAnnouncement_free(this_obj_conv);
28554 }
28555
28556 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
28557         LDKNodeAnnouncement this_ptr_conv;
28558         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28559         this_ptr_conv.is_owned = false;
28560         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28561         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28562         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, NodeAnnouncement_get_signature(&this_ptr_conv).compact_form);
28563         return ret_arr;
28564 }
28565
28566 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28567         LDKNodeAnnouncement this_ptr_conv;
28568         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28569         this_ptr_conv.is_owned = false;
28570         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28571         LDKSignature val_ref;
28572         CHECK((*env)->GetArrayLength(env, val) == 64);
28573         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28574         NodeAnnouncement_set_signature(&this_ptr_conv, val_ref);
28575 }
28576
28577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
28578         LDKNodeAnnouncement this_ptr_conv;
28579         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28580         this_ptr_conv.is_owned = false;
28581         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28582         LDKUnsignedNodeAnnouncement ret_var = NodeAnnouncement_get_contents(&this_ptr_conv);
28583         uint64_t ret_ref = 0;
28584         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28585         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28586         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28587         ret_ref = (uint64_t)ret_var.inner;
28588         if (ret_var.is_owned) {
28589                 ret_ref |= 1;
28590         }
28591         return ret_ref;
28592 }
28593
28594 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28595         LDKNodeAnnouncement this_ptr_conv;
28596         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28597         this_ptr_conv.is_owned = false;
28598         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28599         LDKUnsignedNodeAnnouncement val_conv;
28600         val_conv.inner = (void*)(val & (~1));
28601         val_conv.is_owned = (val & 1) || (val == 0);
28602         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28603         val_conv = UnsignedNodeAnnouncement_clone(&val_conv);
28604         NodeAnnouncement_set_contents(&this_ptr_conv, val_conv);
28605 }
28606
28607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
28608         LDKSignature signature_arg_ref;
28609         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
28610         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
28611         LDKUnsignedNodeAnnouncement contents_arg_conv;
28612         contents_arg_conv.inner = (void*)(contents_arg & (~1));
28613         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
28614         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
28615         contents_arg_conv = UnsignedNodeAnnouncement_clone(&contents_arg_conv);
28616         LDKNodeAnnouncement ret_var = NodeAnnouncement_new(signature_arg_ref, contents_arg_conv);
28617         uint64_t ret_ref = 0;
28618         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28619         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28620         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28621         ret_ref = (uint64_t)ret_var.inner;
28622         if (ret_var.is_owned) {
28623                 ret_ref |= 1;
28624         }
28625         return ret_ref;
28626 }
28627
28628 static inline uint64_t NodeAnnouncement_clone_ptr(LDKNodeAnnouncement *NONNULL_PTR arg) {
28629         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(arg);
28630 uint64_t ret_ref = 0;
28631 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28632 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28633 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28634 ret_ref = (uint64_t)ret_var.inner;
28635 if (ret_var.is_owned) {
28636         ret_ref |= 1;
28637 }
28638         return ret_ref;
28639 }
28640 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28641         LDKNodeAnnouncement arg_conv;
28642         arg_conv.inner = (void*)(arg & (~1));
28643         arg_conv.is_owned = false;
28644         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28645         int64_t ret_val = NodeAnnouncement_clone_ptr(&arg_conv);
28646         return ret_val;
28647 }
28648
28649 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28650         LDKNodeAnnouncement orig_conv;
28651         orig_conv.inner = (void*)(orig & (~1));
28652         orig_conv.is_owned = false;
28653         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28654         LDKNodeAnnouncement ret_var = NodeAnnouncement_clone(&orig_conv);
28655         uint64_t ret_ref = 0;
28656         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28657         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28658         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28659         ret_ref = (uint64_t)ret_var.inner;
28660         if (ret_var.is_owned) {
28661                 ret_ref |= 1;
28662         }
28663         return ret_ref;
28664 }
28665
28666 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28667         LDKUnsignedChannelAnnouncement this_obj_conv;
28668         this_obj_conv.inner = (void*)(this_obj & (~1));
28669         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28670         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28671         UnsignedChannelAnnouncement_free(this_obj_conv);
28672 }
28673
28674 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
28675         LDKUnsignedChannelAnnouncement this_ptr_conv;
28676         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28677         this_ptr_conv.is_owned = false;
28678         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28679         LDKChannelFeatures ret_var = UnsignedChannelAnnouncement_get_features(&this_ptr_conv);
28680         uint64_t ret_ref = 0;
28681         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28682         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28683         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28684         ret_ref = (uint64_t)ret_var.inner;
28685         if (ret_var.is_owned) {
28686                 ret_ref |= 1;
28687         }
28688         return ret_ref;
28689 }
28690
28691 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28692         LDKUnsignedChannelAnnouncement this_ptr_conv;
28693         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28694         this_ptr_conv.is_owned = false;
28695         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28696         LDKChannelFeatures val_conv;
28697         val_conv.inner = (void*)(val & (~1));
28698         val_conv.is_owned = (val & 1) || (val == 0);
28699         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28700         val_conv = ChannelFeatures_clone(&val_conv);
28701         UnsignedChannelAnnouncement_set_features(&this_ptr_conv, val_conv);
28702 }
28703
28704 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
28705         LDKUnsignedChannelAnnouncement this_ptr_conv;
28706         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28707         this_ptr_conv.is_owned = false;
28708         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28709         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
28710         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelAnnouncement_get_chain_hash(&this_ptr_conv));
28711         return ret_arr;
28712 }
28713
28714 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28715         LDKUnsignedChannelAnnouncement this_ptr_conv;
28716         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28717         this_ptr_conv.is_owned = false;
28718         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28719         LDKThirtyTwoBytes val_ref;
28720         CHECK((*env)->GetArrayLength(env, val) == 32);
28721         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
28722         UnsignedChannelAnnouncement_set_chain_hash(&this_ptr_conv, val_ref);
28723 }
28724
28725 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
28726         LDKUnsignedChannelAnnouncement this_ptr_conv;
28727         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28728         this_ptr_conv.is_owned = false;
28729         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28730         int64_t ret_val = UnsignedChannelAnnouncement_get_short_channel_id(&this_ptr_conv);
28731         return ret_val;
28732 }
28733
28734 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28735         LDKUnsignedChannelAnnouncement this_ptr_conv;
28736         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28737         this_ptr_conv.is_owned = false;
28738         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28739         UnsignedChannelAnnouncement_set_short_channel_id(&this_ptr_conv, val);
28740 }
28741
28742 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
28743         LDKUnsignedChannelAnnouncement this_ptr_conv;
28744         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28745         this_ptr_conv.is_owned = false;
28746         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28747         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28748         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_1(&this_ptr_conv).compressed_form);
28749         return ret_arr;
28750 }
28751
28752 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28753         LDKUnsignedChannelAnnouncement this_ptr_conv;
28754         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28755         this_ptr_conv.is_owned = false;
28756         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28757         LDKPublicKey val_ref;
28758         CHECK((*env)->GetArrayLength(env, val) == 33);
28759         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28760         UnsignedChannelAnnouncement_set_node_id_1(&this_ptr_conv, val_ref);
28761 }
28762
28763 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
28764         LDKUnsignedChannelAnnouncement this_ptr_conv;
28765         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28766         this_ptr_conv.is_owned = false;
28767         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28768         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28769         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_node_id_2(&this_ptr_conv).compressed_form);
28770         return ret_arr;
28771 }
28772
28773 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1node_1id_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28774         LDKUnsignedChannelAnnouncement this_ptr_conv;
28775         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28776         this_ptr_conv.is_owned = false;
28777         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28778         LDKPublicKey val_ref;
28779         CHECK((*env)->GetArrayLength(env, val) == 33);
28780         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28781         UnsignedChannelAnnouncement_set_node_id_2(&this_ptr_conv, val_ref);
28782 }
28783
28784 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
28785         LDKUnsignedChannelAnnouncement this_ptr_conv;
28786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28787         this_ptr_conv.is_owned = false;
28788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28789         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28790         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_1(&this_ptr_conv).compressed_form);
28791         return ret_arr;
28792 }
28793
28794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28795         LDKUnsignedChannelAnnouncement this_ptr_conv;
28796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28797         this_ptr_conv.is_owned = false;
28798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28799         LDKPublicKey val_ref;
28800         CHECK((*env)->GetArrayLength(env, val) == 33);
28801         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28802         UnsignedChannelAnnouncement_set_bitcoin_key_1(&this_ptr_conv, val_ref);
28803 }
28804
28805 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1get_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
28806         LDKUnsignedChannelAnnouncement this_ptr_conv;
28807         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28808         this_ptr_conv.is_owned = false;
28809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28810         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
28811         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, UnsignedChannelAnnouncement_get_bitcoin_key_2(&this_ptr_conv).compressed_form);
28812         return ret_arr;
28813 }
28814
28815 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1set_1bitcoin_1key_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28816         LDKUnsignedChannelAnnouncement this_ptr_conv;
28817         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28818         this_ptr_conv.is_owned = false;
28819         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28820         LDKPublicKey val_ref;
28821         CHECK((*env)->GetArrayLength(env, val) == 33);
28822         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
28823         UnsignedChannelAnnouncement_set_bitcoin_key_2(&this_ptr_conv, val_ref);
28824 }
28825
28826 static inline uint64_t UnsignedChannelAnnouncement_clone_ptr(LDKUnsignedChannelAnnouncement *NONNULL_PTR arg) {
28827         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(arg);
28828 uint64_t ret_ref = 0;
28829 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28830 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28831 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28832 ret_ref = (uint64_t)ret_var.inner;
28833 if (ret_var.is_owned) {
28834         ret_ref |= 1;
28835 }
28836         return ret_ref;
28837 }
28838 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
28839         LDKUnsignedChannelAnnouncement arg_conv;
28840         arg_conv.inner = (void*)(arg & (~1));
28841         arg_conv.is_owned = false;
28842         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
28843         int64_t ret_val = UnsignedChannelAnnouncement_clone_ptr(&arg_conv);
28844         return ret_val;
28845 }
28846
28847 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
28848         LDKUnsignedChannelAnnouncement orig_conv;
28849         orig_conv.inner = (void*)(orig & (~1));
28850         orig_conv.is_owned = false;
28851         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
28852         LDKUnsignedChannelAnnouncement ret_var = UnsignedChannelAnnouncement_clone(&orig_conv);
28853         uint64_t ret_ref = 0;
28854         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28855         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28856         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28857         ret_ref = (uint64_t)ret_var.inner;
28858         if (ret_var.is_owned) {
28859                 ret_ref |= 1;
28860         }
28861         return ret_ref;
28862 }
28863
28864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
28865         LDKChannelAnnouncement this_obj_conv;
28866         this_obj_conv.inner = (void*)(this_obj & (~1));
28867         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
28868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
28869         ChannelAnnouncement_free(this_obj_conv);
28870 }
28871
28872 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
28873         LDKChannelAnnouncement this_ptr_conv;
28874         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28875         this_ptr_conv.is_owned = false;
28876         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28877         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28878         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_1(&this_ptr_conv).compact_form);
28879         return ret_arr;
28880 }
28881
28882 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28883         LDKChannelAnnouncement this_ptr_conv;
28884         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28885         this_ptr_conv.is_owned = false;
28886         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28887         LDKSignature val_ref;
28888         CHECK((*env)->GetArrayLength(env, val) == 64);
28889         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28890         ChannelAnnouncement_set_node_signature_1(&this_ptr_conv, val_ref);
28891 }
28892
28893 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
28894         LDKChannelAnnouncement this_ptr_conv;
28895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28896         this_ptr_conv.is_owned = false;
28897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28898         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28899         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_node_signature_2(&this_ptr_conv).compact_form);
28900         return ret_arr;
28901 }
28902
28903 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1node_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28904         LDKChannelAnnouncement this_ptr_conv;
28905         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28906         this_ptr_conv.is_owned = false;
28907         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28908         LDKSignature val_ref;
28909         CHECK((*env)->GetArrayLength(env, val) == 64);
28910         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28911         ChannelAnnouncement_set_node_signature_2(&this_ptr_conv, val_ref);
28912 }
28913
28914 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr) {
28915         LDKChannelAnnouncement this_ptr_conv;
28916         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28917         this_ptr_conv.is_owned = false;
28918         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28919         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28920         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_1(&this_ptr_conv).compact_form);
28921         return ret_arr;
28922 }
28923
28924 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_11(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28925         LDKChannelAnnouncement this_ptr_conv;
28926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28927         this_ptr_conv.is_owned = false;
28928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28929         LDKSignature val_ref;
28930         CHECK((*env)->GetArrayLength(env, val) == 64);
28931         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28932         ChannelAnnouncement_set_bitcoin_signature_1(&this_ptr_conv, val_ref);
28933 }
28934
28935 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr) {
28936         LDKChannelAnnouncement this_ptr_conv;
28937         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28938         this_ptr_conv.is_owned = false;
28939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28940         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
28941         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelAnnouncement_get_bitcoin_signature_2(&this_ptr_conv).compact_form);
28942         return ret_arr;
28943 }
28944
28945 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1bitcoin_1signature_12(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
28946         LDKChannelAnnouncement this_ptr_conv;
28947         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28948         this_ptr_conv.is_owned = false;
28949         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28950         LDKSignature val_ref;
28951         CHECK((*env)->GetArrayLength(env, val) == 64);
28952         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
28953         ChannelAnnouncement_set_bitcoin_signature_2(&this_ptr_conv, val_ref);
28954 }
28955
28956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
28957         LDKChannelAnnouncement this_ptr_conv;
28958         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28959         this_ptr_conv.is_owned = false;
28960         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28961         LDKUnsignedChannelAnnouncement ret_var = ChannelAnnouncement_get_contents(&this_ptr_conv);
28962         uint64_t ret_ref = 0;
28963         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
28964         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
28965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
28966         ret_ref = (uint64_t)ret_var.inner;
28967         if (ret_var.is_owned) {
28968                 ret_ref |= 1;
28969         }
28970         return ret_ref;
28971 }
28972
28973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
28974         LDKChannelAnnouncement this_ptr_conv;
28975         this_ptr_conv.inner = (void*)(this_ptr & (~1));
28976         this_ptr_conv.is_owned = false;
28977         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
28978         LDKUnsignedChannelAnnouncement val_conv;
28979         val_conv.inner = (void*)(val & (~1));
28980         val_conv.is_owned = (val & 1) || (val == 0);
28981         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
28982         val_conv = UnsignedChannelAnnouncement_clone(&val_conv);
28983         ChannelAnnouncement_set_contents(&this_ptr_conv, val_conv);
28984 }
28985
28986 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) {
28987         LDKSignature node_signature_1_arg_ref;
28988         CHECK((*env)->GetArrayLength(env, node_signature_1_arg) == 64);
28989         (*env)->GetByteArrayRegion(env, node_signature_1_arg, 0, 64, node_signature_1_arg_ref.compact_form);
28990         LDKSignature node_signature_2_arg_ref;
28991         CHECK((*env)->GetArrayLength(env, node_signature_2_arg) == 64);
28992         (*env)->GetByteArrayRegion(env, node_signature_2_arg, 0, 64, node_signature_2_arg_ref.compact_form);
28993         LDKSignature bitcoin_signature_1_arg_ref;
28994         CHECK((*env)->GetArrayLength(env, bitcoin_signature_1_arg) == 64);
28995         (*env)->GetByteArrayRegion(env, bitcoin_signature_1_arg, 0, 64, bitcoin_signature_1_arg_ref.compact_form);
28996         LDKSignature bitcoin_signature_2_arg_ref;
28997         CHECK((*env)->GetArrayLength(env, bitcoin_signature_2_arg) == 64);
28998         (*env)->GetByteArrayRegion(env, bitcoin_signature_2_arg, 0, 64, bitcoin_signature_2_arg_ref.compact_form);
28999         LDKUnsignedChannelAnnouncement contents_arg_conv;
29000         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29001         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29002         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29003         contents_arg_conv = UnsignedChannelAnnouncement_clone(&contents_arg_conv);
29004         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);
29005         uint64_t ret_ref = 0;
29006         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29007         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29008         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29009         ret_ref = (uint64_t)ret_var.inner;
29010         if (ret_var.is_owned) {
29011                 ret_ref |= 1;
29012         }
29013         return ret_ref;
29014 }
29015
29016 static inline uint64_t ChannelAnnouncement_clone_ptr(LDKChannelAnnouncement *NONNULL_PTR arg) {
29017         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(arg);
29018 uint64_t ret_ref = 0;
29019 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29020 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29021 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29022 ret_ref = (uint64_t)ret_var.inner;
29023 if (ret_var.is_owned) {
29024         ret_ref |= 1;
29025 }
29026         return ret_ref;
29027 }
29028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29029         LDKChannelAnnouncement arg_conv;
29030         arg_conv.inner = (void*)(arg & (~1));
29031         arg_conv.is_owned = false;
29032         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29033         int64_t ret_val = ChannelAnnouncement_clone_ptr(&arg_conv);
29034         return ret_val;
29035 }
29036
29037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29038         LDKChannelAnnouncement orig_conv;
29039         orig_conv.inner = (void*)(orig & (~1));
29040         orig_conv.is_owned = false;
29041         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29042         LDKChannelAnnouncement ret_var = ChannelAnnouncement_clone(&orig_conv);
29043         uint64_t ret_ref = 0;
29044         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29045         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29046         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29047         ret_ref = (uint64_t)ret_var.inner;
29048         if (ret_var.is_owned) {
29049                 ret_ref |= 1;
29050         }
29051         return ret_ref;
29052 }
29053
29054 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29055         LDKUnsignedChannelUpdate this_obj_conv;
29056         this_obj_conv.inner = (void*)(this_obj & (~1));
29057         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29058         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29059         UnsignedChannelUpdate_free(this_obj_conv);
29060 }
29061
29062 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29063         LDKUnsignedChannelUpdate this_ptr_conv;
29064         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29065         this_ptr_conv.is_owned = false;
29066         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29067         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29068         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *UnsignedChannelUpdate_get_chain_hash(&this_ptr_conv));
29069         return ret_arr;
29070 }
29071
29072 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29073         LDKUnsignedChannelUpdate this_ptr_conv;
29074         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29075         this_ptr_conv.is_owned = false;
29076         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29077         LDKThirtyTwoBytes val_ref;
29078         CHECK((*env)->GetArrayLength(env, val) == 32);
29079         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29080         UnsignedChannelUpdate_set_chain_hash(&this_ptr_conv, val_ref);
29081 }
29082
29083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
29084         LDKUnsignedChannelUpdate this_ptr_conv;
29085         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29086         this_ptr_conv.is_owned = false;
29087         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29088         int64_t ret_val = UnsignedChannelUpdate_get_short_channel_id(&this_ptr_conv);
29089         return ret_val;
29090 }
29091
29092 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29093         LDKUnsignedChannelUpdate this_ptr_conv;
29094         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29095         this_ptr_conv.is_owned = false;
29096         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29097         UnsignedChannelUpdate_set_short_channel_id(&this_ptr_conv, val);
29098 }
29099
29100 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
29101         LDKUnsignedChannelUpdate this_ptr_conv;
29102         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29103         this_ptr_conv.is_owned = false;
29104         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29105         int32_t ret_val = UnsignedChannelUpdate_get_timestamp(&this_ptr_conv);
29106         return ret_val;
29107 }
29108
29109 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29110         LDKUnsignedChannelUpdate this_ptr_conv;
29111         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29112         this_ptr_conv.is_owned = false;
29113         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29114         UnsignedChannelUpdate_set_timestamp(&this_ptr_conv, val);
29115 }
29116
29117 JNIEXPORT int8_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1flags(JNIEnv *env, jclass clz, int64_t this_ptr) {
29118         LDKUnsignedChannelUpdate this_ptr_conv;
29119         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29120         this_ptr_conv.is_owned = false;
29121         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29122         int8_t ret_val = UnsignedChannelUpdate_get_flags(&this_ptr_conv);
29123         return ret_val;
29124 }
29125
29126 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1flags(JNIEnv *env, jclass clz, int64_t this_ptr, int8_t val) {
29127         LDKUnsignedChannelUpdate this_ptr_conv;
29128         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29129         this_ptr_conv.is_owned = false;
29130         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29131         UnsignedChannelUpdate_set_flags(&this_ptr_conv, val);
29132 }
29133
29134 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
29135         LDKUnsignedChannelUpdate this_ptr_conv;
29136         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29137         this_ptr_conv.is_owned = false;
29138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29139         int16_t ret_val = UnsignedChannelUpdate_get_cltv_expiry_delta(&this_ptr_conv);
29140         return ret_val;
29141 }
29142
29143 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
29144         LDKUnsignedChannelUpdate this_ptr_conv;
29145         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29146         this_ptr_conv.is_owned = false;
29147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29148         UnsignedChannelUpdate_set_cltv_expiry_delta(&this_ptr_conv, val);
29149 }
29150
29151 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29152         LDKUnsignedChannelUpdate this_ptr_conv;
29153         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29154         this_ptr_conv.is_owned = false;
29155         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29156         int64_t ret_val = UnsignedChannelUpdate_get_htlc_minimum_msat(&this_ptr_conv);
29157         return ret_val;
29158 }
29159
29160 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29161         LDKUnsignedChannelUpdate this_ptr_conv;
29162         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29163         this_ptr_conv.is_owned = false;
29164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29165         UnsignedChannelUpdate_set_htlc_minimum_msat(&this_ptr_conv, val);
29166 }
29167
29168 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
29169         LDKUnsignedChannelUpdate this_ptr_conv;
29170         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29171         this_ptr_conv.is_owned = false;
29172         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29173         int32_t ret_val = UnsignedChannelUpdate_get_fee_base_msat(&this_ptr_conv);
29174         return ret_val;
29175 }
29176
29177 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29178         LDKUnsignedChannelUpdate this_ptr_conv;
29179         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29180         this_ptr_conv.is_owned = false;
29181         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29182         UnsignedChannelUpdate_set_fee_base_msat(&this_ptr_conv, val);
29183 }
29184
29185 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1get_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
29186         LDKUnsignedChannelUpdate this_ptr_conv;
29187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29188         this_ptr_conv.is_owned = false;
29189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29190         int32_t ret_val = UnsignedChannelUpdate_get_fee_proportional_millionths(&this_ptr_conv);
29191         return ret_val;
29192 }
29193
29194 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1set_1fee_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29195         LDKUnsignedChannelUpdate this_ptr_conv;
29196         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29197         this_ptr_conv.is_owned = false;
29198         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29199         UnsignedChannelUpdate_set_fee_proportional_millionths(&this_ptr_conv, val);
29200 }
29201
29202 static inline uint64_t UnsignedChannelUpdate_clone_ptr(LDKUnsignedChannelUpdate *NONNULL_PTR arg) {
29203         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(arg);
29204 uint64_t ret_ref = 0;
29205 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29206 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29207 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29208 ret_ref = (uint64_t)ret_var.inner;
29209 if (ret_var.is_owned) {
29210         ret_ref |= 1;
29211 }
29212         return ret_ref;
29213 }
29214 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29215         LDKUnsignedChannelUpdate arg_conv;
29216         arg_conv.inner = (void*)(arg & (~1));
29217         arg_conv.is_owned = false;
29218         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29219         int64_t ret_val = UnsignedChannelUpdate_clone_ptr(&arg_conv);
29220         return ret_val;
29221 }
29222
29223 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29224         LDKUnsignedChannelUpdate orig_conv;
29225         orig_conv.inner = (void*)(orig & (~1));
29226         orig_conv.is_owned = false;
29227         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29228         LDKUnsignedChannelUpdate ret_var = UnsignedChannelUpdate_clone(&orig_conv);
29229         uint64_t ret_ref = 0;
29230         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29231         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29232         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29233         ret_ref = (uint64_t)ret_var.inner;
29234         if (ret_var.is_owned) {
29235                 ret_ref |= 1;
29236         }
29237         return ret_ref;
29238 }
29239
29240 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29241         LDKChannelUpdate this_obj_conv;
29242         this_obj_conv.inner = (void*)(this_obj & (~1));
29243         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29244         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29245         ChannelUpdate_free(this_obj_conv);
29246 }
29247
29248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1signature(JNIEnv *env, jclass clz, int64_t this_ptr) {
29249         LDKChannelUpdate this_ptr_conv;
29250         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29251         this_ptr_conv.is_owned = false;
29252         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29253         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
29254         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, ChannelUpdate_get_signature(&this_ptr_conv).compact_form);
29255         return ret_arr;
29256 }
29257
29258 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1signature(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29259         LDKChannelUpdate this_ptr_conv;
29260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29261         this_ptr_conv.is_owned = false;
29262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29263         LDKSignature val_ref;
29264         CHECK((*env)->GetArrayLength(env, val) == 64);
29265         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
29266         ChannelUpdate_set_signature(&this_ptr_conv, val_ref);
29267 }
29268
29269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1get_1contents(JNIEnv *env, jclass clz, int64_t this_ptr) {
29270         LDKChannelUpdate this_ptr_conv;
29271         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29272         this_ptr_conv.is_owned = false;
29273         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29274         LDKUnsignedChannelUpdate ret_var = ChannelUpdate_get_contents(&this_ptr_conv);
29275         uint64_t ret_ref = 0;
29276         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29277         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29278         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29279         ret_ref = (uint64_t)ret_var.inner;
29280         if (ret_var.is_owned) {
29281                 ret_ref |= 1;
29282         }
29283         return ret_ref;
29284 }
29285
29286 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1set_1contents(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
29287         LDKChannelUpdate this_ptr_conv;
29288         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29289         this_ptr_conv.is_owned = false;
29290         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29291         LDKUnsignedChannelUpdate val_conv;
29292         val_conv.inner = (void*)(val & (~1));
29293         val_conv.is_owned = (val & 1) || (val == 0);
29294         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
29295         val_conv = UnsignedChannelUpdate_clone(&val_conv);
29296         ChannelUpdate_set_contents(&this_ptr_conv, val_conv);
29297 }
29298
29299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1new(JNIEnv *env, jclass clz, int8_tArray signature_arg, int64_t contents_arg) {
29300         LDKSignature signature_arg_ref;
29301         CHECK((*env)->GetArrayLength(env, signature_arg) == 64);
29302         (*env)->GetByteArrayRegion(env, signature_arg, 0, 64, signature_arg_ref.compact_form);
29303         LDKUnsignedChannelUpdate contents_arg_conv;
29304         contents_arg_conv.inner = (void*)(contents_arg & (~1));
29305         contents_arg_conv.is_owned = (contents_arg & 1) || (contents_arg == 0);
29306         CHECK_INNER_FIELD_ACCESS_OR_NULL(contents_arg_conv);
29307         contents_arg_conv = UnsignedChannelUpdate_clone(&contents_arg_conv);
29308         LDKChannelUpdate ret_var = ChannelUpdate_new(signature_arg_ref, contents_arg_conv);
29309         uint64_t ret_ref = 0;
29310         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29311         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29312         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29313         ret_ref = (uint64_t)ret_var.inner;
29314         if (ret_var.is_owned) {
29315                 ret_ref |= 1;
29316         }
29317         return ret_ref;
29318 }
29319
29320 static inline uint64_t ChannelUpdate_clone_ptr(LDKChannelUpdate *NONNULL_PTR arg) {
29321         LDKChannelUpdate ret_var = ChannelUpdate_clone(arg);
29322 uint64_t ret_ref = 0;
29323 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29324 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29325 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29326 ret_ref = (uint64_t)ret_var.inner;
29327 if (ret_var.is_owned) {
29328         ret_ref |= 1;
29329 }
29330         return ret_ref;
29331 }
29332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29333         LDKChannelUpdate arg_conv;
29334         arg_conv.inner = (void*)(arg & (~1));
29335         arg_conv.is_owned = false;
29336         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29337         int64_t ret_val = ChannelUpdate_clone_ptr(&arg_conv);
29338         return ret_val;
29339 }
29340
29341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29342         LDKChannelUpdate orig_conv;
29343         orig_conv.inner = (void*)(orig & (~1));
29344         orig_conv.is_owned = false;
29345         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29346         LDKChannelUpdate ret_var = ChannelUpdate_clone(&orig_conv);
29347         uint64_t ret_ref = 0;
29348         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29349         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29350         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29351         ret_ref = (uint64_t)ret_var.inner;
29352         if (ret_var.is_owned) {
29353                 ret_ref |= 1;
29354         }
29355         return ret_ref;
29356 }
29357
29358 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29359         LDKQueryChannelRange this_obj_conv;
29360         this_obj_conv.inner = (void*)(this_obj & (~1));
29361         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29362         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29363         QueryChannelRange_free(this_obj_conv);
29364 }
29365
29366 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29367         LDKQueryChannelRange this_ptr_conv;
29368         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29369         this_ptr_conv.is_owned = false;
29370         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29371         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29372         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryChannelRange_get_chain_hash(&this_ptr_conv));
29373         return ret_arr;
29374 }
29375
29376 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29377         LDKQueryChannelRange this_ptr_conv;
29378         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29379         this_ptr_conv.is_owned = false;
29380         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29381         LDKThirtyTwoBytes val_ref;
29382         CHECK((*env)->GetArrayLength(env, val) == 32);
29383         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29384         QueryChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
29385 }
29386
29387 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
29388         LDKQueryChannelRange this_ptr_conv;
29389         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29390         this_ptr_conv.is_owned = false;
29391         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29392         int32_t ret_val = QueryChannelRange_get_first_blocknum(&this_ptr_conv);
29393         return ret_val;
29394 }
29395
29396 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29397         LDKQueryChannelRange this_ptr_conv;
29398         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29399         this_ptr_conv.is_owned = false;
29400         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29401         QueryChannelRange_set_first_blocknum(&this_ptr_conv, val);
29402 }
29403
29404 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
29405         LDKQueryChannelRange this_ptr_conv;
29406         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29407         this_ptr_conv.is_owned = false;
29408         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29409         int32_t ret_val = QueryChannelRange_get_number_of_blocks(&this_ptr_conv);
29410         return ret_val;
29411 }
29412
29413 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29414         LDKQueryChannelRange this_ptr_conv;
29415         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29416         this_ptr_conv.is_owned = false;
29417         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29418         QueryChannelRange_set_number_of_blocks(&this_ptr_conv, val);
29419 }
29420
29421 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) {
29422         LDKThirtyTwoBytes chain_hash_arg_ref;
29423         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29424         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29425         LDKQueryChannelRange ret_var = QueryChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg);
29426         uint64_t ret_ref = 0;
29427         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29428         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29430         ret_ref = (uint64_t)ret_var.inner;
29431         if (ret_var.is_owned) {
29432                 ret_ref |= 1;
29433         }
29434         return ret_ref;
29435 }
29436
29437 static inline uint64_t QueryChannelRange_clone_ptr(LDKQueryChannelRange *NONNULL_PTR arg) {
29438         LDKQueryChannelRange ret_var = QueryChannelRange_clone(arg);
29439 uint64_t ret_ref = 0;
29440 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29441 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29442 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29443 ret_ref = (uint64_t)ret_var.inner;
29444 if (ret_var.is_owned) {
29445         ret_ref |= 1;
29446 }
29447         return ret_ref;
29448 }
29449 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29450         LDKQueryChannelRange arg_conv;
29451         arg_conv.inner = (void*)(arg & (~1));
29452         arg_conv.is_owned = false;
29453         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29454         int64_t ret_val = QueryChannelRange_clone_ptr(&arg_conv);
29455         return ret_val;
29456 }
29457
29458 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29459         LDKQueryChannelRange orig_conv;
29460         orig_conv.inner = (void*)(orig & (~1));
29461         orig_conv.is_owned = false;
29462         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29463         LDKQueryChannelRange ret_var = QueryChannelRange_clone(&orig_conv);
29464         uint64_t ret_ref = 0;
29465         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29466         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29467         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29468         ret_ref = (uint64_t)ret_var.inner;
29469         if (ret_var.is_owned) {
29470                 ret_ref |= 1;
29471         }
29472         return ret_ref;
29473 }
29474
29475 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29476         LDKReplyChannelRange this_obj_conv;
29477         this_obj_conv.inner = (void*)(this_obj & (~1));
29478         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29480         ReplyChannelRange_free(this_obj_conv);
29481 }
29482
29483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29484         LDKReplyChannelRange this_ptr_conv;
29485         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29486         this_ptr_conv.is_owned = false;
29487         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29488         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29489         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyChannelRange_get_chain_hash(&this_ptr_conv));
29490         return ret_arr;
29491 }
29492
29493 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29494         LDKReplyChannelRange this_ptr_conv;
29495         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29496         this_ptr_conv.is_owned = false;
29497         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29498         LDKThirtyTwoBytes val_ref;
29499         CHECK((*env)->GetArrayLength(env, val) == 32);
29500         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29501         ReplyChannelRange_set_chain_hash(&this_ptr_conv, val_ref);
29502 }
29503
29504 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr) {
29505         LDKReplyChannelRange this_ptr_conv;
29506         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29507         this_ptr_conv.is_owned = false;
29508         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29509         int32_t ret_val = ReplyChannelRange_get_first_blocknum(&this_ptr_conv);
29510         return ret_val;
29511 }
29512
29513 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1first_1blocknum(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29514         LDKReplyChannelRange this_ptr_conv;
29515         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29516         this_ptr_conv.is_owned = false;
29517         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29518         ReplyChannelRange_set_first_blocknum(&this_ptr_conv, val);
29519 }
29520
29521 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr) {
29522         LDKReplyChannelRange this_ptr_conv;
29523         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29524         this_ptr_conv.is_owned = false;
29525         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29526         int32_t ret_val = ReplyChannelRange_get_number_of_blocks(&this_ptr_conv);
29527         return ret_val;
29528 }
29529
29530 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1number_1of_1blocks(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29531         LDKReplyChannelRange this_ptr_conv;
29532         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29533         this_ptr_conv.is_owned = false;
29534         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29535         ReplyChannelRange_set_number_of_blocks(&this_ptr_conv, val);
29536 }
29537
29538 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1get_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr) {
29539         LDKReplyChannelRange this_ptr_conv;
29540         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29541         this_ptr_conv.is_owned = false;
29542         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29543         jboolean ret_val = ReplyChannelRange_get_sync_complete(&this_ptr_conv);
29544         return ret_val;
29545 }
29546
29547 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1sync_1complete(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29548         LDKReplyChannelRange this_ptr_conv;
29549         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29550         this_ptr_conv.is_owned = false;
29551         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29552         ReplyChannelRange_set_sync_complete(&this_ptr_conv, val);
29553 }
29554
29555 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29556         LDKReplyChannelRange this_ptr_conv;
29557         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29558         this_ptr_conv.is_owned = false;
29559         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29560         LDKCVec_u64Z val_constr;
29561         val_constr.datalen = (*env)->GetArrayLength(env, val);
29562         if (val_constr.datalen > 0)
29563                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29564         else
29565                 val_constr.data = NULL;
29566         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29567         for (size_t g = 0; g < val_constr.datalen; g++) {
29568                 int64_t val_conv_6 = val_vals[g];
29569                 val_constr.data[g] = val_conv_6;
29570         }
29571         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29572         ReplyChannelRange_set_short_channel_ids(&this_ptr_conv, val_constr);
29573 }
29574
29575 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) {
29576         LDKThirtyTwoBytes chain_hash_arg_ref;
29577         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29578         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29579         LDKCVec_u64Z short_channel_ids_arg_constr;
29580         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
29581         if (short_channel_ids_arg_constr.datalen > 0)
29582                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29583         else
29584                 short_channel_ids_arg_constr.data = NULL;
29585         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
29586         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
29587                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
29588                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
29589         }
29590         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
29591         LDKReplyChannelRange ret_var = ReplyChannelRange_new(chain_hash_arg_ref, first_blocknum_arg, number_of_blocks_arg, sync_complete_arg, short_channel_ids_arg_constr);
29592         uint64_t ret_ref = 0;
29593         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29594         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29595         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29596         ret_ref = (uint64_t)ret_var.inner;
29597         if (ret_var.is_owned) {
29598                 ret_ref |= 1;
29599         }
29600         return ret_ref;
29601 }
29602
29603 static inline uint64_t ReplyChannelRange_clone_ptr(LDKReplyChannelRange *NONNULL_PTR arg) {
29604         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(arg);
29605 uint64_t ret_ref = 0;
29606 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29607 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29608 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29609 ret_ref = (uint64_t)ret_var.inner;
29610 if (ret_var.is_owned) {
29611         ret_ref |= 1;
29612 }
29613         return ret_ref;
29614 }
29615 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29616         LDKReplyChannelRange arg_conv;
29617         arg_conv.inner = (void*)(arg & (~1));
29618         arg_conv.is_owned = false;
29619         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29620         int64_t ret_val = ReplyChannelRange_clone_ptr(&arg_conv);
29621         return ret_val;
29622 }
29623
29624 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29625         LDKReplyChannelRange orig_conv;
29626         orig_conv.inner = (void*)(orig & (~1));
29627         orig_conv.is_owned = false;
29628         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29629         LDKReplyChannelRange ret_var = ReplyChannelRange_clone(&orig_conv);
29630         uint64_t ret_ref = 0;
29631         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29632         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29633         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29634         ret_ref = (uint64_t)ret_var.inner;
29635         if (ret_var.is_owned) {
29636                 ret_ref |= 1;
29637         }
29638         return ret_ref;
29639 }
29640
29641 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29642         LDKQueryShortChannelIds this_obj_conv;
29643         this_obj_conv.inner = (void*)(this_obj & (~1));
29644         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29645         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29646         QueryShortChannelIds_free(this_obj_conv);
29647 }
29648
29649 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29650         LDKQueryShortChannelIds this_ptr_conv;
29651         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29652         this_ptr_conv.is_owned = false;
29653         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29654         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29655         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *QueryShortChannelIds_get_chain_hash(&this_ptr_conv));
29656         return ret_arr;
29657 }
29658
29659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29660         LDKQueryShortChannelIds this_ptr_conv;
29661         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29662         this_ptr_conv.is_owned = false;
29663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29664         LDKThirtyTwoBytes val_ref;
29665         CHECK((*env)->GetArrayLength(env, val) == 32);
29666         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29667         QueryShortChannelIds_set_chain_hash(&this_ptr_conv, val_ref);
29668 }
29669
29670 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1set_1short_1channel_1ids(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
29671         LDKQueryShortChannelIds this_ptr_conv;
29672         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29673         this_ptr_conv.is_owned = false;
29674         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29675         LDKCVec_u64Z val_constr;
29676         val_constr.datalen = (*env)->GetArrayLength(env, val);
29677         if (val_constr.datalen > 0)
29678                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29679         else
29680                 val_constr.data = NULL;
29681         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
29682         for (size_t g = 0; g < val_constr.datalen; g++) {
29683                 int64_t val_conv_6 = val_vals[g];
29684                 val_constr.data[g] = val_conv_6;
29685         }
29686         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
29687         QueryShortChannelIds_set_short_channel_ids(&this_ptr_conv, val_constr);
29688 }
29689
29690 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) {
29691         LDKThirtyTwoBytes chain_hash_arg_ref;
29692         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29693         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29694         LDKCVec_u64Z short_channel_ids_arg_constr;
29695         short_channel_ids_arg_constr.datalen = (*env)->GetArrayLength(env, short_channel_ids_arg);
29696         if (short_channel_ids_arg_constr.datalen > 0)
29697                 short_channel_ids_arg_constr.data = MALLOC(short_channel_ids_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
29698         else
29699                 short_channel_ids_arg_constr.data = NULL;
29700         int64_t* short_channel_ids_arg_vals = (*env)->GetLongArrayElements (env, short_channel_ids_arg, NULL);
29701         for (size_t g = 0; g < short_channel_ids_arg_constr.datalen; g++) {
29702                 int64_t short_channel_ids_arg_conv_6 = short_channel_ids_arg_vals[g];
29703                 short_channel_ids_arg_constr.data[g] = short_channel_ids_arg_conv_6;
29704         }
29705         (*env)->ReleaseLongArrayElements(env, short_channel_ids_arg, short_channel_ids_arg_vals, 0);
29706         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_new(chain_hash_arg_ref, short_channel_ids_arg_constr);
29707         uint64_t ret_ref = 0;
29708         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29709         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29710         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29711         ret_ref = (uint64_t)ret_var.inner;
29712         if (ret_var.is_owned) {
29713                 ret_ref |= 1;
29714         }
29715         return ret_ref;
29716 }
29717
29718 static inline uint64_t QueryShortChannelIds_clone_ptr(LDKQueryShortChannelIds *NONNULL_PTR arg) {
29719         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(arg);
29720 uint64_t ret_ref = 0;
29721 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29722 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29723 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29724 ret_ref = (uint64_t)ret_var.inner;
29725 if (ret_var.is_owned) {
29726         ret_ref |= 1;
29727 }
29728         return ret_ref;
29729 }
29730 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29731         LDKQueryShortChannelIds arg_conv;
29732         arg_conv.inner = (void*)(arg & (~1));
29733         arg_conv.is_owned = false;
29734         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29735         int64_t ret_val = QueryShortChannelIds_clone_ptr(&arg_conv);
29736         return ret_val;
29737 }
29738
29739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29740         LDKQueryShortChannelIds orig_conv;
29741         orig_conv.inner = (void*)(orig & (~1));
29742         orig_conv.is_owned = false;
29743         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29744         LDKQueryShortChannelIds ret_var = QueryShortChannelIds_clone(&orig_conv);
29745         uint64_t ret_ref = 0;
29746         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29747         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29748         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29749         ret_ref = (uint64_t)ret_var.inner;
29750         if (ret_var.is_owned) {
29751                 ret_ref |= 1;
29752         }
29753         return ret_ref;
29754 }
29755
29756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29757         LDKReplyShortChannelIdsEnd this_obj_conv;
29758         this_obj_conv.inner = (void*)(this_obj & (~1));
29759         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29761         ReplyShortChannelIdsEnd_free(this_obj_conv);
29762 }
29763
29764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29765         LDKReplyShortChannelIdsEnd this_ptr_conv;
29766         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29767         this_ptr_conv.is_owned = false;
29768         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29769         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29770         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *ReplyShortChannelIdsEnd_get_chain_hash(&this_ptr_conv));
29771         return ret_arr;
29772 }
29773
29774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29775         LDKReplyShortChannelIdsEnd this_ptr_conv;
29776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29777         this_ptr_conv.is_owned = false;
29778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29779         LDKThirtyTwoBytes val_ref;
29780         CHECK((*env)->GetArrayLength(env, val) == 32);
29781         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29782         ReplyShortChannelIdsEnd_set_chain_hash(&this_ptr_conv, val_ref);
29783 }
29784
29785 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1get_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr) {
29786         LDKReplyShortChannelIdsEnd this_ptr_conv;
29787         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29788         this_ptr_conv.is_owned = false;
29789         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29790         jboolean ret_val = ReplyShortChannelIdsEnd_get_full_information(&this_ptr_conv);
29791         return ret_val;
29792 }
29793
29794 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1set_1full_1information(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
29795         LDKReplyShortChannelIdsEnd this_ptr_conv;
29796         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29797         this_ptr_conv.is_owned = false;
29798         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29799         ReplyShortChannelIdsEnd_set_full_information(&this_ptr_conv, val);
29800 }
29801
29802 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1new(JNIEnv *env, jclass clz, int8_tArray chain_hash_arg, jboolean full_information_arg) {
29803         LDKThirtyTwoBytes chain_hash_arg_ref;
29804         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29805         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29806         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_new(chain_hash_arg_ref, full_information_arg);
29807         uint64_t ret_ref = 0;
29808         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29809         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29810         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29811         ret_ref = (uint64_t)ret_var.inner;
29812         if (ret_var.is_owned) {
29813                 ret_ref |= 1;
29814         }
29815         return ret_ref;
29816 }
29817
29818 static inline uint64_t ReplyShortChannelIdsEnd_clone_ptr(LDKReplyShortChannelIdsEnd *NONNULL_PTR arg) {
29819         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(arg);
29820 uint64_t ret_ref = 0;
29821 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29822 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29823 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29824 ret_ref = (uint64_t)ret_var.inner;
29825 if (ret_var.is_owned) {
29826         ret_ref |= 1;
29827 }
29828         return ret_ref;
29829 }
29830 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29831         LDKReplyShortChannelIdsEnd arg_conv;
29832         arg_conv.inner = (void*)(arg & (~1));
29833         arg_conv.is_owned = false;
29834         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29835         int64_t ret_val = ReplyShortChannelIdsEnd_clone_ptr(&arg_conv);
29836         return ret_val;
29837 }
29838
29839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29840         LDKReplyShortChannelIdsEnd orig_conv;
29841         orig_conv.inner = (void*)(orig & (~1));
29842         orig_conv.is_owned = false;
29843         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29844         LDKReplyShortChannelIdsEnd ret_var = ReplyShortChannelIdsEnd_clone(&orig_conv);
29845         uint64_t ret_ref = 0;
29846         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29847         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29848         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29849         ret_ref = (uint64_t)ret_var.inner;
29850         if (ret_var.is_owned) {
29851                 ret_ref |= 1;
29852         }
29853         return ret_ref;
29854 }
29855
29856 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
29857         LDKGossipTimestampFilter this_obj_conv;
29858         this_obj_conv.inner = (void*)(this_obj & (~1));
29859         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
29860         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
29861         GossipTimestampFilter_free(this_obj_conv);
29862 }
29863
29864 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
29865         LDKGossipTimestampFilter this_ptr_conv;
29866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29867         this_ptr_conv.is_owned = false;
29868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29869         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
29870         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *GossipTimestampFilter_get_chain_hash(&this_ptr_conv));
29871         return ret_arr;
29872 }
29873
29874 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1chain_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
29875         LDKGossipTimestampFilter this_ptr_conv;
29876         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29877         this_ptr_conv.is_owned = false;
29878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29879         LDKThirtyTwoBytes val_ref;
29880         CHECK((*env)->GetArrayLength(env, val) == 32);
29881         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
29882         GossipTimestampFilter_set_chain_hash(&this_ptr_conv, val_ref);
29883 }
29884
29885 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
29886         LDKGossipTimestampFilter this_ptr_conv;
29887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29888         this_ptr_conv.is_owned = false;
29889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29890         int32_t ret_val = GossipTimestampFilter_get_first_timestamp(&this_ptr_conv);
29891         return ret_val;
29892 }
29893
29894 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1first_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29895         LDKGossipTimestampFilter this_ptr_conv;
29896         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29897         this_ptr_conv.is_owned = false;
29898         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29899         GossipTimestampFilter_set_first_timestamp(&this_ptr_conv, val);
29900 }
29901
29902 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1get_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr) {
29903         LDKGossipTimestampFilter this_ptr_conv;
29904         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29905         this_ptr_conv.is_owned = false;
29906         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29907         int32_t ret_val = GossipTimestampFilter_get_timestamp_range(&this_ptr_conv);
29908         return ret_val;
29909 }
29910
29911 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1set_1timestamp_1range(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
29912         LDKGossipTimestampFilter this_ptr_conv;
29913         this_ptr_conv.inner = (void*)(this_ptr & (~1));
29914         this_ptr_conv.is_owned = false;
29915         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
29916         GossipTimestampFilter_set_timestamp_range(&this_ptr_conv, val);
29917 }
29918
29919 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) {
29920         LDKThirtyTwoBytes chain_hash_arg_ref;
29921         CHECK((*env)->GetArrayLength(env, chain_hash_arg) == 32);
29922         (*env)->GetByteArrayRegion(env, chain_hash_arg, 0, 32, chain_hash_arg_ref.data);
29923         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_new(chain_hash_arg_ref, first_timestamp_arg, timestamp_range_arg);
29924         uint64_t ret_ref = 0;
29925         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29926         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29927         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29928         ret_ref = (uint64_t)ret_var.inner;
29929         if (ret_var.is_owned) {
29930                 ret_ref |= 1;
29931         }
29932         return ret_ref;
29933 }
29934
29935 static inline uint64_t GossipTimestampFilter_clone_ptr(LDKGossipTimestampFilter *NONNULL_PTR arg) {
29936         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(arg);
29937 uint64_t ret_ref = 0;
29938 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29939 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29940 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29941 ret_ref = (uint64_t)ret_var.inner;
29942 if (ret_var.is_owned) {
29943         ret_ref |= 1;
29944 }
29945         return ret_ref;
29946 }
29947 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29948         LDKGossipTimestampFilter arg_conv;
29949         arg_conv.inner = (void*)(arg & (~1));
29950         arg_conv.is_owned = false;
29951         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
29952         int64_t ret_val = GossipTimestampFilter_clone_ptr(&arg_conv);
29953         return ret_val;
29954 }
29955
29956 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29957         LDKGossipTimestampFilter orig_conv;
29958         orig_conv.inner = (void*)(orig & (~1));
29959         orig_conv.is_owned = false;
29960         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
29961         LDKGossipTimestampFilter ret_var = GossipTimestampFilter_clone(&orig_conv);
29962         uint64_t ret_ref = 0;
29963         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
29964         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
29965         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
29966         ret_ref = (uint64_t)ret_var.inner;
29967         if (ret_var.is_owned) {
29968                 ret_ref |= 1;
29969         }
29970         return ret_ref;
29971 }
29972
29973 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErrorAction_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
29974         if ((this_ptr & 1) != 0) return;
29975         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
29976         CHECK_ACCESS(this_ptr_ptr);
29977         LDKErrorAction this_ptr_conv = *(LDKErrorAction*)(this_ptr_ptr);
29978         FREE((void*)this_ptr);
29979         ErrorAction_free(this_ptr_conv);
29980 }
29981
29982 static inline uint64_t ErrorAction_clone_ptr(LDKErrorAction *NONNULL_PTR arg) {
29983         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
29984         *ret_copy = ErrorAction_clone(arg);
29985 uint64_t ret_ref = (uint64_t)ret_copy;
29986         return ret_ref;
29987 }
29988 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
29989         LDKErrorAction* arg_conv = (LDKErrorAction*)arg;
29990         int64_t ret_val = ErrorAction_clone_ptr(arg_conv);
29991         return ret_val;
29992 }
29993
29994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
29995         LDKErrorAction* orig_conv = (LDKErrorAction*)orig;
29996         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
29997         *ret_copy = ErrorAction_clone(orig_conv);
29998         uint64_t ret_ref = (uint64_t)ret_copy;
29999         return ret_ref;
30000 }
30001
30002 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1disconnect_1peer(JNIEnv *env, jclass clz, int64_t msg) {
30003         LDKErrorMessage msg_conv;
30004         msg_conv.inner = (void*)(msg & (~1));
30005         msg_conv.is_owned = (msg & 1) || (msg == 0);
30006         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30007         msg_conv = ErrorMessage_clone(&msg_conv);
30008         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30009         *ret_copy = ErrorAction_disconnect_peer(msg_conv);
30010         uint64_t ret_ref = (uint64_t)ret_copy;
30011         return ret_ref;
30012 }
30013
30014 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1error(JNIEnv *env, jclass clz) {
30015         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30016         *ret_copy = ErrorAction_ignore_error();
30017         uint64_t ret_ref = (uint64_t)ret_copy;
30018         return ret_ref;
30019 }
30020
30021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1ignore_1and_1log(JNIEnv *env, jclass clz, jclass a) {
30022         LDKLevel a_conv = LDKLevel_from_java(env, a);
30023         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30024         *ret_copy = ErrorAction_ignore_and_log(a_conv);
30025         uint64_t ret_ref = (uint64_t)ret_copy;
30026         return ret_ref;
30027 }
30028
30029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorAction_1send_1error_1message(JNIEnv *env, jclass clz, int64_t msg) {
30030         LDKErrorMessage msg_conv;
30031         msg_conv.inner = (void*)(msg & (~1));
30032         msg_conv.is_owned = (msg & 1) || (msg == 0);
30033         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
30034         msg_conv = ErrorMessage_clone(&msg_conv);
30035         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30036         *ret_copy = ErrorAction_send_error_message(msg_conv);
30037         uint64_t ret_ref = (uint64_t)ret_copy;
30038         return ret_ref;
30039 }
30040
30041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30042         LDKLightningError this_obj_conv;
30043         this_obj_conv.inner = (void*)(this_obj & (~1));
30044         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30046         LightningError_free(this_obj_conv);
30047 }
30048
30049 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1err(JNIEnv *env, jclass clz, int64_t this_ptr) {
30050         LDKLightningError this_ptr_conv;
30051         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30052         this_ptr_conv.is_owned = false;
30053         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30054         LDKStr ret_str = LightningError_get_err(&this_ptr_conv);
30055         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
30056         Str_free(ret_str);
30057         return ret_conv;
30058 }
30059
30060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1err(JNIEnv *env, jclass clz, int64_t this_ptr, jstring val) {
30061         LDKLightningError this_ptr_conv;
30062         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30063         this_ptr_conv.is_owned = false;
30064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30065         LDKStr val_conv = java_to_owned_str(env, val);
30066         LightningError_set_err(&this_ptr_conv, val_conv);
30067 }
30068
30069 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1get_1action(JNIEnv *env, jclass clz, int64_t this_ptr) {
30070         LDKLightningError this_ptr_conv;
30071         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30072         this_ptr_conv.is_owned = false;
30073         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30074         LDKErrorAction *ret_copy = MALLOC(sizeof(LDKErrorAction), "LDKErrorAction");
30075         *ret_copy = LightningError_get_action(&this_ptr_conv);
30076         uint64_t ret_ref = (uint64_t)ret_copy;
30077         return ret_ref;
30078 }
30079
30080 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LightningError_1set_1action(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30081         LDKLightningError this_ptr_conv;
30082         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30083         this_ptr_conv.is_owned = false;
30084         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30085         void* val_ptr = (void*)(((uint64_t)val) & ~1);
30086         CHECK_ACCESS(val_ptr);
30087         LDKErrorAction val_conv = *(LDKErrorAction*)(val_ptr);
30088         val_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)val) & ~1));
30089         LightningError_set_action(&this_ptr_conv, val_conv);
30090 }
30091
30092 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1new(JNIEnv *env, jclass clz, jstring err_arg, int64_t action_arg) {
30093         LDKStr err_arg_conv = java_to_owned_str(env, err_arg);
30094         void* action_arg_ptr = (void*)(((uint64_t)action_arg) & ~1);
30095         CHECK_ACCESS(action_arg_ptr);
30096         LDKErrorAction action_arg_conv = *(LDKErrorAction*)(action_arg_ptr);
30097         action_arg_conv = ErrorAction_clone((LDKErrorAction*)(((uint64_t)action_arg) & ~1));
30098         LDKLightningError ret_var = LightningError_new(err_arg_conv, action_arg_conv);
30099         uint64_t ret_ref = 0;
30100         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30101         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30102         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30103         ret_ref = (uint64_t)ret_var.inner;
30104         if (ret_var.is_owned) {
30105                 ret_ref |= 1;
30106         }
30107         return ret_ref;
30108 }
30109
30110 static inline uint64_t LightningError_clone_ptr(LDKLightningError *NONNULL_PTR arg) {
30111         LDKLightningError ret_var = LightningError_clone(arg);
30112 uint64_t ret_ref = 0;
30113 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30114 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30115 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30116 ret_ref = (uint64_t)ret_var.inner;
30117 if (ret_var.is_owned) {
30118         ret_ref |= 1;
30119 }
30120         return ret_ref;
30121 }
30122 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30123         LDKLightningError arg_conv;
30124         arg_conv.inner = (void*)(arg & (~1));
30125         arg_conv.is_owned = false;
30126         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30127         int64_t ret_val = LightningError_clone_ptr(&arg_conv);
30128         return ret_val;
30129 }
30130
30131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LightningError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30132         LDKLightningError orig_conv;
30133         orig_conv.inner = (void*)(orig & (~1));
30134         orig_conv.is_owned = false;
30135         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30136         LDKLightningError ret_var = LightningError_clone(&orig_conv);
30137         uint64_t ret_ref = 0;
30138         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30139         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30140         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30141         ret_ref = (uint64_t)ret_var.inner;
30142         if (ret_var.is_owned) {
30143                 ret_ref |= 1;
30144         }
30145         return ret_ref;
30146 }
30147
30148 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
30149         LDKCommitmentUpdate this_obj_conv;
30150         this_obj_conv.inner = (void*)(this_obj & (~1));
30151         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
30152         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
30153         CommitmentUpdate_free(this_obj_conv);
30154 }
30155
30156 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30157         LDKCommitmentUpdate this_ptr_conv;
30158         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30159         this_ptr_conv.is_owned = false;
30160         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30161         LDKCVec_UpdateAddHTLCZ ret_var = CommitmentUpdate_get_update_add_htlcs(&this_ptr_conv);
30162         int64_tArray ret_arr = NULL;
30163         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30164         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30165         for (size_t p = 0; p < ret_var.datalen; p++) {
30166                 LDKUpdateAddHTLC ret_conv_15_var = ret_var.data[p];
30167                 uint64_t ret_conv_15_ref = 0;
30168                 CHECK((((uint64_t)ret_conv_15_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30169                 CHECK((((uint64_t)&ret_conv_15_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30170                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_15_var);
30171                 ret_conv_15_ref = (uint64_t)ret_conv_15_var.inner;
30172                 if (ret_conv_15_var.is_owned) {
30173                         ret_conv_15_ref |= 1;
30174                 }
30175                 ret_arr_ptr[p] = ret_conv_15_ref;
30176         }
30177         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30178         FREE(ret_var.data);
30179         return ret_arr;
30180 }
30181
30182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1add_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30183         LDKCommitmentUpdate this_ptr_conv;
30184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30185         this_ptr_conv.is_owned = false;
30186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30187         LDKCVec_UpdateAddHTLCZ val_constr;
30188         val_constr.datalen = (*env)->GetArrayLength(env, val);
30189         if (val_constr.datalen > 0)
30190                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30191         else
30192                 val_constr.data = NULL;
30193         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30194         for (size_t p = 0; p < val_constr.datalen; p++) {
30195                 int64_t val_conv_15 = val_vals[p];
30196                 LDKUpdateAddHTLC val_conv_15_conv;
30197                 val_conv_15_conv.inner = (void*)(val_conv_15 & (~1));
30198                 val_conv_15_conv.is_owned = (val_conv_15 & 1) || (val_conv_15 == 0);
30199                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_15_conv);
30200                 val_conv_15_conv = UpdateAddHTLC_clone(&val_conv_15_conv);
30201                 val_constr.data[p] = val_conv_15_conv;
30202         }
30203         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30204         CommitmentUpdate_set_update_add_htlcs(&this_ptr_conv, val_constr);
30205 }
30206
30207 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30208         LDKCommitmentUpdate this_ptr_conv;
30209         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30210         this_ptr_conv.is_owned = false;
30211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30212         LDKCVec_UpdateFulfillHTLCZ ret_var = CommitmentUpdate_get_update_fulfill_htlcs(&this_ptr_conv);
30213         int64_tArray ret_arr = NULL;
30214         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30215         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30216         for (size_t t = 0; t < ret_var.datalen; t++) {
30217                 LDKUpdateFulfillHTLC ret_conv_19_var = ret_var.data[t];
30218                 uint64_t ret_conv_19_ref = 0;
30219                 CHECK((((uint64_t)ret_conv_19_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30220                 CHECK((((uint64_t)&ret_conv_19_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30221                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_19_var);
30222                 ret_conv_19_ref = (uint64_t)ret_conv_19_var.inner;
30223                 if (ret_conv_19_var.is_owned) {
30224                         ret_conv_19_ref |= 1;
30225                 }
30226                 ret_arr_ptr[t] = ret_conv_19_ref;
30227         }
30228         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30229         FREE(ret_var.data);
30230         return ret_arr;
30231 }
30232
30233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fulfill_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30234         LDKCommitmentUpdate this_ptr_conv;
30235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30236         this_ptr_conv.is_owned = false;
30237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30238         LDKCVec_UpdateFulfillHTLCZ val_constr;
30239         val_constr.datalen = (*env)->GetArrayLength(env, val);
30240         if (val_constr.datalen > 0)
30241                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30242         else
30243                 val_constr.data = NULL;
30244         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30245         for (size_t t = 0; t < val_constr.datalen; t++) {
30246                 int64_t val_conv_19 = val_vals[t];
30247                 LDKUpdateFulfillHTLC val_conv_19_conv;
30248                 val_conv_19_conv.inner = (void*)(val_conv_19 & (~1));
30249                 val_conv_19_conv.is_owned = (val_conv_19 & 1) || (val_conv_19 == 0);
30250                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_19_conv);
30251                 val_conv_19_conv = UpdateFulfillHTLC_clone(&val_conv_19_conv);
30252                 val_constr.data[t] = val_conv_19_conv;
30253         }
30254         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30255         CommitmentUpdate_set_update_fulfill_htlcs(&this_ptr_conv, val_constr);
30256 }
30257
30258 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30259         LDKCommitmentUpdate this_ptr_conv;
30260         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30261         this_ptr_conv.is_owned = false;
30262         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30263         LDKCVec_UpdateFailHTLCZ ret_var = CommitmentUpdate_get_update_fail_htlcs(&this_ptr_conv);
30264         int64_tArray ret_arr = NULL;
30265         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30266         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30267         for (size_t q = 0; q < ret_var.datalen; q++) {
30268                 LDKUpdateFailHTLC ret_conv_16_var = ret_var.data[q];
30269                 uint64_t ret_conv_16_ref = 0;
30270                 CHECK((((uint64_t)ret_conv_16_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30271                 CHECK((((uint64_t)&ret_conv_16_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30272                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_16_var);
30273                 ret_conv_16_ref = (uint64_t)ret_conv_16_var.inner;
30274                 if (ret_conv_16_var.is_owned) {
30275                         ret_conv_16_ref |= 1;
30276                 }
30277                 ret_arr_ptr[q] = ret_conv_16_ref;
30278         }
30279         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30280         FREE(ret_var.data);
30281         return ret_arr;
30282 }
30283
30284 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fail_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
30285         LDKCommitmentUpdate this_ptr_conv;
30286         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30287         this_ptr_conv.is_owned = false;
30288         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30289         LDKCVec_UpdateFailHTLCZ val_constr;
30290         val_constr.datalen = (*env)->GetArrayLength(env, val);
30291         if (val_constr.datalen > 0)
30292                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30293         else
30294                 val_constr.data = NULL;
30295         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30296         for (size_t q = 0; q < val_constr.datalen; q++) {
30297                 int64_t val_conv_16 = val_vals[q];
30298                 LDKUpdateFailHTLC val_conv_16_conv;
30299                 val_conv_16_conv.inner = (void*)(val_conv_16 & (~1));
30300                 val_conv_16_conv.is_owned = (val_conv_16 & 1) || (val_conv_16 == 0);
30301                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_16_conv);
30302                 val_conv_16_conv = UpdateFailHTLC_clone(&val_conv_16_conv);
30303                 val_constr.data[q] = val_conv_16_conv;
30304         }
30305         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30306         CommitmentUpdate_set_update_fail_htlcs(&this_ptr_conv, val_constr);
30307 }
30308
30309 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fail_1malformed_1htlcs(JNIEnv *env, jclass clz, int64_t this_ptr) {
30310         LDKCommitmentUpdate this_ptr_conv;
30311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30312         this_ptr_conv.is_owned = false;
30313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30314         LDKCVec_UpdateFailMalformedHTLCZ ret_var = CommitmentUpdate_get_update_fail_malformed_htlcs(&this_ptr_conv);
30315         int64_tArray ret_arr = NULL;
30316         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
30317         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
30318         for (size_t z = 0; z < ret_var.datalen; z++) {
30319                 LDKUpdateFailMalformedHTLC ret_conv_25_var = ret_var.data[z];
30320                 uint64_t ret_conv_25_ref = 0;
30321                 CHECK((((uint64_t)ret_conv_25_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30322                 CHECK((((uint64_t)&ret_conv_25_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30323                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_25_var);
30324                 ret_conv_25_ref = (uint64_t)ret_conv_25_var.inner;
30325                 if (ret_conv_25_var.is_owned) {
30326                         ret_conv_25_ref |= 1;
30327                 }
30328                 ret_arr_ptr[z] = ret_conv_25_ref;
30329         }
30330         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
30331         FREE(ret_var.data);
30332         return ret_arr;
30333 }
30334
30335 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) {
30336         LDKCommitmentUpdate this_ptr_conv;
30337         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30338         this_ptr_conv.is_owned = false;
30339         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30340         LDKCVec_UpdateFailMalformedHTLCZ val_constr;
30341         val_constr.datalen = (*env)->GetArrayLength(env, val);
30342         if (val_constr.datalen > 0)
30343                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30344         else
30345                 val_constr.data = NULL;
30346         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
30347         for (size_t z = 0; z < val_constr.datalen; z++) {
30348                 int64_t val_conv_25 = val_vals[z];
30349                 LDKUpdateFailMalformedHTLC val_conv_25_conv;
30350                 val_conv_25_conv.inner = (void*)(val_conv_25 & (~1));
30351                 val_conv_25_conv.is_owned = (val_conv_25 & 1) || (val_conv_25 == 0);
30352                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_25_conv);
30353                 val_conv_25_conv = UpdateFailMalformedHTLC_clone(&val_conv_25_conv);
30354                 val_constr.data[z] = val_conv_25_conv;
30355         }
30356         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
30357         CommitmentUpdate_set_update_fail_malformed_htlcs(&this_ptr_conv, val_constr);
30358 }
30359
30360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr) {
30361         LDKCommitmentUpdate this_ptr_conv;
30362         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30363         this_ptr_conv.is_owned = false;
30364         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30365         LDKUpdateFee ret_var = CommitmentUpdate_get_update_fee(&this_ptr_conv);
30366         uint64_t ret_ref = 0;
30367         if ((uint64_t)ret_var.inner > 4096) {
30368                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30369                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30370         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30371                 ret_ref = (uint64_t)ret_var.inner;
30372                 if (ret_var.is_owned) {
30373                         ret_ref |= 1;
30374                 }
30375         }
30376         return ret_ref;
30377 }
30378
30379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1update_1fee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30380         LDKCommitmentUpdate this_ptr_conv;
30381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30382         this_ptr_conv.is_owned = false;
30383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30384         LDKUpdateFee val_conv;
30385         val_conv.inner = (void*)(val & (~1));
30386         val_conv.is_owned = (val & 1) || (val == 0);
30387         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30388         val_conv = UpdateFee_clone(&val_conv);
30389         CommitmentUpdate_set_update_fee(&this_ptr_conv, val_conv);
30390 }
30391
30392 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1get_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr) {
30393         LDKCommitmentUpdate this_ptr_conv;
30394         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30395         this_ptr_conv.is_owned = false;
30396         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30397         LDKCommitmentSigned ret_var = CommitmentUpdate_get_commitment_signed(&this_ptr_conv);
30398         uint64_t ret_ref = 0;
30399         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30400         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30401         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30402         ret_ref = (uint64_t)ret_var.inner;
30403         if (ret_var.is_owned) {
30404                 ret_ref |= 1;
30405         }
30406         return ret_ref;
30407 }
30408
30409 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1set_1commitment_1signed(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
30410         LDKCommitmentUpdate this_ptr_conv;
30411         this_ptr_conv.inner = (void*)(this_ptr & (~1));
30412         this_ptr_conv.is_owned = false;
30413         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
30414         LDKCommitmentSigned val_conv;
30415         val_conv.inner = (void*)(val & (~1));
30416         val_conv.is_owned = (val & 1) || (val == 0);
30417         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
30418         val_conv = CommitmentSigned_clone(&val_conv);
30419         CommitmentUpdate_set_commitment_signed(&this_ptr_conv, val_conv);
30420 }
30421
30422 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) {
30423         LDKCVec_UpdateAddHTLCZ update_add_htlcs_arg_constr;
30424         update_add_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_add_htlcs_arg);
30425         if (update_add_htlcs_arg_constr.datalen > 0)
30426                 update_add_htlcs_arg_constr.data = MALLOC(update_add_htlcs_arg_constr.datalen * sizeof(LDKUpdateAddHTLC), "LDKCVec_UpdateAddHTLCZ Elements");
30427         else
30428                 update_add_htlcs_arg_constr.data = NULL;
30429         int64_t* update_add_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_add_htlcs_arg, NULL);
30430         for (size_t p = 0; p < update_add_htlcs_arg_constr.datalen; p++) {
30431                 int64_t update_add_htlcs_arg_conv_15 = update_add_htlcs_arg_vals[p];
30432                 LDKUpdateAddHTLC update_add_htlcs_arg_conv_15_conv;
30433                 update_add_htlcs_arg_conv_15_conv.inner = (void*)(update_add_htlcs_arg_conv_15 & (~1));
30434                 update_add_htlcs_arg_conv_15_conv.is_owned = (update_add_htlcs_arg_conv_15 & 1) || (update_add_htlcs_arg_conv_15 == 0);
30435                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_add_htlcs_arg_conv_15_conv);
30436                 update_add_htlcs_arg_conv_15_conv = UpdateAddHTLC_clone(&update_add_htlcs_arg_conv_15_conv);
30437                 update_add_htlcs_arg_constr.data[p] = update_add_htlcs_arg_conv_15_conv;
30438         }
30439         (*env)->ReleaseLongArrayElements(env, update_add_htlcs_arg, update_add_htlcs_arg_vals, 0);
30440         LDKCVec_UpdateFulfillHTLCZ update_fulfill_htlcs_arg_constr;
30441         update_fulfill_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fulfill_htlcs_arg);
30442         if (update_fulfill_htlcs_arg_constr.datalen > 0)
30443                 update_fulfill_htlcs_arg_constr.data = MALLOC(update_fulfill_htlcs_arg_constr.datalen * sizeof(LDKUpdateFulfillHTLC), "LDKCVec_UpdateFulfillHTLCZ Elements");
30444         else
30445                 update_fulfill_htlcs_arg_constr.data = NULL;
30446         int64_t* update_fulfill_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fulfill_htlcs_arg, NULL);
30447         for (size_t t = 0; t < update_fulfill_htlcs_arg_constr.datalen; t++) {
30448                 int64_t update_fulfill_htlcs_arg_conv_19 = update_fulfill_htlcs_arg_vals[t];
30449                 LDKUpdateFulfillHTLC update_fulfill_htlcs_arg_conv_19_conv;
30450                 update_fulfill_htlcs_arg_conv_19_conv.inner = (void*)(update_fulfill_htlcs_arg_conv_19 & (~1));
30451                 update_fulfill_htlcs_arg_conv_19_conv.is_owned = (update_fulfill_htlcs_arg_conv_19 & 1) || (update_fulfill_htlcs_arg_conv_19 == 0);
30452                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fulfill_htlcs_arg_conv_19_conv);
30453                 update_fulfill_htlcs_arg_conv_19_conv = UpdateFulfillHTLC_clone(&update_fulfill_htlcs_arg_conv_19_conv);
30454                 update_fulfill_htlcs_arg_constr.data[t] = update_fulfill_htlcs_arg_conv_19_conv;
30455         }
30456         (*env)->ReleaseLongArrayElements(env, update_fulfill_htlcs_arg, update_fulfill_htlcs_arg_vals, 0);
30457         LDKCVec_UpdateFailHTLCZ update_fail_htlcs_arg_constr;
30458         update_fail_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_htlcs_arg);
30459         if (update_fail_htlcs_arg_constr.datalen > 0)
30460                 update_fail_htlcs_arg_constr.data = MALLOC(update_fail_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailHTLC), "LDKCVec_UpdateFailHTLCZ Elements");
30461         else
30462                 update_fail_htlcs_arg_constr.data = NULL;
30463         int64_t* update_fail_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_htlcs_arg, NULL);
30464         for (size_t q = 0; q < update_fail_htlcs_arg_constr.datalen; q++) {
30465                 int64_t update_fail_htlcs_arg_conv_16 = update_fail_htlcs_arg_vals[q];
30466                 LDKUpdateFailHTLC update_fail_htlcs_arg_conv_16_conv;
30467                 update_fail_htlcs_arg_conv_16_conv.inner = (void*)(update_fail_htlcs_arg_conv_16 & (~1));
30468                 update_fail_htlcs_arg_conv_16_conv.is_owned = (update_fail_htlcs_arg_conv_16 & 1) || (update_fail_htlcs_arg_conv_16 == 0);
30469                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_htlcs_arg_conv_16_conv);
30470                 update_fail_htlcs_arg_conv_16_conv = UpdateFailHTLC_clone(&update_fail_htlcs_arg_conv_16_conv);
30471                 update_fail_htlcs_arg_constr.data[q] = update_fail_htlcs_arg_conv_16_conv;
30472         }
30473         (*env)->ReleaseLongArrayElements(env, update_fail_htlcs_arg, update_fail_htlcs_arg_vals, 0);
30474         LDKCVec_UpdateFailMalformedHTLCZ update_fail_malformed_htlcs_arg_constr;
30475         update_fail_malformed_htlcs_arg_constr.datalen = (*env)->GetArrayLength(env, update_fail_malformed_htlcs_arg);
30476         if (update_fail_malformed_htlcs_arg_constr.datalen > 0)
30477                 update_fail_malformed_htlcs_arg_constr.data = MALLOC(update_fail_malformed_htlcs_arg_constr.datalen * sizeof(LDKUpdateFailMalformedHTLC), "LDKCVec_UpdateFailMalformedHTLCZ Elements");
30478         else
30479                 update_fail_malformed_htlcs_arg_constr.data = NULL;
30480         int64_t* update_fail_malformed_htlcs_arg_vals = (*env)->GetLongArrayElements (env, update_fail_malformed_htlcs_arg, NULL);
30481         for (size_t z = 0; z < update_fail_malformed_htlcs_arg_constr.datalen; z++) {
30482                 int64_t update_fail_malformed_htlcs_arg_conv_25 = update_fail_malformed_htlcs_arg_vals[z];
30483                 LDKUpdateFailMalformedHTLC update_fail_malformed_htlcs_arg_conv_25_conv;
30484                 update_fail_malformed_htlcs_arg_conv_25_conv.inner = (void*)(update_fail_malformed_htlcs_arg_conv_25 & (~1));
30485                 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);
30486                 CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fail_malformed_htlcs_arg_conv_25_conv);
30487                 update_fail_malformed_htlcs_arg_conv_25_conv = UpdateFailMalformedHTLC_clone(&update_fail_malformed_htlcs_arg_conv_25_conv);
30488                 update_fail_malformed_htlcs_arg_constr.data[z] = update_fail_malformed_htlcs_arg_conv_25_conv;
30489         }
30490         (*env)->ReleaseLongArrayElements(env, update_fail_malformed_htlcs_arg, update_fail_malformed_htlcs_arg_vals, 0);
30491         LDKUpdateFee update_fee_arg_conv;
30492         update_fee_arg_conv.inner = (void*)(update_fee_arg & (~1));
30493         update_fee_arg_conv.is_owned = (update_fee_arg & 1) || (update_fee_arg == 0);
30494         CHECK_INNER_FIELD_ACCESS_OR_NULL(update_fee_arg_conv);
30495         update_fee_arg_conv = UpdateFee_clone(&update_fee_arg_conv);
30496         LDKCommitmentSigned commitment_signed_arg_conv;
30497         commitment_signed_arg_conv.inner = (void*)(commitment_signed_arg & (~1));
30498         commitment_signed_arg_conv.is_owned = (commitment_signed_arg & 1) || (commitment_signed_arg == 0);
30499         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_signed_arg_conv);
30500         commitment_signed_arg_conv = CommitmentSigned_clone(&commitment_signed_arg_conv);
30501         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);
30502         uint64_t ret_ref = 0;
30503         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30504         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30505         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30506         ret_ref = (uint64_t)ret_var.inner;
30507         if (ret_var.is_owned) {
30508                 ret_ref |= 1;
30509         }
30510         return ret_ref;
30511 }
30512
30513 static inline uint64_t CommitmentUpdate_clone_ptr(LDKCommitmentUpdate *NONNULL_PTR arg) {
30514         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(arg);
30515 uint64_t ret_ref = 0;
30516 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30517 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30518 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30519 ret_ref = (uint64_t)ret_var.inner;
30520 if (ret_var.is_owned) {
30521         ret_ref |= 1;
30522 }
30523         return ret_ref;
30524 }
30525 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
30526         LDKCommitmentUpdate arg_conv;
30527         arg_conv.inner = (void*)(arg & (~1));
30528         arg_conv.is_owned = false;
30529         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
30530         int64_t ret_val = CommitmentUpdate_clone_ptr(&arg_conv);
30531         return ret_val;
30532 }
30533
30534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
30535         LDKCommitmentUpdate orig_conv;
30536         orig_conv.inner = (void*)(orig & (~1));
30537         orig_conv.is_owned = false;
30538         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
30539         LDKCommitmentUpdate ret_var = CommitmentUpdate_clone(&orig_conv);
30540         uint64_t ret_ref = 0;
30541         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
30542         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
30543         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
30544         ret_ref = (uint64_t)ret_var.inner;
30545         if (ret_var.is_owned) {
30546                 ret_ref |= 1;
30547         }
30548         return ret_ref;
30549 }
30550
30551 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30552         if ((this_ptr & 1) != 0) return;
30553         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30554         CHECK_ACCESS(this_ptr_ptr);
30555         LDKChannelMessageHandler this_ptr_conv = *(LDKChannelMessageHandler*)(this_ptr_ptr);
30556         FREE((void*)this_ptr);
30557         ChannelMessageHandler_free(this_ptr_conv);
30558 }
30559
30560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
30561         if ((this_ptr & 1) != 0) return;
30562         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
30563         CHECK_ACCESS(this_ptr_ptr);
30564         LDKRoutingMessageHandler this_ptr_conv = *(LDKRoutingMessageHandler*)(this_ptr_ptr);
30565         FREE((void*)this_ptr);
30566         RoutingMessageHandler_free(this_ptr_conv);
30567 }
30568
30569 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
30570         LDKAcceptChannel obj_conv;
30571         obj_conv.inner = (void*)(obj & (~1));
30572         obj_conv.is_owned = false;
30573         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30574         LDKCVec_u8Z ret_var = AcceptChannel_write(&obj_conv);
30575         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30576         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30577         CVec_u8Z_free(ret_var);
30578         return ret_arr;
30579 }
30580
30581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AcceptChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30582         LDKu8slice ser_ref;
30583         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30584         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30585         LDKCResult_AcceptChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AcceptChannelDecodeErrorZ), "LDKCResult_AcceptChannelDecodeErrorZ");
30586         *ret_conv = AcceptChannel_read(ser_ref);
30587         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30588         return (uint64_t)ret_conv;
30589 }
30590
30591 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
30592         LDKAnnouncementSignatures obj_conv;
30593         obj_conv.inner = (void*)(obj & (~1));
30594         obj_conv.is_owned = false;
30595         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30596         LDKCVec_u8Z ret_var = AnnouncementSignatures_write(&obj_conv);
30597         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30598         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30599         CVec_u8Z_free(ret_var);
30600         return ret_arr;
30601 }
30602
30603 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_AnnouncementSignatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30604         LDKu8slice ser_ref;
30605         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30606         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30607         LDKCResult_AnnouncementSignaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_AnnouncementSignaturesDecodeErrorZ), "LDKCResult_AnnouncementSignaturesDecodeErrorZ");
30608         *ret_conv = AnnouncementSignatures_read(ser_ref);
30609         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30610         return (uint64_t)ret_conv;
30611 }
30612
30613 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1write(JNIEnv *env, jclass clz, int64_t obj) {
30614         LDKChannelReestablish obj_conv;
30615         obj_conv.inner = (void*)(obj & (~1));
30616         obj_conv.is_owned = false;
30617         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30618         LDKCVec_u8Z ret_var = ChannelReestablish_write(&obj_conv);
30619         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30620         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30621         CVec_u8Z_free(ret_var);
30622         return ret_arr;
30623 }
30624
30625 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelReestablish_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30626         LDKu8slice ser_ref;
30627         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30628         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30629         LDKCResult_ChannelReestablishDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelReestablishDecodeErrorZ), "LDKCResult_ChannelReestablishDecodeErrorZ");
30630         *ret_conv = ChannelReestablish_read(ser_ref);
30631         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30632         return (uint64_t)ret_conv;
30633 }
30634
30635 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
30636         LDKClosingSigned obj_conv;
30637         obj_conv.inner = (void*)(obj & (~1));
30638         obj_conv.is_owned = false;
30639         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30640         LDKCVec_u8Z ret_var = ClosingSigned_write(&obj_conv);
30641         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30642         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30643         CVec_u8Z_free(ret_var);
30644         return ret_arr;
30645 }
30646
30647 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30648         LDKu8slice ser_ref;
30649         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30650         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30651         LDKCResult_ClosingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedDecodeErrorZ), "LDKCResult_ClosingSignedDecodeErrorZ");
30652         *ret_conv = ClosingSigned_read(ser_ref);
30653         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30654         return (uint64_t)ret_conv;
30655 }
30656
30657 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
30658         LDKClosingSignedFeeRange obj_conv;
30659         obj_conv.inner = (void*)(obj & (~1));
30660         obj_conv.is_owned = false;
30661         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30662         LDKCVec_u8Z ret_var = ClosingSignedFeeRange_write(&obj_conv);
30663         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30664         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30665         CVec_u8Z_free(ret_var);
30666         return ret_arr;
30667 }
30668
30669 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingSignedFeeRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30670         LDKu8slice ser_ref;
30671         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30672         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30673         LDKCResult_ClosingSignedFeeRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ClosingSignedFeeRangeDecodeErrorZ), "LDKCResult_ClosingSignedFeeRangeDecodeErrorZ");
30674         *ret_conv = ClosingSignedFeeRange_read(ser_ref);
30675         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30676         return (uint64_t)ret_conv;
30677 }
30678
30679 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
30680         LDKCommitmentSigned obj_conv;
30681         obj_conv.inner = (void*)(obj & (~1));
30682         obj_conv.is_owned = false;
30683         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30684         LDKCVec_u8Z ret_var = CommitmentSigned_write(&obj_conv);
30685         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30686         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30687         CVec_u8Z_free(ret_var);
30688         return ret_arr;
30689 }
30690
30691 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30692         LDKu8slice ser_ref;
30693         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30694         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30695         LDKCResult_CommitmentSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentSignedDecodeErrorZ), "LDKCResult_CommitmentSignedDecodeErrorZ");
30696         *ret_conv = CommitmentSigned_read(ser_ref);
30697         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30698         return (uint64_t)ret_conv;
30699 }
30700
30701 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingCreated_1write(JNIEnv *env, jclass clz, int64_t obj) {
30702         LDKFundingCreated obj_conv;
30703         obj_conv.inner = (void*)(obj & (~1));
30704         obj_conv.is_owned = false;
30705         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30706         LDKCVec_u8Z ret_var = FundingCreated_write(&obj_conv);
30707         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30708         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30709         CVec_u8Z_free(ret_var);
30710         return ret_arr;
30711 }
30712
30713 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingCreated_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30714         LDKu8slice ser_ref;
30715         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30716         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30717         LDKCResult_FundingCreatedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingCreatedDecodeErrorZ), "LDKCResult_FundingCreatedDecodeErrorZ");
30718         *ret_conv = FundingCreated_read(ser_ref);
30719         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30720         return (uint64_t)ret_conv;
30721 }
30722
30723 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingSigned_1write(JNIEnv *env, jclass clz, int64_t obj) {
30724         LDKFundingSigned obj_conv;
30725         obj_conv.inner = (void*)(obj & (~1));
30726         obj_conv.is_owned = false;
30727         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30728         LDKCVec_u8Z ret_var = FundingSigned_write(&obj_conv);
30729         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30730         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30731         CVec_u8Z_free(ret_var);
30732         return ret_arr;
30733 }
30734
30735 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingSigned_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30736         LDKu8slice ser_ref;
30737         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30738         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30739         LDKCResult_FundingSignedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingSignedDecodeErrorZ), "LDKCResult_FundingSignedDecodeErrorZ");
30740         *ret_conv = FundingSigned_read(ser_ref);
30741         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30742         return (uint64_t)ret_conv;
30743 }
30744
30745 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_FundingLocked_1write(JNIEnv *env, jclass clz, int64_t obj) {
30746         LDKFundingLocked obj_conv;
30747         obj_conv.inner = (void*)(obj & (~1));
30748         obj_conv.is_owned = false;
30749         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30750         LDKCVec_u8Z ret_var = FundingLocked_write(&obj_conv);
30751         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30752         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30753         CVec_u8Z_free(ret_var);
30754         return ret_arr;
30755 }
30756
30757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FundingLocked_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30758         LDKu8slice ser_ref;
30759         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30760         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30761         LDKCResult_FundingLockedDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_FundingLockedDecodeErrorZ), "LDKCResult_FundingLockedDecodeErrorZ");
30762         *ret_conv = FundingLocked_read(ser_ref);
30763         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30764         return (uint64_t)ret_conv;
30765 }
30766
30767 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Init_1write(JNIEnv *env, jclass clz, int64_t obj) {
30768         LDKInit obj_conv;
30769         obj_conv.inner = (void*)(obj & (~1));
30770         obj_conv.is_owned = false;
30771         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30772         LDKCVec_u8Z ret_var = Init_write(&obj_conv);
30773         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30774         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30775         CVec_u8Z_free(ret_var);
30776         return ret_arr;
30777 }
30778
30779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Init_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30780         LDKu8slice ser_ref;
30781         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30782         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30783         LDKCResult_InitDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitDecodeErrorZ), "LDKCResult_InitDecodeErrorZ");
30784         *ret_conv = Init_read(ser_ref);
30785         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30786         return (uint64_t)ret_conv;
30787 }
30788
30789 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_OpenChannel_1write(JNIEnv *env, jclass clz, int64_t obj) {
30790         LDKOpenChannel obj_conv;
30791         obj_conv.inner = (void*)(obj & (~1));
30792         obj_conv.is_owned = false;
30793         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30794         LDKCVec_u8Z ret_var = OpenChannel_write(&obj_conv);
30795         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30796         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30797         CVec_u8Z_free(ret_var);
30798         return ret_arr;
30799 }
30800
30801 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_OpenChannel_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30802         LDKu8slice ser_ref;
30803         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30804         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30805         LDKCResult_OpenChannelDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_OpenChannelDecodeErrorZ), "LDKCResult_OpenChannelDecodeErrorZ");
30806         *ret_conv = OpenChannel_read(ser_ref);
30807         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30808         return (uint64_t)ret_conv;
30809 }
30810
30811 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1write(JNIEnv *env, jclass clz, int64_t obj) {
30812         LDKRevokeAndACK obj_conv;
30813         obj_conv.inner = (void*)(obj & (~1));
30814         obj_conv.is_owned = false;
30815         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30816         LDKCVec_u8Z ret_var = RevokeAndACK_write(&obj_conv);
30817         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30818         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30819         CVec_u8Z_free(ret_var);
30820         return ret_arr;
30821 }
30822
30823 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RevokeAndACK_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30824         LDKu8slice ser_ref;
30825         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30826         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30827         LDKCResult_RevokeAndACKDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RevokeAndACKDecodeErrorZ), "LDKCResult_RevokeAndACKDecodeErrorZ");
30828         *ret_conv = RevokeAndACK_read(ser_ref);
30829         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30830         return (uint64_t)ret_conv;
30831 }
30832
30833 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Shutdown_1write(JNIEnv *env, jclass clz, int64_t obj) {
30834         LDKShutdown obj_conv;
30835         obj_conv.inner = (void*)(obj & (~1));
30836         obj_conv.is_owned = false;
30837         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30838         LDKCVec_u8Z ret_var = Shutdown_write(&obj_conv);
30839         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30840         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30841         CVec_u8Z_free(ret_var);
30842         return ret_arr;
30843 }
30844
30845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Shutdown_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30846         LDKu8slice ser_ref;
30847         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30848         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30849         LDKCResult_ShutdownDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownDecodeErrorZ), "LDKCResult_ShutdownDecodeErrorZ");
30850         *ret_conv = Shutdown_read(ser_ref);
30851         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30852         return (uint64_t)ret_conv;
30853 }
30854
30855 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
30856         LDKUpdateFailHTLC obj_conv;
30857         obj_conv.inner = (void*)(obj & (~1));
30858         obj_conv.is_owned = false;
30859         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30860         LDKCVec_u8Z ret_var = UpdateFailHTLC_write(&obj_conv);
30861         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30862         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30863         CVec_u8Z_free(ret_var);
30864         return ret_arr;
30865 }
30866
30867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30868         LDKu8slice ser_ref;
30869         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30870         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30871         LDKCResult_UpdateFailHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailHTLCDecodeErrorZ), "LDKCResult_UpdateFailHTLCDecodeErrorZ");
30872         *ret_conv = UpdateFailHTLC_read(ser_ref);
30873         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30874         return (uint64_t)ret_conv;
30875 }
30876
30877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
30878         LDKUpdateFailMalformedHTLC obj_conv;
30879         obj_conv.inner = (void*)(obj & (~1));
30880         obj_conv.is_owned = false;
30881         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30882         LDKCVec_u8Z ret_var = UpdateFailMalformedHTLC_write(&obj_conv);
30883         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30884         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30885         CVec_u8Z_free(ret_var);
30886         return ret_arr;
30887 }
30888
30889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFailMalformedHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30890         LDKu8slice ser_ref;
30891         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30892         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30893         LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ), "LDKCResult_UpdateFailMalformedHTLCDecodeErrorZ");
30894         *ret_conv = UpdateFailMalformedHTLC_read(ser_ref);
30895         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30896         return (uint64_t)ret_conv;
30897 }
30898
30899 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFee_1write(JNIEnv *env, jclass clz, int64_t obj) {
30900         LDKUpdateFee obj_conv;
30901         obj_conv.inner = (void*)(obj & (~1));
30902         obj_conv.is_owned = false;
30903         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30904         LDKCVec_u8Z ret_var = UpdateFee_write(&obj_conv);
30905         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30906         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30907         CVec_u8Z_free(ret_var);
30908         return ret_arr;
30909 }
30910
30911 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30912         LDKu8slice ser_ref;
30913         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30914         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30915         LDKCResult_UpdateFeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFeeDecodeErrorZ), "LDKCResult_UpdateFeeDecodeErrorZ");
30916         *ret_conv = UpdateFee_read(ser_ref);
30917         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30918         return (uint64_t)ret_conv;
30919 }
30920
30921 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
30922         LDKUpdateFulfillHTLC obj_conv;
30923         obj_conv.inner = (void*)(obj & (~1));
30924         obj_conv.is_owned = false;
30925         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30926         LDKCVec_u8Z ret_var = UpdateFulfillHTLC_write(&obj_conv);
30927         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30928         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30929         CVec_u8Z_free(ret_var);
30930         return ret_arr;
30931 }
30932
30933 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateFulfillHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30934         LDKu8slice ser_ref;
30935         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30936         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30937         LDKCResult_UpdateFulfillHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateFulfillHTLCDecodeErrorZ), "LDKCResult_UpdateFulfillHTLCDecodeErrorZ");
30938         *ret_conv = UpdateFulfillHTLC_read(ser_ref);
30939         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30940         return (uint64_t)ret_conv;
30941 }
30942
30943 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1write(JNIEnv *env, jclass clz, int64_t obj) {
30944         LDKUpdateAddHTLC obj_conv;
30945         obj_conv.inner = (void*)(obj & (~1));
30946         obj_conv.is_owned = false;
30947         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30948         LDKCVec_u8Z ret_var = UpdateAddHTLC_write(&obj_conv);
30949         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30950         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30951         CVec_u8Z_free(ret_var);
30952         return ret_arr;
30953 }
30954
30955 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UpdateAddHTLC_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30956         LDKu8slice ser_ref;
30957         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30958         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30959         LDKCResult_UpdateAddHTLCDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UpdateAddHTLCDecodeErrorZ), "LDKCResult_UpdateAddHTLCDecodeErrorZ");
30960         *ret_conv = UpdateAddHTLC_read(ser_ref);
30961         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30962         return (uint64_t)ret_conv;
30963 }
30964
30965 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Ping_1write(JNIEnv *env, jclass clz, int64_t obj) {
30966         LDKPing obj_conv;
30967         obj_conv.inner = (void*)(obj & (~1));
30968         obj_conv.is_owned = false;
30969         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30970         LDKCVec_u8Z ret_var = Ping_write(&obj_conv);
30971         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30972         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30973         CVec_u8Z_free(ret_var);
30974         return ret_arr;
30975 }
30976
30977 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Ping_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
30978         LDKu8slice ser_ref;
30979         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
30980         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
30981         LDKCResult_PingDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PingDecodeErrorZ), "LDKCResult_PingDecodeErrorZ");
30982         *ret_conv = Ping_read(ser_ref);
30983         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
30984         return (uint64_t)ret_conv;
30985 }
30986
30987 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Pong_1write(JNIEnv *env, jclass clz, int64_t obj) {
30988         LDKPong obj_conv;
30989         obj_conv.inner = (void*)(obj & (~1));
30990         obj_conv.is_owned = false;
30991         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
30992         LDKCVec_u8Z ret_var = Pong_write(&obj_conv);
30993         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
30994         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
30995         CVec_u8Z_free(ret_var);
30996         return ret_arr;
30997 }
30998
30999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Pong_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31000         LDKu8slice ser_ref;
31001         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31002         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31003         LDKCResult_PongDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PongDecodeErrorZ), "LDKCResult_PongDecodeErrorZ");
31004         *ret_conv = Pong_read(ser_ref);
31005         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31006         return (uint64_t)ret_conv;
31007 }
31008
31009 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31010         LDKUnsignedChannelAnnouncement obj_conv;
31011         obj_conv.inner = (void*)(obj & (~1));
31012         obj_conv.is_owned = false;
31013         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31014         LDKCVec_u8Z ret_var = UnsignedChannelAnnouncement_write(&obj_conv);
31015         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31016         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31017         CVec_u8Z_free(ret_var);
31018         return ret_arr;
31019 }
31020
31021 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31022         LDKu8slice ser_ref;
31023         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31024         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31025         LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ), "LDKCResult_UnsignedChannelAnnouncementDecodeErrorZ");
31026         *ret_conv = UnsignedChannelAnnouncement_read(ser_ref);
31027         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31028         return (uint64_t)ret_conv;
31029 }
31030
31031 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31032         LDKChannelAnnouncement obj_conv;
31033         obj_conv.inner = (void*)(obj & (~1));
31034         obj_conv.is_owned = false;
31035         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31036         LDKCVec_u8Z ret_var = ChannelAnnouncement_write(&obj_conv);
31037         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31038         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31039         CVec_u8Z_free(ret_var);
31040         return ret_arr;
31041 }
31042
31043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31044         LDKu8slice ser_ref;
31045         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31046         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31047         LDKCResult_ChannelAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelAnnouncementDecodeErrorZ), "LDKCResult_ChannelAnnouncementDecodeErrorZ");
31048         *ret_conv = ChannelAnnouncement_read(ser_ref);
31049         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31050         return (uint64_t)ret_conv;
31051 }
31052
31053 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
31054         LDKUnsignedChannelUpdate obj_conv;
31055         obj_conv.inner = (void*)(obj & (~1));
31056         obj_conv.is_owned = false;
31057         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31058         LDKCVec_u8Z ret_var = UnsignedChannelUpdate_write(&obj_conv);
31059         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31060         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31061         CVec_u8Z_free(ret_var);
31062         return ret_arr;
31063 }
31064
31065 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31066         LDKu8slice ser_ref;
31067         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31068         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31069         LDKCResult_UnsignedChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedChannelUpdateDecodeErrorZ), "LDKCResult_UnsignedChannelUpdateDecodeErrorZ");
31070         *ret_conv = UnsignedChannelUpdate_read(ser_ref);
31071         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31072         return (uint64_t)ret_conv;
31073 }
31074
31075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
31076         LDKChannelUpdate obj_conv;
31077         obj_conv.inner = (void*)(obj & (~1));
31078         obj_conv.is_owned = false;
31079         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31080         LDKCVec_u8Z ret_var = ChannelUpdate_write(&obj_conv);
31081         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31082         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31083         CVec_u8Z_free(ret_var);
31084         return ret_arr;
31085 }
31086
31087 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31088         LDKu8slice ser_ref;
31089         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31090         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31091         LDKCResult_ChannelUpdateDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelUpdateDecodeErrorZ), "LDKCResult_ChannelUpdateDecodeErrorZ");
31092         *ret_conv = ChannelUpdate_read(ser_ref);
31093         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31094         return (uint64_t)ret_conv;
31095 }
31096
31097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1write(JNIEnv *env, jclass clz, int64_t obj) {
31098         LDKErrorMessage obj_conv;
31099         obj_conv.inner = (void*)(obj & (~1));
31100         obj_conv.is_owned = false;
31101         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31102         LDKCVec_u8Z ret_var = ErrorMessage_write(&obj_conv);
31103         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31104         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31105         CVec_u8Z_free(ret_var);
31106         return ret_arr;
31107 }
31108
31109 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErrorMessage_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31110         LDKu8slice ser_ref;
31111         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31112         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31113         LDKCResult_ErrorMessageDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ErrorMessageDecodeErrorZ), "LDKCResult_ErrorMessageDecodeErrorZ");
31114         *ret_conv = ErrorMessage_read(ser_ref);
31115         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31116         return (uint64_t)ret_conv;
31117 }
31118
31119 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31120         LDKUnsignedNodeAnnouncement obj_conv;
31121         obj_conv.inner = (void*)(obj & (~1));
31122         obj_conv.is_owned = false;
31123         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31124         LDKCVec_u8Z ret_var = UnsignedNodeAnnouncement_write(&obj_conv);
31125         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31126         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31127         CVec_u8Z_free(ret_var);
31128         return ret_arr;
31129 }
31130
31131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_UnsignedNodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31132         LDKu8slice ser_ref;
31133         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31134         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31135         LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ), "LDKCResult_UnsignedNodeAnnouncementDecodeErrorZ");
31136         *ret_conv = UnsignedNodeAnnouncement_read(ser_ref);
31137         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31138         return (uint64_t)ret_conv;
31139 }
31140
31141 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1write(JNIEnv *env, jclass clz, int64_t obj) {
31142         LDKNodeAnnouncement obj_conv;
31143         obj_conv.inner = (void*)(obj & (~1));
31144         obj_conv.is_owned = false;
31145         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31146         LDKCVec_u8Z ret_var = NodeAnnouncement_write(&obj_conv);
31147         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31148         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31149         CVec_u8Z_free(ret_var);
31150         return ret_arr;
31151 }
31152
31153 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncement_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31154         LDKu8slice ser_ref;
31155         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31156         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31157         LDKCResult_NodeAnnouncementDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementDecodeErrorZ), "LDKCResult_NodeAnnouncementDecodeErrorZ");
31158         *ret_conv = NodeAnnouncement_read(ser_ref);
31159         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31160         return (uint64_t)ret_conv;
31161 }
31162
31163 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31164         LDKu8slice ser_ref;
31165         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31166         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31167         LDKCResult_QueryShortChannelIdsDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryShortChannelIdsDecodeErrorZ), "LDKCResult_QueryShortChannelIdsDecodeErrorZ");
31168         *ret_conv = QueryShortChannelIds_read(ser_ref);
31169         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31170         return (uint64_t)ret_conv;
31171 }
31172
31173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryShortChannelIds_1write(JNIEnv *env, jclass clz, int64_t obj) {
31174         LDKQueryShortChannelIds obj_conv;
31175         obj_conv.inner = (void*)(obj & (~1));
31176         obj_conv.is_owned = false;
31177         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31178         LDKCVec_u8Z ret_var = QueryShortChannelIds_write(&obj_conv);
31179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31181         CVec_u8Z_free(ret_var);
31182         return ret_arr;
31183 }
31184
31185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1write(JNIEnv *env, jclass clz, int64_t obj) {
31186         LDKReplyShortChannelIdsEnd obj_conv;
31187         obj_conv.inner = (void*)(obj & (~1));
31188         obj_conv.is_owned = false;
31189         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31190         LDKCVec_u8Z ret_var = ReplyShortChannelIdsEnd_write(&obj_conv);
31191         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31192         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31193         CVec_u8Z_free(ret_var);
31194         return ret_arr;
31195 }
31196
31197 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyShortChannelIdsEnd_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31198         LDKu8slice ser_ref;
31199         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31200         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31201         LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ), "LDKCResult_ReplyShortChannelIdsEndDecodeErrorZ");
31202         *ret_conv = ReplyShortChannelIdsEnd_read(ser_ref);
31203         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31204         return (uint64_t)ret_conv;
31205 }
31206
31207 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1end_1blocknum(JNIEnv *env, jclass clz, int64_t this_arg) {
31208         LDKQueryChannelRange this_arg_conv;
31209         this_arg_conv.inner = (void*)(this_arg & (~1));
31210         this_arg_conv.is_owned = false;
31211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31212         int32_t ret_val = QueryChannelRange_end_blocknum(&this_arg_conv);
31213         return ret_val;
31214 }
31215
31216 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
31217         LDKQueryChannelRange obj_conv;
31218         obj_conv.inner = (void*)(obj & (~1));
31219         obj_conv.is_owned = false;
31220         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31221         LDKCVec_u8Z ret_var = QueryChannelRange_write(&obj_conv);
31222         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31223         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31224         CVec_u8Z_free(ret_var);
31225         return ret_arr;
31226 }
31227
31228 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_QueryChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31229         LDKu8slice ser_ref;
31230         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31231         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31232         LDKCResult_QueryChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_QueryChannelRangeDecodeErrorZ), "LDKCResult_QueryChannelRangeDecodeErrorZ");
31233         *ret_conv = QueryChannelRange_read(ser_ref);
31234         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31235         return (uint64_t)ret_conv;
31236 }
31237
31238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31239         LDKu8slice ser_ref;
31240         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31241         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31242         LDKCResult_ReplyChannelRangeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ReplyChannelRangeDecodeErrorZ), "LDKCResult_ReplyChannelRangeDecodeErrorZ");
31243         *ret_conv = ReplyChannelRange_read(ser_ref);
31244         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31245         return (uint64_t)ret_conv;
31246 }
31247
31248 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ReplyChannelRange_1write(JNIEnv *env, jclass clz, int64_t obj) {
31249         LDKReplyChannelRange obj_conv;
31250         obj_conv.inner = (void*)(obj & (~1));
31251         obj_conv.is_owned = false;
31252         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31253         LDKCVec_u8Z ret_var = ReplyChannelRange_write(&obj_conv);
31254         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31255         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31256         CVec_u8Z_free(ret_var);
31257         return ret_arr;
31258 }
31259
31260 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1write(JNIEnv *env, jclass clz, int64_t obj) {
31261         LDKGossipTimestampFilter obj_conv;
31262         obj_conv.inner = (void*)(obj & (~1));
31263         obj_conv.is_owned = false;
31264         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
31265         LDKCVec_u8Z ret_var = GossipTimestampFilter_write(&obj_conv);
31266         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31267         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31268         CVec_u8Z_free(ret_var);
31269         return ret_arr;
31270 }
31271
31272 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_GossipTimestampFilter_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
31273         LDKu8slice ser_ref;
31274         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
31275         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
31276         LDKCResult_GossipTimestampFilterDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_GossipTimestampFilterDecodeErrorZ), "LDKCResult_GossipTimestampFilterDecodeErrorZ");
31277         *ret_conv = GossipTimestampFilter_read(ser_ref);
31278         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
31279         return (uint64_t)ret_conv;
31280 }
31281
31282 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31283         if ((this_ptr & 1) != 0) return;
31284         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31285         CHECK_ACCESS(this_ptr_ptr);
31286         LDKCustomMessageHandler this_ptr_conv = *(LDKCustomMessageHandler*)(this_ptr_ptr);
31287         FREE((void*)this_ptr);
31288         CustomMessageHandler_free(this_ptr_conv);
31289 }
31290
31291 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31292         LDKIgnoringMessageHandler this_obj_conv;
31293         this_obj_conv.inner = (void*)(this_obj & (~1));
31294         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31295         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31296         IgnoringMessageHandler_free(this_obj_conv);
31297 }
31298
31299 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1new(JNIEnv *env, jclass clz) {
31300         LDKIgnoringMessageHandler ret_var = IgnoringMessageHandler_new();
31301         uint64_t ret_ref = 0;
31302         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31303         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31304         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31305         ret_ref = (uint64_t)ret_var.inner;
31306         if (ret_var.is_owned) {
31307                 ret_ref |= 1;
31308         }
31309         return ret_ref;
31310 }
31311
31312 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31313         LDKIgnoringMessageHandler this_arg_conv;
31314         this_arg_conv.inner = (void*)(this_arg & (~1));
31315         this_arg_conv.is_owned = false;
31316         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31317         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31318         *ret_ret = IgnoringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31319         return (uint64_t)ret_ret;
31320 }
31321
31322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31323         LDKIgnoringMessageHandler this_arg_conv;
31324         this_arg_conv.inner = (void*)(this_arg & (~1));
31325         this_arg_conv.is_owned = false;
31326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31327         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
31328         *ret_ret = IgnoringMessageHandler_as_RoutingMessageHandler(&this_arg_conv);
31329         return (uint64_t)ret_ret;
31330 }
31331
31332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageReader(JNIEnv *env, jclass clz, int64_t this_arg) {
31333         LDKIgnoringMessageHandler this_arg_conv;
31334         this_arg_conv.inner = (void*)(this_arg & (~1));
31335         this_arg_conv.is_owned = false;
31336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31337         LDKCustomMessageReader* ret_ret = MALLOC(sizeof(LDKCustomMessageReader), "LDKCustomMessageReader");
31338         *ret_ret = IgnoringMessageHandler_as_CustomMessageReader(&this_arg_conv);
31339         return (uint64_t)ret_ret;
31340 }
31341
31342 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_IgnoringMessageHandler_1as_1CustomMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31343         LDKIgnoringMessageHandler this_arg_conv;
31344         this_arg_conv.inner = (void*)(this_arg & (~1));
31345         this_arg_conv.is_owned = false;
31346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31347         LDKCustomMessageHandler* ret_ret = MALLOC(sizeof(LDKCustomMessageHandler), "LDKCustomMessageHandler");
31348         *ret_ret = IgnoringMessageHandler_as_CustomMessageHandler(&this_arg_conv);
31349         return (uint64_t)ret_ret;
31350 }
31351
31352 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31353         LDKErroringMessageHandler this_obj_conv;
31354         this_obj_conv.inner = (void*)(this_obj & (~1));
31355         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31357         ErroringMessageHandler_free(this_obj_conv);
31358 }
31359
31360 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1new(JNIEnv *env, jclass clz) {
31361         LDKErroringMessageHandler ret_var = ErroringMessageHandler_new();
31362         uint64_t ret_ref = 0;
31363         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31364         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31365         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31366         ret_ref = (uint64_t)ret_var.inner;
31367         if (ret_var.is_owned) {
31368                 ret_ref |= 1;
31369         }
31370         return ret_ref;
31371 }
31372
31373 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
31374         LDKErroringMessageHandler this_arg_conv;
31375         this_arg_conv.inner = (void*)(this_arg & (~1));
31376         this_arg_conv.is_owned = false;
31377         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31378         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
31379         *ret_ret = ErroringMessageHandler_as_MessageSendEventsProvider(&this_arg_conv);
31380         return (uint64_t)ret_ret;
31381 }
31382
31383 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ErroringMessageHandler_1as_1ChannelMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
31384         LDKErroringMessageHandler this_arg_conv;
31385         this_arg_conv.inner = (void*)(this_arg & (~1));
31386         this_arg_conv.is_owned = false;
31387         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31388         LDKChannelMessageHandler* ret_ret = MALLOC(sizeof(LDKChannelMessageHandler), "LDKChannelMessageHandler");
31389         *ret_ret = ErroringMessageHandler_as_ChannelMessageHandler(&this_arg_conv);
31390         return (uint64_t)ret_ret;
31391 }
31392
31393 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31394         LDKMessageHandler this_obj_conv;
31395         this_obj_conv.inner = (void*)(this_obj & (~1));
31396         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31397         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31398         MessageHandler_free(this_obj_conv);
31399 }
31400
31401 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
31402         LDKMessageHandler this_ptr_conv;
31403         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31404         this_ptr_conv.is_owned = false;
31405         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31406         // WARNING: This object doesn't live past this scope, needs clone!
31407         uint64_t ret_ret = ((uint64_t)MessageHandler_get_chan_handler(&this_ptr_conv)) | 1;
31408         return ret_ret;
31409 }
31410
31411 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1chan_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31412         LDKMessageHandler this_ptr_conv;
31413         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31414         this_ptr_conv.is_owned = false;
31415         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31416         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31417         CHECK_ACCESS(val_ptr);
31418         LDKChannelMessageHandler val_conv = *(LDKChannelMessageHandler*)(val_ptr);
31419         if (val_conv.free == LDKChannelMessageHandler_JCalls_free) {
31420                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31421                 LDKChannelMessageHandler_JCalls_cloned(&val_conv);
31422         }
31423         MessageHandler_set_chan_handler(&this_ptr_conv, val_conv);
31424 }
31425
31426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MessageHandler_1get_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr) {
31427         LDKMessageHandler this_ptr_conv;
31428         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31429         this_ptr_conv.is_owned = false;
31430         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31431         // WARNING: This object doesn't live past this scope, needs clone!
31432         uint64_t ret_ret = ((uint64_t)MessageHandler_get_route_handler(&this_ptr_conv)) | 1;
31433         return ret_ret;
31434 }
31435
31436 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MessageHandler_1set_1route_1handler(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
31437         LDKMessageHandler this_ptr_conv;
31438         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31439         this_ptr_conv.is_owned = false;
31440         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31441         void* val_ptr = (void*)(((uint64_t)val) & ~1);
31442         CHECK_ACCESS(val_ptr);
31443         LDKRoutingMessageHandler val_conv = *(LDKRoutingMessageHandler*)(val_ptr);
31444         if (val_conv.free == LDKRoutingMessageHandler_JCalls_free) {
31445                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31446                 LDKRoutingMessageHandler_JCalls_cloned(&val_conv);
31447         }
31448         MessageHandler_set_route_handler(&this_ptr_conv, val_conv);
31449 }
31450
31451 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) {
31452         void* chan_handler_arg_ptr = (void*)(((uint64_t)chan_handler_arg) & ~1);
31453         CHECK_ACCESS(chan_handler_arg_ptr);
31454         LDKChannelMessageHandler chan_handler_arg_conv = *(LDKChannelMessageHandler*)(chan_handler_arg_ptr);
31455         if (chan_handler_arg_conv.free == LDKChannelMessageHandler_JCalls_free) {
31456                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31457                 LDKChannelMessageHandler_JCalls_cloned(&chan_handler_arg_conv);
31458         }
31459         void* route_handler_arg_ptr = (void*)(((uint64_t)route_handler_arg) & ~1);
31460         CHECK_ACCESS(route_handler_arg_ptr);
31461         LDKRoutingMessageHandler route_handler_arg_conv = *(LDKRoutingMessageHandler*)(route_handler_arg_ptr);
31462         if (route_handler_arg_conv.free == LDKRoutingMessageHandler_JCalls_free) {
31463                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31464                 LDKRoutingMessageHandler_JCalls_cloned(&route_handler_arg_conv);
31465         }
31466         LDKMessageHandler ret_var = MessageHandler_new(chan_handler_arg_conv, route_handler_arg_conv);
31467         uint64_t ret_ref = 0;
31468         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31469         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31470         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31471         ret_ref = (uint64_t)ret_var.inner;
31472         if (ret_var.is_owned) {
31473                 ret_ref |= 1;
31474         }
31475         return ret_ref;
31476 }
31477
31478 static inline uint64_t SocketDescriptor_clone_ptr(LDKSocketDescriptor *NONNULL_PTR arg) {
31479         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
31480         *ret_ret = SocketDescriptor_clone(arg);
31481         return (uint64_t)ret_ret;
31482 }
31483 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31484         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
31485         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
31486         LDKSocketDescriptor* arg_conv = (LDKSocketDescriptor*)arg_ptr;
31487         int64_t ret_val = SocketDescriptor_clone_ptr(arg_conv);
31488         return ret_val;
31489 }
31490
31491 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31492         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
31493         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
31494         LDKSocketDescriptor* orig_conv = (LDKSocketDescriptor*)orig_ptr;
31495         LDKSocketDescriptor* ret_ret = MALLOC(sizeof(LDKSocketDescriptor), "LDKSocketDescriptor");
31496         *ret_ret = SocketDescriptor_clone(orig_conv);
31497         return (uint64_t)ret_ret;
31498 }
31499
31500 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SocketDescriptor_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
31501         if ((this_ptr & 1) != 0) return;
31502         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
31503         CHECK_ACCESS(this_ptr_ptr);
31504         LDKSocketDescriptor this_ptr_conv = *(LDKSocketDescriptor*)(this_ptr_ptr);
31505         FREE((void*)this_ptr);
31506         SocketDescriptor_free(this_ptr_conv);
31507 }
31508
31509 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31510         LDKPeerHandleError this_obj_conv;
31511         this_obj_conv.inner = (void*)(this_obj & (~1));
31512         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31513         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31514         PeerHandleError_free(this_obj_conv);
31515 }
31516
31517 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1get_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr) {
31518         LDKPeerHandleError this_ptr_conv;
31519         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31520         this_ptr_conv.is_owned = false;
31521         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31522         jboolean ret_val = PeerHandleError_get_no_connection_possible(&this_ptr_conv);
31523         return ret_val;
31524 }
31525
31526 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1set_1no_1connection_1possible(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
31527         LDKPeerHandleError this_ptr_conv;
31528         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31529         this_ptr_conv.is_owned = false;
31530         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31531         PeerHandleError_set_no_connection_possible(&this_ptr_conv, val);
31532 }
31533
31534 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1new(JNIEnv *env, jclass clz, jboolean no_connection_possible_arg) {
31535         LDKPeerHandleError ret_var = PeerHandleError_new(no_connection_possible_arg);
31536         uint64_t ret_ref = 0;
31537         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31538         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31539         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31540         ret_ref = (uint64_t)ret_var.inner;
31541         if (ret_var.is_owned) {
31542                 ret_ref |= 1;
31543         }
31544         return ret_ref;
31545 }
31546
31547 static inline uint64_t PeerHandleError_clone_ptr(LDKPeerHandleError *NONNULL_PTR arg) {
31548         LDKPeerHandleError ret_var = PeerHandleError_clone(arg);
31549 uint64_t ret_ref = 0;
31550 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31551 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31552 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31553 ret_ref = (uint64_t)ret_var.inner;
31554 if (ret_var.is_owned) {
31555         ret_ref |= 1;
31556 }
31557         return ret_ref;
31558 }
31559 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
31560         LDKPeerHandleError arg_conv;
31561         arg_conv.inner = (void*)(arg & (~1));
31562         arg_conv.is_owned = false;
31563         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
31564         int64_t ret_val = PeerHandleError_clone_ptr(&arg_conv);
31565         return ret_val;
31566 }
31567
31568 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerHandleError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
31569         LDKPeerHandleError orig_conv;
31570         orig_conv.inner = (void*)(orig & (~1));
31571         orig_conv.is_owned = false;
31572         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
31573         LDKPeerHandleError ret_var = PeerHandleError_clone(&orig_conv);
31574         uint64_t ret_ref = 0;
31575         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31576         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31577         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31578         ret_ref = (uint64_t)ret_var.inner;
31579         if (ret_var.is_owned) {
31580                 ret_ref |= 1;
31581         }
31582         return ret_ref;
31583 }
31584
31585 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31586         LDKPeerManager this_obj_conv;
31587         this_obj_conv.inner = (void*)(this_obj & (~1));
31588         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31589         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31590         PeerManager_free(this_obj_conv);
31591 }
31592
31593 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) {
31594         LDKMessageHandler message_handler_conv;
31595         message_handler_conv.inner = (void*)(message_handler & (~1));
31596         message_handler_conv.is_owned = (message_handler & 1) || (message_handler == 0);
31597         CHECK_INNER_FIELD_ACCESS_OR_NULL(message_handler_conv);
31598         // Warning: we need a move here but no clone is available for LDKMessageHandler
31599         LDKSecretKey our_node_secret_ref;
31600         CHECK((*env)->GetArrayLength(env, our_node_secret) == 32);
31601         (*env)->GetByteArrayRegion(env, our_node_secret, 0, 32, our_node_secret_ref.bytes);
31602         unsigned char ephemeral_random_data_arr[32];
31603         CHECK((*env)->GetArrayLength(env, ephemeral_random_data) == 32);
31604         (*env)->GetByteArrayRegion(env, ephemeral_random_data, 0, 32, ephemeral_random_data_arr);
31605         unsigned char (*ephemeral_random_data_ref)[32] = &ephemeral_random_data_arr;
31606         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
31607         CHECK_ACCESS(logger_ptr);
31608         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
31609         if (logger_conv.free == LDKLogger_JCalls_free) {
31610                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31611                 LDKLogger_JCalls_cloned(&logger_conv);
31612         }
31613         void* custom_message_handler_ptr = (void*)(((uint64_t)custom_message_handler) & ~1);
31614         CHECK_ACCESS(custom_message_handler_ptr);
31615         LDKCustomMessageHandler custom_message_handler_conv = *(LDKCustomMessageHandler*)(custom_message_handler_ptr);
31616         if (custom_message_handler_conv.free == LDKCustomMessageHandler_JCalls_free) {
31617                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31618                 LDKCustomMessageHandler_JCalls_cloned(&custom_message_handler_conv);
31619         }
31620         LDKPeerManager ret_var = PeerManager_new(message_handler_conv, our_node_secret_ref, ephemeral_random_data_ref, logger_conv, custom_message_handler_conv);
31621         uint64_t ret_ref = 0;
31622         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31623         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31624         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31625         ret_ref = (uint64_t)ret_var.inner;
31626         if (ret_var.is_owned) {
31627                 ret_ref |= 1;
31628         }
31629         return ret_ref;
31630 }
31631
31632 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_PeerManager_1get_1peer_1node_1ids(JNIEnv *env, jclass clz, int64_t this_arg) {
31633         LDKPeerManager this_arg_conv;
31634         this_arg_conv.inner = (void*)(this_arg & (~1));
31635         this_arg_conv.is_owned = false;
31636         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31637         LDKCVec_PublicKeyZ ret_var = PeerManager_get_peer_node_ids(&this_arg_conv);
31638         jobjectArray ret_arr = NULL;
31639         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_B_clz, NULL);
31640         ;
31641         for (size_t i = 0; i < ret_var.datalen; i++) {
31642                 int8_tArray ret_conv_8_arr = (*env)->NewByteArray(env, 33);
31643                 (*env)->SetByteArrayRegion(env, ret_conv_8_arr, 0, 33, ret_var.data[i].compressed_form);
31644                 (*env)->SetObjectArrayElement(env, ret_arr, i, ret_conv_8_arr);
31645         }
31646         
31647         FREE(ret_var.data);
31648         return ret_arr;
31649 }
31650
31651 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) {
31652         LDKPeerManager this_arg_conv;
31653         this_arg_conv.inner = (void*)(this_arg & (~1));
31654         this_arg_conv.is_owned = false;
31655         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31656         LDKPublicKey their_node_id_ref;
31657         CHECK((*env)->GetArrayLength(env, their_node_id) == 33);
31658         (*env)->GetByteArrayRegion(env, their_node_id, 0, 33, their_node_id_ref.compressed_form);
31659         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
31660         CHECK_ACCESS(descriptor_ptr);
31661         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
31662         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
31663                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31664                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
31665         }
31666         LDKCResult_CVec_u8ZPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_u8ZPeerHandleErrorZ), "LDKCResult_CVec_u8ZPeerHandleErrorZ");
31667         *ret_conv = PeerManager_new_outbound_connection(&this_arg_conv, their_node_id_ref, descriptor_conv);
31668         return (uint64_t)ret_conv;
31669 }
31670
31671 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PeerManager_1new_1inbound_1connection(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
31672         LDKPeerManager this_arg_conv;
31673         this_arg_conv.inner = (void*)(this_arg & (~1));
31674         this_arg_conv.is_owned = false;
31675         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31676         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
31677         CHECK_ACCESS(descriptor_ptr);
31678         LDKSocketDescriptor descriptor_conv = *(LDKSocketDescriptor*)(descriptor_ptr);
31679         if (descriptor_conv.free == LDKSocketDescriptor_JCalls_free) {
31680                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
31681                 LDKSocketDescriptor_JCalls_cloned(&descriptor_conv);
31682         }
31683         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
31684         *ret_conv = PeerManager_new_inbound_connection(&this_arg_conv, descriptor_conv);
31685         return (uint64_t)ret_conv;
31686 }
31687
31688 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) {
31689         LDKPeerManager this_arg_conv;
31690         this_arg_conv.inner = (void*)(this_arg & (~1));
31691         this_arg_conv.is_owned = false;
31692         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31693         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
31694         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
31695         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
31696         LDKCResult_NonePeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NonePeerHandleErrorZ), "LDKCResult_NonePeerHandleErrorZ");
31697         *ret_conv = PeerManager_write_buffer_space_avail(&this_arg_conv, descriptor_conv);
31698         return (uint64_t)ret_conv;
31699 }
31700
31701 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) {
31702         LDKPeerManager this_arg_conv;
31703         this_arg_conv.inner = (void*)(this_arg & (~1));
31704         this_arg_conv.is_owned = false;
31705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31706         void* peer_descriptor_ptr = (void*)(((uint64_t)peer_descriptor) & ~1);
31707         if (!(peer_descriptor & 1)) { CHECK_ACCESS(peer_descriptor_ptr); }
31708         LDKSocketDescriptor* peer_descriptor_conv = (LDKSocketDescriptor*)peer_descriptor_ptr;
31709         LDKu8slice data_ref;
31710         data_ref.datalen = (*env)->GetArrayLength(env, data);
31711         data_ref.data = (*env)->GetByteArrayElements (env, data, NULL);
31712         LDKCResult_boolPeerHandleErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_boolPeerHandleErrorZ), "LDKCResult_boolPeerHandleErrorZ");
31713         *ret_conv = PeerManager_read_event(&this_arg_conv, peer_descriptor_conv, data_ref);
31714         (*env)->ReleaseByteArrayElements(env, data, (int8_t*)data_ref.data, 0);
31715         return (uint64_t)ret_conv;
31716 }
31717
31718 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1process_1events(JNIEnv *env, jclass clz, int64_t this_arg) {
31719         LDKPeerManager this_arg_conv;
31720         this_arg_conv.inner = (void*)(this_arg & (~1));
31721         this_arg_conv.is_owned = false;
31722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31723         PeerManager_process_events(&this_arg_conv);
31724 }
31725
31726 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1socket_1disconnected(JNIEnv *env, jclass clz, int64_t this_arg, int64_t descriptor) {
31727         LDKPeerManager this_arg_conv;
31728         this_arg_conv.inner = (void*)(this_arg & (~1));
31729         this_arg_conv.is_owned = false;
31730         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31731         void* descriptor_ptr = (void*)(((uint64_t)descriptor) & ~1);
31732         if (!(descriptor & 1)) { CHECK_ACCESS(descriptor_ptr); }
31733         LDKSocketDescriptor* descriptor_conv = (LDKSocketDescriptor*)descriptor_ptr;
31734         PeerManager_socket_disconnected(&this_arg_conv, descriptor_conv);
31735 }
31736
31737 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) {
31738         LDKPeerManager this_arg_conv;
31739         this_arg_conv.inner = (void*)(this_arg & (~1));
31740         this_arg_conv.is_owned = false;
31741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31742         LDKPublicKey node_id_ref;
31743         CHECK((*env)->GetArrayLength(env, node_id) == 33);
31744         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
31745         PeerManager_disconnect_by_node_id(&this_arg_conv, node_id_ref, no_connection_possible);
31746 }
31747
31748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1disconnect_1all_1peers(JNIEnv *env, jclass clz, int64_t this_arg) {
31749         LDKPeerManager this_arg_conv;
31750         this_arg_conv.inner = (void*)(this_arg & (~1));
31751         this_arg_conv.is_owned = false;
31752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31753         PeerManager_disconnect_all_peers(&this_arg_conv);
31754 }
31755
31756 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PeerManager_1timer_1tick_1occurred(JNIEnv *env, jclass clz, int64_t this_arg) {
31757         LDKPeerManager this_arg_conv;
31758         this_arg_conv.inner = (void*)(this_arg & (~1));
31759         this_arg_conv.is_owned = false;
31760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
31761         PeerManager_timer_tick_occurred(&this_arg_conv);
31762 }
31763
31764 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_build_1commitment_1secret(JNIEnv *env, jclass clz, int8_tArray commitment_seed, int64_t idx) {
31765         unsigned char commitment_seed_arr[32];
31766         CHECK((*env)->GetArrayLength(env, commitment_seed) == 32);
31767         (*env)->GetByteArrayRegion(env, commitment_seed, 0, 32, commitment_seed_arr);
31768         unsigned char (*commitment_seed_ref)[32] = &commitment_seed_arr;
31769         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
31770         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, build_commitment_secret(commitment_seed_ref, idx).data);
31771         return ret_arr;
31772 }
31773
31774 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) {
31775         LDKCVec_u8Z to_holder_script_ref;
31776         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
31777         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
31778         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
31779         LDKCVec_u8Z to_counterparty_script_ref;
31780         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
31781         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
31782         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
31783         LDKOutPoint funding_outpoint_conv;
31784         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
31785         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
31786         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
31787         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
31788         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);
31789         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
31790         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
31791         Transaction_free(ret_var);
31792         return ret_arr;
31793 }
31794
31795 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) {
31796         LDKPublicKey per_commitment_point_ref;
31797         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
31798         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
31799         unsigned char base_secret_arr[32];
31800         CHECK((*env)->GetArrayLength(env, base_secret) == 32);
31801         (*env)->GetByteArrayRegion(env, base_secret, 0, 32, base_secret_arr);
31802         unsigned char (*base_secret_ref)[32] = &base_secret_arr;
31803         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
31804         *ret_conv = derive_private_key(per_commitment_point_ref, base_secret_ref);
31805         return (uint64_t)ret_conv;
31806 }
31807
31808 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) {
31809         LDKPublicKey per_commitment_point_ref;
31810         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
31811         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
31812         LDKPublicKey base_point_ref;
31813         CHECK((*env)->GetArrayLength(env, base_point) == 33);
31814         (*env)->GetByteArrayRegion(env, base_point, 0, 33, base_point_ref.compressed_form);
31815         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
31816         *ret_conv = derive_public_key(per_commitment_point_ref, base_point_ref);
31817         return (uint64_t)ret_conv;
31818 }
31819
31820 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) {
31821         unsigned char per_commitment_secret_arr[32];
31822         CHECK((*env)->GetArrayLength(env, per_commitment_secret) == 32);
31823         (*env)->GetByteArrayRegion(env, per_commitment_secret, 0, 32, per_commitment_secret_arr);
31824         unsigned char (*per_commitment_secret_ref)[32] = &per_commitment_secret_arr;
31825         unsigned char countersignatory_revocation_base_secret_arr[32];
31826         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_secret) == 32);
31827         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_secret, 0, 32, countersignatory_revocation_base_secret_arr);
31828         unsigned char (*countersignatory_revocation_base_secret_ref)[32] = &countersignatory_revocation_base_secret_arr;
31829         LDKCResult_SecretKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_SecretKeyErrorZ), "LDKCResult_SecretKeyErrorZ");
31830         *ret_conv = derive_private_revocation_key(per_commitment_secret_ref, countersignatory_revocation_base_secret_ref);
31831         return (uint64_t)ret_conv;
31832 }
31833
31834 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) {
31835         LDKPublicKey per_commitment_point_ref;
31836         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
31837         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
31838         LDKPublicKey countersignatory_revocation_base_point_ref;
31839         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base_point) == 33);
31840         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base_point, 0, 33, countersignatory_revocation_base_point_ref.compressed_form);
31841         LDKCResult_PublicKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PublicKeyErrorZ), "LDKCResult_PublicKeyErrorZ");
31842         *ret_conv = derive_public_revocation_key(per_commitment_point_ref, countersignatory_revocation_base_point_ref);
31843         return (uint64_t)ret_conv;
31844 }
31845
31846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
31847         LDKTxCreationKeys this_obj_conv;
31848         this_obj_conv.inner = (void*)(this_obj & (~1));
31849         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
31850         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
31851         TxCreationKeys_free(this_obj_conv);
31852 }
31853
31854 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
31855         LDKTxCreationKeys this_ptr_conv;
31856         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31857         this_ptr_conv.is_owned = false;
31858         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31859         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31860         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_per_commitment_point(&this_ptr_conv).compressed_form);
31861         return ret_arr;
31862 }
31863
31864 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1per_1commitment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31865         LDKTxCreationKeys this_ptr_conv;
31866         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31867         this_ptr_conv.is_owned = false;
31868         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31869         LDKPublicKey val_ref;
31870         CHECK((*env)->GetArrayLength(env, val) == 33);
31871         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31872         TxCreationKeys_set_per_commitment_point(&this_ptr_conv, val_ref);
31873 }
31874
31875 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31876         LDKTxCreationKeys this_ptr_conv;
31877         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31878         this_ptr_conv.is_owned = false;
31879         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31880         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31881         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_revocation_key(&this_ptr_conv).compressed_form);
31882         return ret_arr;
31883 }
31884
31885 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1revocation_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31886         LDKTxCreationKeys this_ptr_conv;
31887         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31888         this_ptr_conv.is_owned = false;
31889         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31890         LDKPublicKey val_ref;
31891         CHECK((*env)->GetArrayLength(env, val) == 33);
31892         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31893         TxCreationKeys_set_revocation_key(&this_ptr_conv, val_ref);
31894 }
31895
31896 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31897         LDKTxCreationKeys this_ptr_conv;
31898         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31899         this_ptr_conv.is_owned = false;
31900         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31901         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31902         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_htlc_key(&this_ptr_conv).compressed_form);
31903         return ret_arr;
31904 }
31905
31906 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1broadcaster_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31907         LDKTxCreationKeys this_ptr_conv;
31908         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31909         this_ptr_conv.is_owned = false;
31910         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31911         LDKPublicKey val_ref;
31912         CHECK((*env)->GetArrayLength(env, val) == 33);
31913         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31914         TxCreationKeys_set_broadcaster_htlc_key(&this_ptr_conv, val_ref);
31915 }
31916
31917 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31918         LDKTxCreationKeys this_ptr_conv;
31919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31920         this_ptr_conv.is_owned = false;
31921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31922         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31923         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_countersignatory_htlc_key(&this_ptr_conv).compressed_form);
31924         return ret_arr;
31925 }
31926
31927 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1set_1countersignatory_1htlc_1key(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
31928         LDKTxCreationKeys this_ptr_conv;
31929         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31930         this_ptr_conv.is_owned = false;
31931         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31932         LDKPublicKey val_ref;
31933         CHECK((*env)->GetArrayLength(env, val) == 33);
31934         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31935         TxCreationKeys_set_countersignatory_htlc_key(&this_ptr_conv, val_ref);
31936 }
31937
31938 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1get_1broadcaster_1delayed_1payment_1key(JNIEnv *env, jclass clz, int64_t this_ptr) {
31939         LDKTxCreationKeys this_ptr_conv;
31940         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31941         this_ptr_conv.is_owned = false;
31942         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31943         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
31944         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, TxCreationKeys_get_broadcaster_delayed_payment_key(&this_ptr_conv).compressed_form);
31945         return ret_arr;
31946 }
31947
31948 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) {
31949         LDKTxCreationKeys this_ptr_conv;
31950         this_ptr_conv.inner = (void*)(this_ptr & (~1));
31951         this_ptr_conv.is_owned = false;
31952         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
31953         LDKPublicKey val_ref;
31954         CHECK((*env)->GetArrayLength(env, val) == 33);
31955         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
31956         TxCreationKeys_set_broadcaster_delayed_payment_key(&this_ptr_conv, val_ref);
31957 }
31958
31959 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) {
31960         LDKPublicKey per_commitment_point_arg_ref;
31961         CHECK((*env)->GetArrayLength(env, per_commitment_point_arg) == 33);
31962         (*env)->GetByteArrayRegion(env, per_commitment_point_arg, 0, 33, per_commitment_point_arg_ref.compressed_form);
31963         LDKPublicKey revocation_key_arg_ref;
31964         CHECK((*env)->GetArrayLength(env, revocation_key_arg) == 33);
31965         (*env)->GetByteArrayRegion(env, revocation_key_arg, 0, 33, revocation_key_arg_ref.compressed_form);
31966         LDKPublicKey broadcaster_htlc_key_arg_ref;
31967         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_key_arg) == 33);
31968         (*env)->GetByteArrayRegion(env, broadcaster_htlc_key_arg, 0, 33, broadcaster_htlc_key_arg_ref.compressed_form);
31969         LDKPublicKey countersignatory_htlc_key_arg_ref;
31970         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_key_arg) == 33);
31971         (*env)->GetByteArrayRegion(env, countersignatory_htlc_key_arg, 0, 33, countersignatory_htlc_key_arg_ref.compressed_form);
31972         LDKPublicKey broadcaster_delayed_payment_key_arg_ref;
31973         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key_arg) == 33);
31974         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key_arg, 0, 33, broadcaster_delayed_payment_key_arg_ref.compressed_form);
31975         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);
31976         uint64_t ret_ref = 0;
31977         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31978         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31979         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31980         ret_ref = (uint64_t)ret_var.inner;
31981         if (ret_var.is_owned) {
31982                 ret_ref |= 1;
31983         }
31984         return ret_ref;
31985 }
31986
31987 static inline uint64_t TxCreationKeys_clone_ptr(LDKTxCreationKeys *NONNULL_PTR arg) {
31988         LDKTxCreationKeys ret_var = TxCreationKeys_clone(arg);
31989 uint64_t ret_ref = 0;
31990 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
31991 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
31992 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
31993 ret_ref = (uint64_t)ret_var.inner;
31994 if (ret_var.is_owned) {
31995         ret_ref |= 1;
31996 }
31997         return ret_ref;
31998 }
31999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32000         LDKTxCreationKeys arg_conv;
32001         arg_conv.inner = (void*)(arg & (~1));
32002         arg_conv.is_owned = false;
32003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32004         int64_t ret_val = TxCreationKeys_clone_ptr(&arg_conv);
32005         return ret_val;
32006 }
32007
32008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32009         LDKTxCreationKeys orig_conv;
32010         orig_conv.inner = (void*)(orig & (~1));
32011         orig_conv.is_owned = false;
32012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32013         LDKTxCreationKeys ret_var = TxCreationKeys_clone(&orig_conv);
32014         uint64_t ret_ref = 0;
32015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32018         ret_ref = (uint64_t)ret_var.inner;
32019         if (ret_var.is_owned) {
32020                 ret_ref |= 1;
32021         }
32022         return ret_ref;
32023 }
32024
32025 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
32026         LDKTxCreationKeys obj_conv;
32027         obj_conv.inner = (void*)(obj & (~1));
32028         obj_conv.is_owned = false;
32029         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32030         LDKCVec_u8Z ret_var = TxCreationKeys_write(&obj_conv);
32031         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32032         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32033         CVec_u8Z_free(ret_var);
32034         return ret_arr;
32035 }
32036
32037 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TxCreationKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32038         LDKu8slice ser_ref;
32039         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32040         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32041         LDKCResult_TxCreationKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysDecodeErrorZ), "LDKCResult_TxCreationKeysDecodeErrorZ");
32042         *ret_conv = TxCreationKeys_read(ser_ref);
32043         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32044         return (uint64_t)ret_conv;
32045 }
32046
32047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32048         LDKChannelPublicKeys this_obj_conv;
32049         this_obj_conv.inner = (void*)(this_obj & (~1));
32050         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32052         ChannelPublicKeys_free(this_obj_conv);
32053 }
32054
32055 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
32056         LDKChannelPublicKeys this_ptr_conv;
32057         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32058         this_ptr_conv.is_owned = false;
32059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32060         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32061         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_funding_pubkey(&this_ptr_conv).compressed_form);
32062         return ret_arr;
32063 }
32064
32065 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1funding_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32066         LDKChannelPublicKeys this_ptr_conv;
32067         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32068         this_ptr_conv.is_owned = false;
32069         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32070         LDKPublicKey val_ref;
32071         CHECK((*env)->GetArrayLength(env, val) == 33);
32072         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32073         ChannelPublicKeys_set_funding_pubkey(&this_ptr_conv, val_ref);
32074 }
32075
32076 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32077         LDKChannelPublicKeys this_ptr_conv;
32078         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32079         this_ptr_conv.is_owned = false;
32080         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32081         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32082         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_revocation_basepoint(&this_ptr_conv).compressed_form);
32083         return ret_arr;
32084 }
32085
32086 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1revocation_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32087         LDKChannelPublicKeys this_ptr_conv;
32088         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32089         this_ptr_conv.is_owned = false;
32090         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32091         LDKPublicKey val_ref;
32092         CHECK((*env)->GetArrayLength(env, val) == 33);
32093         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32094         ChannelPublicKeys_set_revocation_basepoint(&this_ptr_conv, val_ref);
32095 }
32096
32097 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr) {
32098         LDKChannelPublicKeys this_ptr_conv;
32099         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32100         this_ptr_conv.is_owned = false;
32101         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32102         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32103         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_payment_point(&this_ptr_conv).compressed_form);
32104         return ret_arr;
32105 }
32106
32107 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1payment_1point(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32108         LDKChannelPublicKeys this_ptr_conv;
32109         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32110         this_ptr_conv.is_owned = false;
32111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32112         LDKPublicKey val_ref;
32113         CHECK((*env)->GetArrayLength(env, val) == 33);
32114         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32115         ChannelPublicKeys_set_payment_point(&this_ptr_conv, val_ref);
32116 }
32117
32118 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32119         LDKChannelPublicKeys this_ptr_conv;
32120         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32121         this_ptr_conv.is_owned = false;
32122         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32123         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32124         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_delayed_payment_basepoint(&this_ptr_conv).compressed_form);
32125         return ret_arr;
32126 }
32127
32128 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1delayed_1payment_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32129         LDKChannelPublicKeys this_ptr_conv;
32130         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32131         this_ptr_conv.is_owned = false;
32132         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32133         LDKPublicKey val_ref;
32134         CHECK((*env)->GetArrayLength(env, val) == 33);
32135         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32136         ChannelPublicKeys_set_delayed_payment_basepoint(&this_ptr_conv, val_ref);
32137 }
32138
32139 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1get_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32140         LDKChannelPublicKeys this_ptr_conv;
32141         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32142         this_ptr_conv.is_owned = false;
32143         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32144         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
32145         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ChannelPublicKeys_get_htlc_basepoint(&this_ptr_conv).compressed_form);
32146         return ret_arr;
32147 }
32148
32149 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1set_1htlc_1basepoint(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32150         LDKChannelPublicKeys this_ptr_conv;
32151         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32152         this_ptr_conv.is_owned = false;
32153         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32154         LDKPublicKey val_ref;
32155         CHECK((*env)->GetArrayLength(env, val) == 33);
32156         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
32157         ChannelPublicKeys_set_htlc_basepoint(&this_ptr_conv, val_ref);
32158 }
32159
32160 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) {
32161         LDKPublicKey funding_pubkey_arg_ref;
32162         CHECK((*env)->GetArrayLength(env, funding_pubkey_arg) == 33);
32163         (*env)->GetByteArrayRegion(env, funding_pubkey_arg, 0, 33, funding_pubkey_arg_ref.compressed_form);
32164         LDKPublicKey revocation_basepoint_arg_ref;
32165         CHECK((*env)->GetArrayLength(env, revocation_basepoint_arg) == 33);
32166         (*env)->GetByteArrayRegion(env, revocation_basepoint_arg, 0, 33, revocation_basepoint_arg_ref.compressed_form);
32167         LDKPublicKey payment_point_arg_ref;
32168         CHECK((*env)->GetArrayLength(env, payment_point_arg) == 33);
32169         (*env)->GetByteArrayRegion(env, payment_point_arg, 0, 33, payment_point_arg_ref.compressed_form);
32170         LDKPublicKey delayed_payment_basepoint_arg_ref;
32171         CHECK((*env)->GetArrayLength(env, delayed_payment_basepoint_arg) == 33);
32172         (*env)->GetByteArrayRegion(env, delayed_payment_basepoint_arg, 0, 33, delayed_payment_basepoint_arg_ref.compressed_form);
32173         LDKPublicKey htlc_basepoint_arg_ref;
32174         CHECK((*env)->GetArrayLength(env, htlc_basepoint_arg) == 33);
32175         (*env)->GetByteArrayRegion(env, htlc_basepoint_arg, 0, 33, htlc_basepoint_arg_ref.compressed_form);
32176         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);
32177         uint64_t ret_ref = 0;
32178         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32179         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32180         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32181         ret_ref = (uint64_t)ret_var.inner;
32182         if (ret_var.is_owned) {
32183                 ret_ref |= 1;
32184         }
32185         return ret_ref;
32186 }
32187
32188 static inline uint64_t ChannelPublicKeys_clone_ptr(LDKChannelPublicKeys *NONNULL_PTR arg) {
32189         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(arg);
32190 uint64_t ret_ref = 0;
32191 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32192 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32193 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32194 ret_ref = (uint64_t)ret_var.inner;
32195 if (ret_var.is_owned) {
32196         ret_ref |= 1;
32197 }
32198         return ret_ref;
32199 }
32200 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32201         LDKChannelPublicKeys arg_conv;
32202         arg_conv.inner = (void*)(arg & (~1));
32203         arg_conv.is_owned = false;
32204         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32205         int64_t ret_val = ChannelPublicKeys_clone_ptr(&arg_conv);
32206         return ret_val;
32207 }
32208
32209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32210         LDKChannelPublicKeys orig_conv;
32211         orig_conv.inner = (void*)(orig & (~1));
32212         orig_conv.is_owned = false;
32213         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32214         LDKChannelPublicKeys ret_var = ChannelPublicKeys_clone(&orig_conv);
32215         uint64_t ret_ref = 0;
32216         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32217         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32218         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32219         ret_ref = (uint64_t)ret_var.inner;
32220         if (ret_var.is_owned) {
32221                 ret_ref |= 1;
32222         }
32223         return ret_ref;
32224 }
32225
32226 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1write(JNIEnv *env, jclass clz, int64_t obj) {
32227         LDKChannelPublicKeys obj_conv;
32228         obj_conv.inner = (void*)(obj & (~1));
32229         obj_conv.is_owned = false;
32230         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32231         LDKCVec_u8Z ret_var = ChannelPublicKeys_write(&obj_conv);
32232         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32233         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32234         CVec_u8Z_free(ret_var);
32235         return ret_arr;
32236 }
32237
32238 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelPublicKeys_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32239         LDKu8slice ser_ref;
32240         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32241         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32242         LDKCResult_ChannelPublicKeysDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelPublicKeysDecodeErrorZ), "LDKCResult_ChannelPublicKeysDecodeErrorZ");
32243         *ret_conv = ChannelPublicKeys_read(ser_ref);
32244         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32245         return (uint64_t)ret_conv;
32246 }
32247
32248 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) {
32249         LDKPublicKey per_commitment_point_ref;
32250         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
32251         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
32252         LDKPublicKey broadcaster_delayed_payment_base_ref;
32253         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_base) == 33);
32254         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_base, 0, 33, broadcaster_delayed_payment_base_ref.compressed_form);
32255         LDKPublicKey broadcaster_htlc_base_ref;
32256         CHECK((*env)->GetArrayLength(env, broadcaster_htlc_base) == 33);
32257         (*env)->GetByteArrayRegion(env, broadcaster_htlc_base, 0, 33, broadcaster_htlc_base_ref.compressed_form);
32258         LDKPublicKey countersignatory_revocation_base_ref;
32259         CHECK((*env)->GetArrayLength(env, countersignatory_revocation_base) == 33);
32260         (*env)->GetByteArrayRegion(env, countersignatory_revocation_base, 0, 33, countersignatory_revocation_base_ref.compressed_form);
32261         LDKPublicKey countersignatory_htlc_base_ref;
32262         CHECK((*env)->GetArrayLength(env, countersignatory_htlc_base) == 33);
32263         (*env)->GetByteArrayRegion(env, countersignatory_htlc_base, 0, 33, countersignatory_htlc_base_ref.compressed_form);
32264         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32265         *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);
32266         return (uint64_t)ret_conv;
32267 }
32268
32269 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) {
32270         LDKPublicKey per_commitment_point_ref;
32271         CHECK((*env)->GetArrayLength(env, per_commitment_point) == 33);
32272         (*env)->GetByteArrayRegion(env, per_commitment_point, 0, 33, per_commitment_point_ref.compressed_form);
32273         LDKChannelPublicKeys broadcaster_keys_conv;
32274         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
32275         broadcaster_keys_conv.is_owned = false;
32276         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
32277         LDKChannelPublicKeys countersignatory_keys_conv;
32278         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
32279         countersignatory_keys_conv.is_owned = false;
32280         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
32281         LDKCResult_TxCreationKeysErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_TxCreationKeysErrorZ), "LDKCResult_TxCreationKeysErrorZ");
32282         *ret_conv = TxCreationKeys_from_channel_static_keys(per_commitment_point_ref, &broadcaster_keys_conv, &countersignatory_keys_conv);
32283         return (uint64_t)ret_conv;
32284 }
32285
32286 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) {
32287         LDKPublicKey revocation_key_ref;
32288         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
32289         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
32290         LDKPublicKey broadcaster_delayed_payment_key_ref;
32291         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
32292         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
32293         LDKCVec_u8Z ret_var = get_revokeable_redeemscript(revocation_key_ref, contest_delay, broadcaster_delayed_payment_key_ref);
32294         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32295         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32296         CVec_u8Z_free(ret_var);
32297         return ret_arr;
32298 }
32299
32300 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32301         LDKHTLCOutputInCommitment this_obj_conv;
32302         this_obj_conv.inner = (void*)(this_obj & (~1));
32303         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32305         HTLCOutputInCommitment_free(this_obj_conv);
32306 }
32307
32308 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1offered(JNIEnv *env, jclass clz, int64_t this_ptr) {
32309         LDKHTLCOutputInCommitment this_ptr_conv;
32310         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32311         this_ptr_conv.is_owned = false;
32312         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32313         jboolean ret_val = HTLCOutputInCommitment_get_offered(&this_ptr_conv);
32314         return ret_val;
32315 }
32316
32317 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1offered(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32318         LDKHTLCOutputInCommitment this_ptr_conv;
32319         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32320         this_ptr_conv.is_owned = false;
32321         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32322         HTLCOutputInCommitment_set_offered(&this_ptr_conv, val);
32323 }
32324
32325 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
32326         LDKHTLCOutputInCommitment this_ptr_conv;
32327         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32328         this_ptr_conv.is_owned = false;
32329         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32330         int64_t ret_val = HTLCOutputInCommitment_get_amount_msat(&this_ptr_conv);
32331         return ret_val;
32332 }
32333
32334 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1amount_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32335         LDKHTLCOutputInCommitment this_ptr_conv;
32336         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32337         this_ptr_conv.is_owned = false;
32338         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32339         HTLCOutputInCommitment_set_amount_msat(&this_ptr_conv, val);
32340 }
32341
32342 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr) {
32343         LDKHTLCOutputInCommitment this_ptr_conv;
32344         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32345         this_ptr_conv.is_owned = false;
32346         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32347         int32_t ret_val = HTLCOutputInCommitment_get_cltv_expiry(&this_ptr_conv);
32348         return ret_val;
32349 }
32350
32351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
32352         LDKHTLCOutputInCommitment this_ptr_conv;
32353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32354         this_ptr_conv.is_owned = false;
32355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32356         HTLCOutputInCommitment_set_cltv_expiry(&this_ptr_conv, val);
32357 }
32358
32359 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr) {
32360         LDKHTLCOutputInCommitment this_ptr_conv;
32361         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32362         this_ptr_conv.is_owned = false;
32363         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32364         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
32365         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *HTLCOutputInCommitment_get_payment_hash(&this_ptr_conv));
32366         return ret_arr;
32367 }
32368
32369 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
32370         LDKHTLCOutputInCommitment this_ptr_conv;
32371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32372         this_ptr_conv.is_owned = false;
32373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32374         LDKThirtyTwoBytes val_ref;
32375         CHECK((*env)->GetArrayLength(env, val) == 32);
32376         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
32377         HTLCOutputInCommitment_set_payment_hash(&this_ptr_conv, val_ref);
32378 }
32379
32380 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1get_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr) {
32381         LDKHTLCOutputInCommitment this_ptr_conv;
32382         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32383         this_ptr_conv.is_owned = false;
32384         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32385         LDKCOption_u32Z *ret_copy = MALLOC(sizeof(LDKCOption_u32Z), "LDKCOption_u32Z");
32386         *ret_copy = HTLCOutputInCommitment_get_transaction_output_index(&this_ptr_conv);
32387         uint64_t ret_ref = (uint64_t)ret_copy;
32388         return ret_ref;
32389 }
32390
32391 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1set_1transaction_1output_1index(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32392         LDKHTLCOutputInCommitment this_ptr_conv;
32393         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32394         this_ptr_conv.is_owned = false;
32395         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32396         void* val_ptr = (void*)(((uint64_t)val) & ~1);
32397         CHECK_ACCESS(val_ptr);
32398         LDKCOption_u32Z val_conv = *(LDKCOption_u32Z*)(val_ptr);
32399         val_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)val) & ~1));
32400         HTLCOutputInCommitment_set_transaction_output_index(&this_ptr_conv, val_conv);
32401 }
32402
32403 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) {
32404         LDKThirtyTwoBytes payment_hash_arg_ref;
32405         CHECK((*env)->GetArrayLength(env, payment_hash_arg) == 32);
32406         (*env)->GetByteArrayRegion(env, payment_hash_arg, 0, 32, payment_hash_arg_ref.data);
32407         void* transaction_output_index_arg_ptr = (void*)(((uint64_t)transaction_output_index_arg) & ~1);
32408         CHECK_ACCESS(transaction_output_index_arg_ptr);
32409         LDKCOption_u32Z transaction_output_index_arg_conv = *(LDKCOption_u32Z*)(transaction_output_index_arg_ptr);
32410         transaction_output_index_arg_conv = COption_u32Z_clone((LDKCOption_u32Z*)(((uint64_t)transaction_output_index_arg) & ~1));
32411         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_new(offered_arg, amount_msat_arg, cltv_expiry_arg, payment_hash_arg_ref, transaction_output_index_arg_conv);
32412         uint64_t ret_ref = 0;
32413         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32414         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32415         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32416         ret_ref = (uint64_t)ret_var.inner;
32417         if (ret_var.is_owned) {
32418                 ret_ref |= 1;
32419         }
32420         return ret_ref;
32421 }
32422
32423 static inline uint64_t HTLCOutputInCommitment_clone_ptr(LDKHTLCOutputInCommitment *NONNULL_PTR arg) {
32424         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(arg);
32425 uint64_t ret_ref = 0;
32426 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32427 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32428 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32429 ret_ref = (uint64_t)ret_var.inner;
32430 if (ret_var.is_owned) {
32431         ret_ref |= 1;
32432 }
32433         return ret_ref;
32434 }
32435 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32436         LDKHTLCOutputInCommitment arg_conv;
32437         arg_conv.inner = (void*)(arg & (~1));
32438         arg_conv.is_owned = false;
32439         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32440         int64_t ret_val = HTLCOutputInCommitment_clone_ptr(&arg_conv);
32441         return ret_val;
32442 }
32443
32444 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32445         LDKHTLCOutputInCommitment orig_conv;
32446         orig_conv.inner = (void*)(orig & (~1));
32447         orig_conv.is_owned = false;
32448         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32449         LDKHTLCOutputInCommitment ret_var = HTLCOutputInCommitment_clone(&orig_conv);
32450         uint64_t ret_ref = 0;
32451         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32452         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32453         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32454         ret_ref = (uint64_t)ret_var.inner;
32455         if (ret_var.is_owned) {
32456                 ret_ref |= 1;
32457         }
32458         return ret_ref;
32459 }
32460
32461 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1write(JNIEnv *env, jclass clz, int64_t obj) {
32462         LDKHTLCOutputInCommitment obj_conv;
32463         obj_conv.inner = (void*)(obj & (~1));
32464         obj_conv.is_owned = false;
32465         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32466         LDKCVec_u8Z ret_var = HTLCOutputInCommitment_write(&obj_conv);
32467         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32468         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32469         CVec_u8Z_free(ret_var);
32470         return ret_arr;
32471 }
32472
32473 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HTLCOutputInCommitment_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32474         LDKu8slice ser_ref;
32475         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32476         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32477         LDKCResult_HTLCOutputInCommitmentDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HTLCOutputInCommitmentDecodeErrorZ), "LDKCResult_HTLCOutputInCommitmentDecodeErrorZ");
32478         *ret_conv = HTLCOutputInCommitment_read(ser_ref);
32479         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32480         return (uint64_t)ret_conv;
32481 }
32482
32483 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_get_1htlc_1redeemscript(JNIEnv *env, jclass clz, int64_t htlc, int64_t keys) {
32484         LDKHTLCOutputInCommitment htlc_conv;
32485         htlc_conv.inner = (void*)(htlc & (~1));
32486         htlc_conv.is_owned = false;
32487         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
32488         LDKTxCreationKeys keys_conv;
32489         keys_conv.inner = (void*)(keys & (~1));
32490         keys_conv.is_owned = false;
32491         CHECK_INNER_FIELD_ACCESS_OR_NULL(keys_conv);
32492         LDKCVec_u8Z ret_var = get_htlc_redeemscript(&htlc_conv, &keys_conv);
32493         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32494         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32495         CVec_u8Z_free(ret_var);
32496         return ret_arr;
32497 }
32498
32499 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_make_1funding_1redeemscript(JNIEnv *env, jclass clz, int8_tArray broadcaster, int8_tArray countersignatory) {
32500         LDKPublicKey broadcaster_ref;
32501         CHECK((*env)->GetArrayLength(env, broadcaster) == 33);
32502         (*env)->GetByteArrayRegion(env, broadcaster, 0, 33, broadcaster_ref.compressed_form);
32503         LDKPublicKey countersignatory_ref;
32504         CHECK((*env)->GetArrayLength(env, countersignatory) == 33);
32505         (*env)->GetByteArrayRegion(env, countersignatory, 0, 33, countersignatory_ref.compressed_form);
32506         LDKCVec_u8Z ret_var = make_funding_redeemscript(broadcaster_ref, countersignatory_ref);
32507         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32508         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32509         CVec_u8Z_free(ret_var);
32510         return ret_arr;
32511 }
32512
32513 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) {
32514         unsigned char commitment_txid_arr[32];
32515         CHECK((*env)->GetArrayLength(env, commitment_txid) == 32);
32516         (*env)->GetByteArrayRegion(env, commitment_txid, 0, 32, commitment_txid_arr);
32517         unsigned char (*commitment_txid_ref)[32] = &commitment_txid_arr;
32518         LDKHTLCOutputInCommitment htlc_conv;
32519         htlc_conv.inner = (void*)(htlc & (~1));
32520         htlc_conv.is_owned = false;
32521         CHECK_INNER_FIELD_ACCESS_OR_NULL(htlc_conv);
32522         LDKPublicKey broadcaster_delayed_payment_key_ref;
32523         CHECK((*env)->GetArrayLength(env, broadcaster_delayed_payment_key) == 33);
32524         (*env)->GetByteArrayRegion(env, broadcaster_delayed_payment_key, 0, 33, broadcaster_delayed_payment_key_ref.compressed_form);
32525         LDKPublicKey revocation_key_ref;
32526         CHECK((*env)->GetArrayLength(env, revocation_key) == 33);
32527         (*env)->GetByteArrayRegion(env, revocation_key, 0, 33, revocation_key_ref.compressed_form);
32528         LDKTransaction ret_var = build_htlc_transaction(commitment_txid_ref, feerate_per_kw, contest_delay, &htlc_conv, broadcaster_delayed_payment_key_ref, revocation_key_ref);
32529         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32530         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32531         Transaction_free(ret_var);
32532         return ret_arr;
32533 }
32534
32535 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32536         LDKChannelTransactionParameters this_obj_conv;
32537         this_obj_conv.inner = (void*)(this_obj & (~1));
32538         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32539         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32540         ChannelTransactionParameters_free(this_obj_conv);
32541 }
32542
32543 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
32544         LDKChannelTransactionParameters this_ptr_conv;
32545         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32546         this_ptr_conv.is_owned = false;
32547         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32548         LDKChannelPublicKeys ret_var = ChannelTransactionParameters_get_holder_pubkeys(&this_ptr_conv);
32549         uint64_t ret_ref = 0;
32550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32553         ret_ref = (uint64_t)ret_var.inner;
32554         if (ret_var.is_owned) {
32555                 ret_ref |= 1;
32556         }
32557         return ret_ref;
32558 }
32559
32560 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1holder_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32561         LDKChannelTransactionParameters this_ptr_conv;
32562         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32563         this_ptr_conv.is_owned = false;
32564         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32565         LDKChannelPublicKeys val_conv;
32566         val_conv.inner = (void*)(val & (~1));
32567         val_conv.is_owned = (val & 1) || (val == 0);
32568         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32569         val_conv = ChannelPublicKeys_clone(&val_conv);
32570         ChannelTransactionParameters_set_holder_pubkeys(&this_ptr_conv, val_conv);
32571 }
32572
32573 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1holder_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32574         LDKChannelTransactionParameters this_ptr_conv;
32575         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32576         this_ptr_conv.is_owned = false;
32577         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32578         int16_t ret_val = ChannelTransactionParameters_get_holder_selected_contest_delay(&this_ptr_conv);
32579         return ret_val;
32580 }
32581
32582 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) {
32583         LDKChannelTransactionParameters this_ptr_conv;
32584         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32585         this_ptr_conv.is_owned = false;
32586         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32587         ChannelTransactionParameters_set_holder_selected_contest_delay(&this_ptr_conv, val);
32588 }
32589
32590 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr) {
32591         LDKChannelTransactionParameters this_ptr_conv;
32592         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32593         this_ptr_conv.is_owned = false;
32594         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32595         jboolean ret_val = ChannelTransactionParameters_get_is_outbound_from_holder(&this_ptr_conv);
32596         return ret_val;
32597 }
32598
32599 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1is_1outbound_1from_1holder(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
32600         LDKChannelTransactionParameters this_ptr_conv;
32601         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32602         this_ptr_conv.is_owned = false;
32603         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32604         ChannelTransactionParameters_set_is_outbound_from_holder(&this_ptr_conv, val);
32605 }
32606
32607 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr) {
32608         LDKChannelTransactionParameters this_ptr_conv;
32609         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32610         this_ptr_conv.is_owned = false;
32611         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32612         LDKCounterpartyChannelTransactionParameters ret_var = ChannelTransactionParameters_get_counterparty_parameters(&this_ptr_conv);
32613         uint64_t ret_ref = 0;
32614         if ((uint64_t)ret_var.inner > 4096) {
32615                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32616                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32617         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32618                 ret_ref = (uint64_t)ret_var.inner;
32619                 if (ret_var.is_owned) {
32620                         ret_ref |= 1;
32621                 }
32622         }
32623         return ret_ref;
32624 }
32625
32626 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1counterparty_1parameters(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32627         LDKChannelTransactionParameters this_ptr_conv;
32628         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32629         this_ptr_conv.is_owned = false;
32630         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32631         LDKCounterpartyChannelTransactionParameters val_conv;
32632         val_conv.inner = (void*)(val & (~1));
32633         val_conv.is_owned = (val & 1) || (val == 0);
32634         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32635         val_conv = CounterpartyChannelTransactionParameters_clone(&val_conv);
32636         ChannelTransactionParameters_set_counterparty_parameters(&this_ptr_conv, val_conv);
32637 }
32638
32639 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1get_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr) {
32640         LDKChannelTransactionParameters this_ptr_conv;
32641         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32642         this_ptr_conv.is_owned = false;
32643         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32644         LDKOutPoint ret_var = ChannelTransactionParameters_get_funding_outpoint(&this_ptr_conv);
32645         uint64_t ret_ref = 0;
32646         if ((uint64_t)ret_var.inner > 4096) {
32647                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32648                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32649         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32650                 ret_ref = (uint64_t)ret_var.inner;
32651                 if (ret_var.is_owned) {
32652                         ret_ref |= 1;
32653                 }
32654         }
32655         return ret_ref;
32656 }
32657
32658 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1set_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32659         LDKChannelTransactionParameters this_ptr_conv;
32660         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32661         this_ptr_conv.is_owned = false;
32662         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32663         LDKOutPoint val_conv;
32664         val_conv.inner = (void*)(val & (~1));
32665         val_conv.is_owned = (val & 1) || (val == 0);
32666         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32667         val_conv = OutPoint_clone(&val_conv);
32668         ChannelTransactionParameters_set_funding_outpoint(&this_ptr_conv, val_conv);
32669 }
32670
32671 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) {
32672         LDKChannelPublicKeys holder_pubkeys_arg_conv;
32673         holder_pubkeys_arg_conv.inner = (void*)(holder_pubkeys_arg & (~1));
32674         holder_pubkeys_arg_conv.is_owned = (holder_pubkeys_arg & 1) || (holder_pubkeys_arg == 0);
32675         CHECK_INNER_FIELD_ACCESS_OR_NULL(holder_pubkeys_arg_conv);
32676         holder_pubkeys_arg_conv = ChannelPublicKeys_clone(&holder_pubkeys_arg_conv);
32677         LDKCounterpartyChannelTransactionParameters counterparty_parameters_arg_conv;
32678         counterparty_parameters_arg_conv.inner = (void*)(counterparty_parameters_arg & (~1));
32679         counterparty_parameters_arg_conv.is_owned = (counterparty_parameters_arg & 1) || (counterparty_parameters_arg == 0);
32680         CHECK_INNER_FIELD_ACCESS_OR_NULL(counterparty_parameters_arg_conv);
32681         counterparty_parameters_arg_conv = CounterpartyChannelTransactionParameters_clone(&counterparty_parameters_arg_conv);
32682         LDKOutPoint funding_outpoint_arg_conv;
32683         funding_outpoint_arg_conv.inner = (void*)(funding_outpoint_arg & (~1));
32684         funding_outpoint_arg_conv.is_owned = (funding_outpoint_arg & 1) || (funding_outpoint_arg == 0);
32685         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_arg_conv);
32686         funding_outpoint_arg_conv = OutPoint_clone(&funding_outpoint_arg_conv);
32687         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);
32688         uint64_t ret_ref = 0;
32689         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32690         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32691         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32692         ret_ref = (uint64_t)ret_var.inner;
32693         if (ret_var.is_owned) {
32694                 ret_ref |= 1;
32695         }
32696         return ret_ref;
32697 }
32698
32699 static inline uint64_t ChannelTransactionParameters_clone_ptr(LDKChannelTransactionParameters *NONNULL_PTR arg) {
32700         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(arg);
32701 uint64_t ret_ref = 0;
32702 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32703 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32704 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32705 ret_ref = (uint64_t)ret_var.inner;
32706 if (ret_var.is_owned) {
32707         ret_ref |= 1;
32708 }
32709         return ret_ref;
32710 }
32711 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32712         LDKChannelTransactionParameters arg_conv;
32713         arg_conv.inner = (void*)(arg & (~1));
32714         arg_conv.is_owned = false;
32715         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32716         int64_t ret_val = ChannelTransactionParameters_clone_ptr(&arg_conv);
32717         return ret_val;
32718 }
32719
32720 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32721         LDKChannelTransactionParameters orig_conv;
32722         orig_conv.inner = (void*)(orig & (~1));
32723         orig_conv.is_owned = false;
32724         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32725         LDKChannelTransactionParameters ret_var = ChannelTransactionParameters_clone(&orig_conv);
32726         uint64_t ret_ref = 0;
32727         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32728         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32729         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32730         ret_ref = (uint64_t)ret_var.inner;
32731         if (ret_var.is_owned) {
32732                 ret_ref |= 1;
32733         }
32734         return ret_ref;
32735 }
32736
32737 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32738         LDKCounterpartyChannelTransactionParameters this_obj_conv;
32739         this_obj_conv.inner = (void*)(this_obj & (~1));
32740         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32741         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32742         CounterpartyChannelTransactionParameters_free(this_obj_conv);
32743 }
32744
32745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr) {
32746         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
32747         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32748         this_ptr_conv.is_owned = false;
32749         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32750         LDKChannelPublicKeys ret_var = CounterpartyChannelTransactionParameters_get_pubkeys(&this_ptr_conv);
32751         uint64_t ret_ref = 0;
32752         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32753         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32754         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32755         ret_ref = (uint64_t)ret_var.inner;
32756         if (ret_var.is_owned) {
32757                 ret_ref |= 1;
32758         }
32759         return ret_ref;
32760 }
32761
32762 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1pubkeys(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
32763         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
32764         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32765         this_ptr_conv.is_owned = false;
32766         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32767         LDKChannelPublicKeys val_conv;
32768         val_conv.inner = (void*)(val & (~1));
32769         val_conv.is_owned = (val & 1) || (val == 0);
32770         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
32771         val_conv = ChannelPublicKeys_clone(&val_conv);
32772         CounterpartyChannelTransactionParameters_set_pubkeys(&this_ptr_conv, val_conv);
32773 }
32774
32775 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1get_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr) {
32776         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
32777         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32778         this_ptr_conv.is_owned = false;
32779         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32780         int16_t ret_val = CounterpartyChannelTransactionParameters_get_selected_contest_delay(&this_ptr_conv);
32781         return ret_val;
32782 }
32783
32784 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1set_1selected_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
32785         LDKCounterpartyChannelTransactionParameters this_ptr_conv;
32786         this_ptr_conv.inner = (void*)(this_ptr & (~1));
32787         this_ptr_conv.is_owned = false;
32788         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
32789         CounterpartyChannelTransactionParameters_set_selected_contest_delay(&this_ptr_conv, val);
32790 }
32791
32792 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) {
32793         LDKChannelPublicKeys pubkeys_arg_conv;
32794         pubkeys_arg_conv.inner = (void*)(pubkeys_arg & (~1));
32795         pubkeys_arg_conv.is_owned = (pubkeys_arg & 1) || (pubkeys_arg == 0);
32796         CHECK_INNER_FIELD_ACCESS_OR_NULL(pubkeys_arg_conv);
32797         pubkeys_arg_conv = ChannelPublicKeys_clone(&pubkeys_arg_conv);
32798         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_new(pubkeys_arg_conv, selected_contest_delay_arg);
32799         uint64_t ret_ref = 0;
32800         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32801         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32802         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32803         ret_ref = (uint64_t)ret_var.inner;
32804         if (ret_var.is_owned) {
32805                 ret_ref |= 1;
32806         }
32807         return ret_ref;
32808 }
32809
32810 static inline uint64_t CounterpartyChannelTransactionParameters_clone_ptr(LDKCounterpartyChannelTransactionParameters *NONNULL_PTR arg) {
32811         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(arg);
32812 uint64_t ret_ref = 0;
32813 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32814 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32815 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32816 ret_ref = (uint64_t)ret_var.inner;
32817 if (ret_var.is_owned) {
32818         ret_ref |= 1;
32819 }
32820         return ret_ref;
32821 }
32822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
32823         LDKCounterpartyChannelTransactionParameters arg_conv;
32824         arg_conv.inner = (void*)(arg & (~1));
32825         arg_conv.is_owned = false;
32826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
32827         int64_t ret_val = CounterpartyChannelTransactionParameters_clone_ptr(&arg_conv);
32828         return ret_val;
32829 }
32830
32831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
32832         LDKCounterpartyChannelTransactionParameters orig_conv;
32833         orig_conv.inner = (void*)(orig & (~1));
32834         orig_conv.is_owned = false;
32835         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
32836         LDKCounterpartyChannelTransactionParameters ret_var = CounterpartyChannelTransactionParameters_clone(&orig_conv);
32837         uint64_t ret_ref = 0;
32838         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32839         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32841         ret_ref = (uint64_t)ret_var.inner;
32842         if (ret_var.is_owned) {
32843                 ret_ref |= 1;
32844         }
32845         return ret_ref;
32846 }
32847
32848 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1is_1populated(JNIEnv *env, jclass clz, int64_t this_arg) {
32849         LDKChannelTransactionParameters this_arg_conv;
32850         this_arg_conv.inner = (void*)(this_arg & (~1));
32851         this_arg_conv.is_owned = false;
32852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32853         jboolean ret_val = ChannelTransactionParameters_is_populated(&this_arg_conv);
32854         return ret_val;
32855 }
32856
32857 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1holder_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
32858         LDKChannelTransactionParameters this_arg_conv;
32859         this_arg_conv.inner = (void*)(this_arg & (~1));
32860         this_arg_conv.is_owned = false;
32861         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32862         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_holder_broadcastable(&this_arg_conv);
32863         uint64_t ret_ref = 0;
32864         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32865         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32866         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32867         ret_ref = (uint64_t)ret_var.inner;
32868         if (ret_var.is_owned) {
32869                 ret_ref |= 1;
32870         }
32871         return ret_ref;
32872 }
32873
32874 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1as_1counterparty_1broadcastable(JNIEnv *env, jclass clz, int64_t this_arg) {
32875         LDKChannelTransactionParameters this_arg_conv;
32876         this_arg_conv.inner = (void*)(this_arg & (~1));
32877         this_arg_conv.is_owned = false;
32878         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32879         LDKDirectedChannelTransactionParameters ret_var = ChannelTransactionParameters_as_counterparty_broadcastable(&this_arg_conv);
32880         uint64_t ret_ref = 0;
32881         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32882         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32883         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32884         ret_ref = (uint64_t)ret_var.inner;
32885         if (ret_var.is_owned) {
32886                 ret_ref |= 1;
32887         }
32888         return ret_ref;
32889 }
32890
32891 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
32892         LDKCounterpartyChannelTransactionParameters obj_conv;
32893         obj_conv.inner = (void*)(obj & (~1));
32894         obj_conv.is_owned = false;
32895         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32896         LDKCVec_u8Z ret_var = CounterpartyChannelTransactionParameters_write(&obj_conv);
32897         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32898         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32899         CVec_u8Z_free(ret_var);
32900         return ret_arr;
32901 }
32902
32903 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CounterpartyChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32904         LDKu8slice ser_ref;
32905         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32906         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32907         LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ), "LDKCResult_CounterpartyChannelTransactionParametersDecodeErrorZ");
32908         *ret_conv = CounterpartyChannelTransactionParameters_read(ser_ref);
32909         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32910         return (uint64_t)ret_conv;
32911 }
32912
32913 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
32914         LDKChannelTransactionParameters obj_conv;
32915         obj_conv.inner = (void*)(obj & (~1));
32916         obj_conv.is_owned = false;
32917         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
32918         LDKCVec_u8Z ret_var = ChannelTransactionParameters_write(&obj_conv);
32919         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
32920         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
32921         CVec_u8Z_free(ret_var);
32922         return ret_arr;
32923 }
32924
32925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelTransactionParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
32926         LDKu8slice ser_ref;
32927         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
32928         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
32929         LDKCResult_ChannelTransactionParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelTransactionParametersDecodeErrorZ), "LDKCResult_ChannelTransactionParametersDecodeErrorZ");
32930         *ret_conv = ChannelTransactionParameters_read(ser_ref);
32931         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
32932         return (uint64_t)ret_conv;
32933 }
32934
32935 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
32936         LDKDirectedChannelTransactionParameters this_obj_conv;
32937         this_obj_conv.inner = (void*)(this_obj & (~1));
32938         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
32939         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
32940         DirectedChannelTransactionParameters_free(this_obj_conv);
32941 }
32942
32943 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1broadcaster_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
32944         LDKDirectedChannelTransactionParameters this_arg_conv;
32945         this_arg_conv.inner = (void*)(this_arg & (~1));
32946         this_arg_conv.is_owned = false;
32947         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32948         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_broadcaster_pubkeys(&this_arg_conv);
32949         uint64_t ret_ref = 0;
32950         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32951         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32952         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32953         ret_ref = (uint64_t)ret_var.inner;
32954         if (ret_var.is_owned) {
32955                 ret_ref |= 1;
32956         }
32957         return ret_ref;
32958 }
32959
32960 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1countersignatory_1pubkeys(JNIEnv *env, jclass clz, int64_t this_arg) {
32961         LDKDirectedChannelTransactionParameters this_arg_conv;
32962         this_arg_conv.inner = (void*)(this_arg & (~1));
32963         this_arg_conv.is_owned = false;
32964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32965         LDKChannelPublicKeys ret_var = DirectedChannelTransactionParameters_countersignatory_pubkeys(&this_arg_conv);
32966         uint64_t ret_ref = 0;
32967         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
32968         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
32969         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
32970         ret_ref = (uint64_t)ret_var.inner;
32971         if (ret_var.is_owned) {
32972                 ret_ref |= 1;
32973         }
32974         return ret_ref;
32975 }
32976
32977 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1contest_1delay(JNIEnv *env, jclass clz, int64_t this_arg) {
32978         LDKDirectedChannelTransactionParameters this_arg_conv;
32979         this_arg_conv.inner = (void*)(this_arg & (~1));
32980         this_arg_conv.is_owned = false;
32981         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32982         int16_t ret_val = DirectedChannelTransactionParameters_contest_delay(&this_arg_conv);
32983         return ret_val;
32984 }
32985
32986 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1is_1outbound(JNIEnv *env, jclass clz, int64_t this_arg) {
32987         LDKDirectedChannelTransactionParameters this_arg_conv;
32988         this_arg_conv.inner = (void*)(this_arg & (~1));
32989         this_arg_conv.is_owned = false;
32990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
32991         jboolean ret_val = DirectedChannelTransactionParameters_is_outbound(&this_arg_conv);
32992         return ret_val;
32993 }
32994
32995 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectedChannelTransactionParameters_1funding_1outpoint(JNIEnv *env, jclass clz, int64_t this_arg) {
32996         LDKDirectedChannelTransactionParameters this_arg_conv;
32997         this_arg_conv.inner = (void*)(this_arg & (~1));
32998         this_arg_conv.is_owned = false;
32999         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33000         LDKOutPoint ret_var = DirectedChannelTransactionParameters_funding_outpoint(&this_arg_conv);
33001         uint64_t ret_ref = 0;
33002         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33003         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33004         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33005         ret_ref = (uint64_t)ret_var.inner;
33006         if (ret_var.is_owned) {
33007                 ret_ref |= 1;
33008         }
33009         return ret_ref;
33010 }
33011
33012 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33013         LDKHolderCommitmentTransaction this_obj_conv;
33014         this_obj_conv.inner = (void*)(this_obj & (~1));
33015         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33016         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33017         HolderCommitmentTransaction_free(this_obj_conv);
33018 }
33019
33020 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1get_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr) {
33021         LDKHolderCommitmentTransaction this_ptr_conv;
33022         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33023         this_ptr_conv.is_owned = false;
33024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33025         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33026         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, HolderCommitmentTransaction_get_counterparty_sig(&this_ptr_conv).compact_form);
33027         return ret_arr;
33028 }
33029
33030 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1sig(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33031         LDKHolderCommitmentTransaction this_ptr_conv;
33032         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33033         this_ptr_conv.is_owned = false;
33034         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33035         LDKSignature val_ref;
33036         CHECK((*env)->GetArrayLength(env, val) == 64);
33037         (*env)->GetByteArrayRegion(env, val, 0, 64, val_ref.compact_form);
33038         HolderCommitmentTransaction_set_counterparty_sig(&this_ptr_conv, val_ref);
33039 }
33040
33041 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1set_1counterparty_1htlc_1sigs(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
33042         LDKHolderCommitmentTransaction this_ptr_conv;
33043         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33044         this_ptr_conv.is_owned = false;
33045         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33046         LDKCVec_SignatureZ val_constr;
33047         val_constr.datalen = (*env)->GetArrayLength(env, val);
33048         if (val_constr.datalen > 0)
33049                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33050         else
33051                 val_constr.data = NULL;
33052         for (size_t i = 0; i < val_constr.datalen; i++) {
33053                 int8_tArray val_conv_8 = (*env)->GetObjectArrayElement(env, val, i);
33054                 LDKSignature val_conv_8_ref;
33055                 CHECK((*env)->GetArrayLength(env, val_conv_8) == 64);
33056                 (*env)->GetByteArrayRegion(env, val_conv_8, 0, 64, val_conv_8_ref.compact_form);
33057                 val_constr.data[i] = val_conv_8_ref;
33058         }
33059         HolderCommitmentTransaction_set_counterparty_htlc_sigs(&this_ptr_conv, val_constr);
33060 }
33061
33062 static inline uint64_t HolderCommitmentTransaction_clone_ptr(LDKHolderCommitmentTransaction *NONNULL_PTR arg) {
33063         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(arg);
33064 uint64_t ret_ref = 0;
33065 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33066 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33067 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33068 ret_ref = (uint64_t)ret_var.inner;
33069 if (ret_var.is_owned) {
33070         ret_ref |= 1;
33071 }
33072         return ret_ref;
33073 }
33074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33075         LDKHolderCommitmentTransaction arg_conv;
33076         arg_conv.inner = (void*)(arg & (~1));
33077         arg_conv.is_owned = false;
33078         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33079         int64_t ret_val = HolderCommitmentTransaction_clone_ptr(&arg_conv);
33080         return ret_val;
33081 }
33082
33083 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33084         LDKHolderCommitmentTransaction orig_conv;
33085         orig_conv.inner = (void*)(orig & (~1));
33086         orig_conv.is_owned = false;
33087         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33088         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_clone(&orig_conv);
33089         uint64_t ret_ref = 0;
33090         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33091         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33092         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33093         ret_ref = (uint64_t)ret_var.inner;
33094         if (ret_var.is_owned) {
33095                 ret_ref |= 1;
33096         }
33097         return ret_ref;
33098 }
33099
33100 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
33101         LDKHolderCommitmentTransaction obj_conv;
33102         obj_conv.inner = (void*)(obj & (~1));
33103         obj_conv.is_owned = false;
33104         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33105         LDKCVec_u8Z ret_var = HolderCommitmentTransaction_write(&obj_conv);
33106         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33107         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33108         CVec_u8Z_free(ret_var);
33109         return ret_arr;
33110 }
33111
33112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_HolderCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33113         LDKu8slice ser_ref;
33114         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33115         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33116         LDKCResult_HolderCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_HolderCommitmentTransactionDecodeErrorZ), "LDKCResult_HolderCommitmentTransactionDecodeErrorZ");
33117         *ret_conv = HolderCommitmentTransaction_read(ser_ref);
33118         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33119         return (uint64_t)ret_conv;
33120 }
33121
33122 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) {
33123         LDKCommitmentTransaction commitment_tx_conv;
33124         commitment_tx_conv.inner = (void*)(commitment_tx & (~1));
33125         commitment_tx_conv.is_owned = (commitment_tx & 1) || (commitment_tx == 0);
33126         CHECK_INNER_FIELD_ACCESS_OR_NULL(commitment_tx_conv);
33127         commitment_tx_conv = CommitmentTransaction_clone(&commitment_tx_conv);
33128         LDKSignature counterparty_sig_ref;
33129         CHECK((*env)->GetArrayLength(env, counterparty_sig) == 64);
33130         (*env)->GetByteArrayRegion(env, counterparty_sig, 0, 64, counterparty_sig_ref.compact_form);
33131         LDKCVec_SignatureZ counterparty_htlc_sigs_constr;
33132         counterparty_htlc_sigs_constr.datalen = (*env)->GetArrayLength(env, counterparty_htlc_sigs);
33133         if (counterparty_htlc_sigs_constr.datalen > 0)
33134                 counterparty_htlc_sigs_constr.data = MALLOC(counterparty_htlc_sigs_constr.datalen * sizeof(LDKSignature), "LDKCVec_SignatureZ Elements");
33135         else
33136                 counterparty_htlc_sigs_constr.data = NULL;
33137         for (size_t i = 0; i < counterparty_htlc_sigs_constr.datalen; i++) {
33138                 int8_tArray counterparty_htlc_sigs_conv_8 = (*env)->GetObjectArrayElement(env, counterparty_htlc_sigs, i);
33139                 LDKSignature counterparty_htlc_sigs_conv_8_ref;
33140                 CHECK((*env)->GetArrayLength(env, counterparty_htlc_sigs_conv_8) == 64);
33141                 (*env)->GetByteArrayRegion(env, counterparty_htlc_sigs_conv_8, 0, 64, counterparty_htlc_sigs_conv_8_ref.compact_form);
33142                 counterparty_htlc_sigs_constr.data[i] = counterparty_htlc_sigs_conv_8_ref;
33143         }
33144         LDKPublicKey holder_funding_key_ref;
33145         CHECK((*env)->GetArrayLength(env, holder_funding_key) == 33);
33146         (*env)->GetByteArrayRegion(env, holder_funding_key, 0, 33, holder_funding_key_ref.compressed_form);
33147         LDKPublicKey counterparty_funding_key_ref;
33148         CHECK((*env)->GetArrayLength(env, counterparty_funding_key) == 33);
33149         (*env)->GetByteArrayRegion(env, counterparty_funding_key, 0, 33, counterparty_funding_key_ref.compressed_form);
33150         LDKHolderCommitmentTransaction ret_var = HolderCommitmentTransaction_new(commitment_tx_conv, counterparty_sig_ref, counterparty_htlc_sigs_constr, holder_funding_key_ref, counterparty_funding_key_ref);
33151         uint64_t ret_ref = 0;
33152         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33153         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33154         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33155         ret_ref = (uint64_t)ret_var.inner;
33156         if (ret_var.is_owned) {
33157                 ret_ref |= 1;
33158         }
33159         return ret_ref;
33160 }
33161
33162 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33163         LDKBuiltCommitmentTransaction this_obj_conv;
33164         this_obj_conv.inner = (void*)(this_obj & (~1));
33165         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33166         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33167         BuiltCommitmentTransaction_free(this_obj_conv);
33168 }
33169
33170 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr) {
33171         LDKBuiltCommitmentTransaction this_ptr_conv;
33172         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33173         this_ptr_conv.is_owned = false;
33174         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33175         LDKTransaction ret_var = BuiltCommitmentTransaction_get_transaction(&this_ptr_conv);
33176         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33177         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33178         Transaction_free(ret_var);
33179         return ret_arr;
33180 }
33181
33182 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1transaction(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33183         LDKBuiltCommitmentTransaction this_ptr_conv;
33184         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33185         this_ptr_conv.is_owned = false;
33186         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33187         LDKTransaction val_ref;
33188         val_ref.datalen = (*env)->GetArrayLength(env, val);
33189         val_ref.data = MALLOC(val_ref.datalen, "LDKTransaction Bytes");
33190         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
33191         val_ref.data_is_owned = true;
33192         BuiltCommitmentTransaction_set_transaction(&this_ptr_conv, val_ref);
33193 }
33194
33195 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1get_1txid(JNIEnv *env, jclass clz, int64_t this_ptr) {
33196         LDKBuiltCommitmentTransaction this_ptr_conv;
33197         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33198         this_ptr_conv.is_owned = false;
33199         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33200         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33201         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *BuiltCommitmentTransaction_get_txid(&this_ptr_conv));
33202         return ret_arr;
33203 }
33204
33205 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1set_1txid(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
33206         LDKBuiltCommitmentTransaction this_ptr_conv;
33207         this_ptr_conv.inner = (void*)(this_ptr & (~1));
33208         this_ptr_conv.is_owned = false;
33209         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
33210         LDKThirtyTwoBytes val_ref;
33211         CHECK((*env)->GetArrayLength(env, val) == 32);
33212         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
33213         BuiltCommitmentTransaction_set_txid(&this_ptr_conv, val_ref);
33214 }
33215
33216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1new(JNIEnv *env, jclass clz, int8_tArray transaction_arg, int8_tArray txid_arg) {
33217         LDKTransaction transaction_arg_ref;
33218         transaction_arg_ref.datalen = (*env)->GetArrayLength(env, transaction_arg);
33219         transaction_arg_ref.data = MALLOC(transaction_arg_ref.datalen, "LDKTransaction Bytes");
33220         (*env)->GetByteArrayRegion(env, transaction_arg, 0, transaction_arg_ref.datalen, transaction_arg_ref.data);
33221         transaction_arg_ref.data_is_owned = true;
33222         LDKThirtyTwoBytes txid_arg_ref;
33223         CHECK((*env)->GetArrayLength(env, txid_arg) == 32);
33224         (*env)->GetByteArrayRegion(env, txid_arg, 0, 32, txid_arg_ref.data);
33225         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_new(transaction_arg_ref, txid_arg_ref);
33226         uint64_t ret_ref = 0;
33227         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33228         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33229         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33230         ret_ref = (uint64_t)ret_var.inner;
33231         if (ret_var.is_owned) {
33232                 ret_ref |= 1;
33233         }
33234         return ret_ref;
33235 }
33236
33237 static inline uint64_t BuiltCommitmentTransaction_clone_ptr(LDKBuiltCommitmentTransaction *NONNULL_PTR arg) {
33238         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(arg);
33239 uint64_t ret_ref = 0;
33240 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33241 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33242 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33243 ret_ref = (uint64_t)ret_var.inner;
33244 if (ret_var.is_owned) {
33245         ret_ref |= 1;
33246 }
33247         return ret_ref;
33248 }
33249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33250         LDKBuiltCommitmentTransaction arg_conv;
33251         arg_conv.inner = (void*)(arg & (~1));
33252         arg_conv.is_owned = false;
33253         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33254         int64_t ret_val = BuiltCommitmentTransaction_clone_ptr(&arg_conv);
33255         return ret_val;
33256 }
33257
33258 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33259         LDKBuiltCommitmentTransaction orig_conv;
33260         orig_conv.inner = (void*)(orig & (~1));
33261         orig_conv.is_owned = false;
33262         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33263         LDKBuiltCommitmentTransaction ret_var = BuiltCommitmentTransaction_clone(&orig_conv);
33264         uint64_t ret_ref = 0;
33265         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33266         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33267         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33268         ret_ref = (uint64_t)ret_var.inner;
33269         if (ret_var.is_owned) {
33270                 ret_ref |= 1;
33271         }
33272         return ret_ref;
33273 }
33274
33275 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
33276         LDKBuiltCommitmentTransaction obj_conv;
33277         obj_conv.inner = (void*)(obj & (~1));
33278         obj_conv.is_owned = false;
33279         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33280         LDKCVec_u8Z ret_var = BuiltCommitmentTransaction_write(&obj_conv);
33281         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33282         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33283         CVec_u8Z_free(ret_var);
33284         return ret_arr;
33285 }
33286
33287 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BuiltCommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33288         LDKu8slice ser_ref;
33289         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33290         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33291         LDKCResult_BuiltCommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_BuiltCommitmentTransactionDecodeErrorZ), "LDKCResult_BuiltCommitmentTransactionDecodeErrorZ");
33292         *ret_conv = BuiltCommitmentTransaction_read(ser_ref);
33293         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33294         return (uint64_t)ret_conv;
33295 }
33296
33297 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) {
33298         LDKBuiltCommitmentTransaction this_arg_conv;
33299         this_arg_conv.inner = (void*)(this_arg & (~1));
33300         this_arg_conv.is_owned = false;
33301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33302         LDKu8slice funding_redeemscript_ref;
33303         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
33304         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
33305         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33306         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, BuiltCommitmentTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
33307         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
33308         return ret_arr;
33309 }
33310
33311 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) {
33312         LDKBuiltCommitmentTransaction this_arg_conv;
33313         this_arg_conv.inner = (void*)(this_arg & (~1));
33314         this_arg_conv.is_owned = false;
33315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33316         unsigned char funding_key_arr[32];
33317         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
33318         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
33319         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
33320         LDKu8slice funding_redeemscript_ref;
33321         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
33322         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
33323         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33324         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, BuiltCommitmentTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
33325         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
33326         return ret_arr;
33327 }
33328
33329 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33330         LDKClosingTransaction this_obj_conv;
33331         this_obj_conv.inner = (void*)(this_obj & (~1));
33332         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33333         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33334         ClosingTransaction_free(this_obj_conv);
33335 }
33336
33337 static inline uint64_t ClosingTransaction_clone_ptr(LDKClosingTransaction *NONNULL_PTR arg) {
33338         LDKClosingTransaction ret_var = ClosingTransaction_clone(arg);
33339 uint64_t ret_ref = 0;
33340 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33341 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33342 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33343 ret_ref = (uint64_t)ret_var.inner;
33344 if (ret_var.is_owned) {
33345         ret_ref |= 1;
33346 }
33347         return ret_ref;
33348 }
33349 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33350         LDKClosingTransaction arg_conv;
33351         arg_conv.inner = (void*)(arg & (~1));
33352         arg_conv.is_owned = false;
33353         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33354         int64_t ret_val = ClosingTransaction_clone_ptr(&arg_conv);
33355         return ret_val;
33356 }
33357
33358 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33359         LDKClosingTransaction orig_conv;
33360         orig_conv.inner = (void*)(orig & (~1));
33361         orig_conv.is_owned = false;
33362         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33363         LDKClosingTransaction ret_var = ClosingTransaction_clone(&orig_conv);
33364         uint64_t ret_ref = 0;
33365         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33366         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33367         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33368         ret_ref = (uint64_t)ret_var.inner;
33369         if (ret_var.is_owned) {
33370                 ret_ref |= 1;
33371         }
33372         return ret_ref;
33373 }
33374
33375 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1hash(JNIEnv *env, jclass clz, int64_t o) {
33376         LDKClosingTransaction o_conv;
33377         o_conv.inner = (void*)(o & (~1));
33378         o_conv.is_owned = false;
33379         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
33380         int64_t ret_val = ClosingTransaction_hash(&o_conv);
33381         return ret_val;
33382 }
33383
33384 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) {
33385         LDKCVec_u8Z to_holder_script_ref;
33386         to_holder_script_ref.datalen = (*env)->GetArrayLength(env, to_holder_script);
33387         to_holder_script_ref.data = MALLOC(to_holder_script_ref.datalen, "LDKCVec_u8Z Bytes");
33388         (*env)->GetByteArrayRegion(env, to_holder_script, 0, to_holder_script_ref.datalen, to_holder_script_ref.data);
33389         LDKCVec_u8Z to_counterparty_script_ref;
33390         to_counterparty_script_ref.datalen = (*env)->GetArrayLength(env, to_counterparty_script);
33391         to_counterparty_script_ref.data = MALLOC(to_counterparty_script_ref.datalen, "LDKCVec_u8Z Bytes");
33392         (*env)->GetByteArrayRegion(env, to_counterparty_script, 0, to_counterparty_script_ref.datalen, to_counterparty_script_ref.data);
33393         LDKOutPoint funding_outpoint_conv;
33394         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
33395         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
33396         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
33397         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
33398         LDKClosingTransaction ret_var = ClosingTransaction_new(to_holder_value_sat, to_counterparty_value_sat, to_holder_script_ref, to_counterparty_script_ref, funding_outpoint_conv);
33399         uint64_t ret_ref = 0;
33400         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33401         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33402         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33403         ret_ref = (uint64_t)ret_var.inner;
33404         if (ret_var.is_owned) {
33405                 ret_ref |= 1;
33406         }
33407         return ret_ref;
33408 }
33409
33410 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
33411         LDKClosingTransaction this_arg_conv;
33412         this_arg_conv.inner = (void*)(this_arg & (~1));
33413         this_arg_conv.is_owned = false;
33414         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33415         LDKTrustedClosingTransaction ret_var = ClosingTransaction_trust(&this_arg_conv);
33416         uint64_t ret_ref = 0;
33417         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33418         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33419         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33420         ret_ref = (uint64_t)ret_var.inner;
33421         if (ret_var.is_owned) {
33422                 ret_ref |= 1;
33423         }
33424         return ret_ref;
33425 }
33426
33427 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1verify(JNIEnv *env, jclass clz, int64_t this_arg, int64_t funding_outpoint) {
33428         LDKClosingTransaction this_arg_conv;
33429         this_arg_conv.inner = (void*)(this_arg & (~1));
33430         this_arg_conv.is_owned = false;
33431         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33432         LDKOutPoint funding_outpoint_conv;
33433         funding_outpoint_conv.inner = (void*)(funding_outpoint & (~1));
33434         funding_outpoint_conv.is_owned = (funding_outpoint & 1) || (funding_outpoint == 0);
33435         CHECK_INNER_FIELD_ACCESS_OR_NULL(funding_outpoint_conv);
33436         funding_outpoint_conv = OutPoint_clone(&funding_outpoint_conv);
33437         LDKCResult_TrustedClosingTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedClosingTransactionNoneZ), "LDKCResult_TrustedClosingTransactionNoneZ");
33438         *ret_conv = ClosingTransaction_verify(&this_arg_conv, funding_outpoint_conv);
33439         return (uint64_t)ret_conv;
33440 }
33441
33442 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
33443         LDKClosingTransaction this_arg_conv;
33444         this_arg_conv.inner = (void*)(this_arg & (~1));
33445         this_arg_conv.is_owned = false;
33446         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33447         int64_t ret_val = ClosingTransaction_to_holder_value_sat(&this_arg_conv);
33448         return ret_val;
33449 }
33450
33451 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
33452         LDKClosingTransaction this_arg_conv;
33453         this_arg_conv.inner = (void*)(this_arg & (~1));
33454         this_arg_conv.is_owned = false;
33455         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33456         int64_t ret_val = ClosingTransaction_to_counterparty_value_sat(&this_arg_conv);
33457         return ret_val;
33458 }
33459
33460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1holder_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
33461         LDKClosingTransaction this_arg_conv;
33462         this_arg_conv.inner = (void*)(this_arg & (~1));
33463         this_arg_conv.is_owned = false;
33464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33465         LDKu8slice ret_var = ClosingTransaction_to_holder_script(&this_arg_conv);
33466         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33467         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33468         return ret_arr;
33469 }
33470
33471 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ClosingTransaction_1to_1counterparty_1script(JNIEnv *env, jclass clz, int64_t this_arg) {
33472         LDKClosingTransaction this_arg_conv;
33473         this_arg_conv.inner = (void*)(this_arg & (~1));
33474         this_arg_conv.is_owned = false;
33475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33476         LDKu8slice ret_var = ClosingTransaction_to_counterparty_script(&this_arg_conv);
33477         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33478         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33479         return ret_arr;
33480 }
33481
33482 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33483         LDKTrustedClosingTransaction this_obj_conv;
33484         this_obj_conv.inner = (void*)(this_obj & (~1));
33485         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33486         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33487         TrustedClosingTransaction_free(this_obj_conv);
33488 }
33489
33490 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedClosingTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
33491         LDKTrustedClosingTransaction this_arg_conv;
33492         this_arg_conv.inner = (void*)(this_arg & (~1));
33493         this_arg_conv.is_owned = false;
33494         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33495         LDKTransaction ret_var = TrustedClosingTransaction_built_transaction(&this_arg_conv);
33496         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33497         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33498         Transaction_free(ret_var);
33499         return ret_arr;
33500 }
33501
33502 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) {
33503         LDKTrustedClosingTransaction this_arg_conv;
33504         this_arg_conv.inner = (void*)(this_arg & (~1));
33505         this_arg_conv.is_owned = false;
33506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33507         LDKu8slice funding_redeemscript_ref;
33508         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
33509         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
33510         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33511         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedClosingTransaction_get_sighash_all(&this_arg_conv, funding_redeemscript_ref, channel_value_satoshis).data);
33512         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
33513         return ret_arr;
33514 }
33515
33516 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) {
33517         LDKTrustedClosingTransaction this_arg_conv;
33518         this_arg_conv.inner = (void*)(this_arg & (~1));
33519         this_arg_conv.is_owned = false;
33520         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33521         unsigned char funding_key_arr[32];
33522         CHECK((*env)->GetArrayLength(env, funding_key) == 32);
33523         (*env)->GetByteArrayRegion(env, funding_key, 0, 32, funding_key_arr);
33524         unsigned char (*funding_key_ref)[32] = &funding_key_arr;
33525         LDKu8slice funding_redeemscript_ref;
33526         funding_redeemscript_ref.datalen = (*env)->GetArrayLength(env, funding_redeemscript);
33527         funding_redeemscript_ref.data = (*env)->GetByteArrayElements (env, funding_redeemscript, NULL);
33528         int8_tArray ret_arr = (*env)->NewByteArray(env, 64);
33529         (*env)->SetByteArrayRegion(env, ret_arr, 0, 64, TrustedClosingTransaction_sign(&this_arg_conv, funding_key_ref, funding_redeemscript_ref, channel_value_satoshis).compact_form);
33530         (*env)->ReleaseByteArrayElements(env, funding_redeemscript, (int8_t*)funding_redeemscript_ref.data, 0);
33531         return ret_arr;
33532 }
33533
33534 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33535         LDKCommitmentTransaction this_obj_conv;
33536         this_obj_conv.inner = (void*)(this_obj & (~1));
33537         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33538         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33539         CommitmentTransaction_free(this_obj_conv);
33540 }
33541
33542 static inline uint64_t CommitmentTransaction_clone_ptr(LDKCommitmentTransaction *NONNULL_PTR arg) {
33543         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(arg);
33544 uint64_t ret_ref = 0;
33545 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33546 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33547 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33548 ret_ref = (uint64_t)ret_var.inner;
33549 if (ret_var.is_owned) {
33550         ret_ref |= 1;
33551 }
33552         return ret_ref;
33553 }
33554 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33555         LDKCommitmentTransaction arg_conv;
33556         arg_conv.inner = (void*)(arg & (~1));
33557         arg_conv.is_owned = false;
33558         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33559         int64_t ret_val = CommitmentTransaction_clone_ptr(&arg_conv);
33560         return ret_val;
33561 }
33562
33563 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33564         LDKCommitmentTransaction orig_conv;
33565         orig_conv.inner = (void*)(orig & (~1));
33566         orig_conv.is_owned = false;
33567         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33568         LDKCommitmentTransaction ret_var = CommitmentTransaction_clone(&orig_conv);
33569         uint64_t ret_ref = 0;
33570         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33571         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33572         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33573         ret_ref = (uint64_t)ret_var.inner;
33574         if (ret_var.is_owned) {
33575                 ret_ref |= 1;
33576         }
33577         return ret_ref;
33578 }
33579
33580 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1write(JNIEnv *env, jclass clz, int64_t obj) {
33581         LDKCommitmentTransaction obj_conv;
33582         obj_conv.inner = (void*)(obj & (~1));
33583         obj_conv.is_owned = false;
33584         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
33585         LDKCVec_u8Z ret_var = CommitmentTransaction_write(&obj_conv);
33586         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
33587         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
33588         CVec_u8Z_free(ret_var);
33589         return ret_arr;
33590 }
33591
33592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
33593         LDKu8slice ser_ref;
33594         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
33595         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
33596         LDKCResult_CommitmentTransactionDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CommitmentTransactionDecodeErrorZ), "LDKCResult_CommitmentTransactionDecodeErrorZ");
33597         *ret_conv = CommitmentTransaction_read(ser_ref);
33598         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
33599         return (uint64_t)ret_conv;
33600 }
33601
33602 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1commitment_1number(JNIEnv *env, jclass clz, int64_t this_arg) {
33603         LDKCommitmentTransaction this_arg_conv;
33604         this_arg_conv.inner = (void*)(this_arg & (~1));
33605         this_arg_conv.is_owned = false;
33606         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33607         int64_t ret_val = CommitmentTransaction_commitment_number(&this_arg_conv);
33608         return ret_val;
33609 }
33610
33611 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1broadcaster_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
33612         LDKCommitmentTransaction this_arg_conv;
33613         this_arg_conv.inner = (void*)(this_arg & (~1));
33614         this_arg_conv.is_owned = false;
33615         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33616         int64_t ret_val = CommitmentTransaction_to_broadcaster_value_sat(&this_arg_conv);
33617         return ret_val;
33618 }
33619
33620 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1to_1countersignatory_1value_1sat(JNIEnv *env, jclass clz, int64_t this_arg) {
33621         LDKCommitmentTransaction this_arg_conv;
33622         this_arg_conv.inner = (void*)(this_arg & (~1));
33623         this_arg_conv.is_owned = false;
33624         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33625         int64_t ret_val = CommitmentTransaction_to_countersignatory_value_sat(&this_arg_conv);
33626         return ret_val;
33627 }
33628
33629 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1feerate_1per_1kw(JNIEnv *env, jclass clz, int64_t this_arg) {
33630         LDKCommitmentTransaction this_arg_conv;
33631         this_arg_conv.inner = (void*)(this_arg & (~1));
33632         this_arg_conv.is_owned = false;
33633         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33634         int32_t ret_val = CommitmentTransaction_feerate_per_kw(&this_arg_conv);
33635         return ret_val;
33636 }
33637
33638 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_CommitmentTransaction_1trust(JNIEnv *env, jclass clz, int64_t this_arg) {
33639         LDKCommitmentTransaction this_arg_conv;
33640         this_arg_conv.inner = (void*)(this_arg & (~1));
33641         this_arg_conv.is_owned = false;
33642         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33643         LDKTrustedCommitmentTransaction ret_var = CommitmentTransaction_trust(&this_arg_conv);
33644         uint64_t ret_ref = 0;
33645         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33646         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33647         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33648         ret_ref = (uint64_t)ret_var.inner;
33649         if (ret_var.is_owned) {
33650                 ret_ref |= 1;
33651         }
33652         return ret_ref;
33653 }
33654
33655 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) {
33656         LDKCommitmentTransaction this_arg_conv;
33657         this_arg_conv.inner = (void*)(this_arg & (~1));
33658         this_arg_conv.is_owned = false;
33659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33660         LDKDirectedChannelTransactionParameters channel_parameters_conv;
33661         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
33662         channel_parameters_conv.is_owned = false;
33663         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
33664         LDKChannelPublicKeys broadcaster_keys_conv;
33665         broadcaster_keys_conv.inner = (void*)(broadcaster_keys & (~1));
33666         broadcaster_keys_conv.is_owned = false;
33667         CHECK_INNER_FIELD_ACCESS_OR_NULL(broadcaster_keys_conv);
33668         LDKChannelPublicKeys countersignatory_keys_conv;
33669         countersignatory_keys_conv.inner = (void*)(countersignatory_keys & (~1));
33670         countersignatory_keys_conv.is_owned = false;
33671         CHECK_INNER_FIELD_ACCESS_OR_NULL(countersignatory_keys_conv);
33672         LDKCResult_TrustedCommitmentTransactionNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_TrustedCommitmentTransactionNoneZ), "LDKCResult_TrustedCommitmentTransactionNoneZ");
33673         *ret_conv = CommitmentTransaction_verify(&this_arg_conv, &channel_parameters_conv, &broadcaster_keys_conv, &countersignatory_keys_conv);
33674         return (uint64_t)ret_conv;
33675 }
33676
33677 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33678         LDKTrustedCommitmentTransaction this_obj_conv;
33679         this_obj_conv.inner = (void*)(this_obj & (~1));
33680         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33681         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33682         TrustedCommitmentTransaction_free(this_obj_conv);
33683 }
33684
33685 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1txid(JNIEnv *env, jclass clz, int64_t this_arg) {
33686         LDKTrustedCommitmentTransaction this_arg_conv;
33687         this_arg_conv.inner = (void*)(this_arg & (~1));
33688         this_arg_conv.is_owned = false;
33689         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33690         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
33691         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, TrustedCommitmentTransaction_txid(&this_arg_conv).data);
33692         return ret_arr;
33693 }
33694
33695 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1built_1transaction(JNIEnv *env, jclass clz, int64_t this_arg) {
33696         LDKTrustedCommitmentTransaction this_arg_conv;
33697         this_arg_conv.inner = (void*)(this_arg & (~1));
33698         this_arg_conv.is_owned = false;
33699         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33700         LDKBuiltCommitmentTransaction ret_var = TrustedCommitmentTransaction_built_transaction(&this_arg_conv);
33701         uint64_t ret_ref = 0;
33702         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33703         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33704         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33705         ret_ref = (uint64_t)ret_var.inner;
33706         if (ret_var.is_owned) {
33707                 ret_ref |= 1;
33708         }
33709         return ret_ref;
33710 }
33711
33712 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_TrustedCommitmentTransaction_1keys(JNIEnv *env, jclass clz, int64_t this_arg) {
33713         LDKTrustedCommitmentTransaction this_arg_conv;
33714         this_arg_conv.inner = (void*)(this_arg & (~1));
33715         this_arg_conv.is_owned = false;
33716         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33717         LDKTxCreationKeys ret_var = TrustedCommitmentTransaction_keys(&this_arg_conv);
33718         uint64_t ret_ref = 0;
33719         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33720         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33721         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33722         ret_ref = (uint64_t)ret_var.inner;
33723         if (ret_var.is_owned) {
33724                 ret_ref |= 1;
33725         }
33726         return ret_ref;
33727 }
33728
33729 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) {
33730         LDKTrustedCommitmentTransaction this_arg_conv;
33731         this_arg_conv.inner = (void*)(this_arg & (~1));
33732         this_arg_conv.is_owned = false;
33733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
33734         unsigned char htlc_base_key_arr[32];
33735         CHECK((*env)->GetArrayLength(env, htlc_base_key) == 32);
33736         (*env)->GetByteArrayRegion(env, htlc_base_key, 0, 32, htlc_base_key_arr);
33737         unsigned char (*htlc_base_key_ref)[32] = &htlc_base_key_arr;
33738         LDKDirectedChannelTransactionParameters channel_parameters_conv;
33739         channel_parameters_conv.inner = (void*)(channel_parameters & (~1));
33740         channel_parameters_conv.is_owned = false;
33741         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_parameters_conv);
33742         LDKCResult_CVec_SignatureZNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_SignatureZNoneZ), "LDKCResult_CVec_SignatureZNoneZ");
33743         *ret_conv = TrustedCommitmentTransaction_get_htlc_sigs(&this_arg_conv, htlc_base_key_ref, &channel_parameters_conv);
33744         return (uint64_t)ret_conv;
33745 }
33746
33747 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) {
33748         LDKPublicKey broadcaster_payment_basepoint_ref;
33749         CHECK((*env)->GetArrayLength(env, broadcaster_payment_basepoint) == 33);
33750         (*env)->GetByteArrayRegion(env, broadcaster_payment_basepoint, 0, 33, broadcaster_payment_basepoint_ref.compressed_form);
33751         LDKPublicKey countersignatory_payment_basepoint_ref;
33752         CHECK((*env)->GetArrayLength(env, countersignatory_payment_basepoint) == 33);
33753         (*env)->GetByteArrayRegion(env, countersignatory_payment_basepoint, 0, 33, countersignatory_payment_basepoint_ref.compressed_form);
33754         int64_t ret_val = get_commitment_transaction_number_obscure_factor(broadcaster_payment_basepoint_ref, countersignatory_payment_basepoint_ref, outbound_from_broadcaster);
33755         return ret_val;
33756 }
33757
33758 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33759         LDKInitFeatures a_conv;
33760         a_conv.inner = (void*)(a & (~1));
33761         a_conv.is_owned = false;
33762         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33763         LDKInitFeatures b_conv;
33764         b_conv.inner = (void*)(b & (~1));
33765         b_conv.is_owned = false;
33766         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33767         jboolean ret_val = InitFeatures_eq(&a_conv, &b_conv);
33768         return ret_val;
33769 }
33770
33771 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33772         LDKNodeFeatures a_conv;
33773         a_conv.inner = (void*)(a & (~1));
33774         a_conv.is_owned = false;
33775         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33776         LDKNodeFeatures b_conv;
33777         b_conv.inner = (void*)(b & (~1));
33778         b_conv.is_owned = false;
33779         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33780         jboolean ret_val = NodeFeatures_eq(&a_conv, &b_conv);
33781         return ret_val;
33782 }
33783
33784 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33785         LDKChannelFeatures a_conv;
33786         a_conv.inner = (void*)(a & (~1));
33787         a_conv.is_owned = false;
33788         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33789         LDKChannelFeatures b_conv;
33790         b_conv.inner = (void*)(b & (~1));
33791         b_conv.is_owned = false;
33792         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33793         jboolean ret_val = ChannelFeatures_eq(&a_conv, &b_conv);
33794         return ret_val;
33795 }
33796
33797 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
33798         LDKInvoiceFeatures a_conv;
33799         a_conv.inner = (void*)(a & (~1));
33800         a_conv.is_owned = false;
33801         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
33802         LDKInvoiceFeatures b_conv;
33803         b_conv.inner = (void*)(b & (~1));
33804         b_conv.is_owned = false;
33805         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
33806         jboolean ret_val = InvoiceFeatures_eq(&a_conv, &b_conv);
33807         return ret_val;
33808 }
33809
33810 static inline uint64_t InitFeatures_clone_ptr(LDKInitFeatures *NONNULL_PTR arg) {
33811         LDKInitFeatures ret_var = InitFeatures_clone(arg);
33812 uint64_t ret_ref = 0;
33813 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33814 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33815 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33816 ret_ref = (uint64_t)ret_var.inner;
33817 if (ret_var.is_owned) {
33818         ret_ref |= 1;
33819 }
33820         return ret_ref;
33821 }
33822 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33823         LDKInitFeatures arg_conv;
33824         arg_conv.inner = (void*)(arg & (~1));
33825         arg_conv.is_owned = false;
33826         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33827         int64_t ret_val = InitFeatures_clone_ptr(&arg_conv);
33828         return ret_val;
33829 }
33830
33831 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33832         LDKInitFeatures orig_conv;
33833         orig_conv.inner = (void*)(orig & (~1));
33834         orig_conv.is_owned = false;
33835         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33836         LDKInitFeatures ret_var = InitFeatures_clone(&orig_conv);
33837         uint64_t ret_ref = 0;
33838         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33839         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33840         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33841         ret_ref = (uint64_t)ret_var.inner;
33842         if (ret_var.is_owned) {
33843                 ret_ref |= 1;
33844         }
33845         return ret_ref;
33846 }
33847
33848 static inline uint64_t NodeFeatures_clone_ptr(LDKNodeFeatures *NONNULL_PTR arg) {
33849         LDKNodeFeatures ret_var = NodeFeatures_clone(arg);
33850 uint64_t ret_ref = 0;
33851 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33852 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33853 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33854 ret_ref = (uint64_t)ret_var.inner;
33855 if (ret_var.is_owned) {
33856         ret_ref |= 1;
33857 }
33858         return ret_ref;
33859 }
33860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33861         LDKNodeFeatures arg_conv;
33862         arg_conv.inner = (void*)(arg & (~1));
33863         arg_conv.is_owned = false;
33864         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33865         int64_t ret_val = NodeFeatures_clone_ptr(&arg_conv);
33866         return ret_val;
33867 }
33868
33869 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33870         LDKNodeFeatures orig_conv;
33871         orig_conv.inner = (void*)(orig & (~1));
33872         orig_conv.is_owned = false;
33873         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33874         LDKNodeFeatures ret_var = NodeFeatures_clone(&orig_conv);
33875         uint64_t ret_ref = 0;
33876         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33877         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33878         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33879         ret_ref = (uint64_t)ret_var.inner;
33880         if (ret_var.is_owned) {
33881                 ret_ref |= 1;
33882         }
33883         return ret_ref;
33884 }
33885
33886 static inline uint64_t ChannelFeatures_clone_ptr(LDKChannelFeatures *NONNULL_PTR arg) {
33887         LDKChannelFeatures ret_var = ChannelFeatures_clone(arg);
33888 uint64_t ret_ref = 0;
33889 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33890 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33891 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33892 ret_ref = (uint64_t)ret_var.inner;
33893 if (ret_var.is_owned) {
33894         ret_ref |= 1;
33895 }
33896         return ret_ref;
33897 }
33898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33899         LDKChannelFeatures arg_conv;
33900         arg_conv.inner = (void*)(arg & (~1));
33901         arg_conv.is_owned = false;
33902         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33903         int64_t ret_val = ChannelFeatures_clone_ptr(&arg_conv);
33904         return ret_val;
33905 }
33906
33907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33908         LDKChannelFeatures orig_conv;
33909         orig_conv.inner = (void*)(orig & (~1));
33910         orig_conv.is_owned = false;
33911         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33912         LDKChannelFeatures ret_var = ChannelFeatures_clone(&orig_conv);
33913         uint64_t ret_ref = 0;
33914         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33915         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33916         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33917         ret_ref = (uint64_t)ret_var.inner;
33918         if (ret_var.is_owned) {
33919                 ret_ref |= 1;
33920         }
33921         return ret_ref;
33922 }
33923
33924 static inline uint64_t InvoiceFeatures_clone_ptr(LDKInvoiceFeatures *NONNULL_PTR arg) {
33925         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(arg);
33926 uint64_t ret_ref = 0;
33927 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33928 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33929 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33930 ret_ref = (uint64_t)ret_var.inner;
33931 if (ret_var.is_owned) {
33932         ret_ref |= 1;
33933 }
33934         return ret_ref;
33935 }
33936 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
33937         LDKInvoiceFeatures arg_conv;
33938         arg_conv.inner = (void*)(arg & (~1));
33939         arg_conv.is_owned = false;
33940         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
33941         int64_t ret_val = InvoiceFeatures_clone_ptr(&arg_conv);
33942         return ret_val;
33943 }
33944
33945 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1clone(JNIEnv *env, jclass clz, int64_t orig) {
33946         LDKInvoiceFeatures orig_conv;
33947         orig_conv.inner = (void*)(orig & (~1));
33948         orig_conv.is_owned = false;
33949         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
33950         LDKInvoiceFeatures ret_var = InvoiceFeatures_clone(&orig_conv);
33951         uint64_t ret_ref = 0;
33952         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33953         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33954         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
33955         ret_ref = (uint64_t)ret_var.inner;
33956         if (ret_var.is_owned) {
33957                 ret_ref |= 1;
33958         }
33959         return ret_ref;
33960 }
33961
33962 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InitFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33963         LDKInitFeatures this_obj_conv;
33964         this_obj_conv.inner = (void*)(this_obj & (~1));
33965         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33966         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33967         InitFeatures_free(this_obj_conv);
33968 }
33969
33970 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33971         LDKNodeFeatures this_obj_conv;
33972         this_obj_conv.inner = (void*)(this_obj & (~1));
33973         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33974         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33975         NodeFeatures_free(this_obj_conv);
33976 }
33977
33978 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33979         LDKChannelFeatures this_obj_conv;
33980         this_obj_conv.inner = (void*)(this_obj & (~1));
33981         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33982         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33983         ChannelFeatures_free(this_obj_conv);
33984 }
33985
33986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
33987         LDKInvoiceFeatures this_obj_conv;
33988         this_obj_conv.inner = (void*)(this_obj & (~1));
33989         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
33990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
33991         InvoiceFeatures_free(this_obj_conv);
33992 }
33993
33994 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1empty(JNIEnv *env, jclass clz) {
33995         LDKInitFeatures ret_var = InitFeatures_empty();
33996         uint64_t ret_ref = 0;
33997         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
33998         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
33999         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34000         ret_ref = (uint64_t)ret_var.inner;
34001         if (ret_var.is_owned) {
34002                 ret_ref |= 1;
34003         }
34004         return ret_ref;
34005 }
34006
34007 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1known(JNIEnv *env, jclass clz) {
34008         LDKInitFeatures ret_var = InitFeatures_known();
34009         uint64_t ret_ref = 0;
34010         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34011         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34012         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34013         ret_ref = (uint64_t)ret_var.inner;
34014         if (ret_var.is_owned) {
34015                 ret_ref |= 1;
34016         }
34017         return ret_ref;
34018 }
34019
34020 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34021         LDKInitFeatures this_arg_conv;
34022         this_arg_conv.inner = (void*)(this_arg & (~1));
34023         this_arg_conv.is_owned = false;
34024         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34025         jboolean ret_val = InitFeatures_requires_unknown_bits(&this_arg_conv);
34026         return ret_val;
34027 }
34028
34029 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1empty(JNIEnv *env, jclass clz) {
34030         LDKNodeFeatures ret_var = NodeFeatures_empty();
34031         uint64_t ret_ref = 0;
34032         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34033         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34034         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34035         ret_ref = (uint64_t)ret_var.inner;
34036         if (ret_var.is_owned) {
34037                 ret_ref |= 1;
34038         }
34039         return ret_ref;
34040 }
34041
34042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1known(JNIEnv *env, jclass clz) {
34043         LDKNodeFeatures ret_var = NodeFeatures_known();
34044         uint64_t ret_ref = 0;
34045         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34046         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34047         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34048         ret_ref = (uint64_t)ret_var.inner;
34049         if (ret_var.is_owned) {
34050                 ret_ref |= 1;
34051         }
34052         return ret_ref;
34053 }
34054
34055 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34056         LDKNodeFeatures this_arg_conv;
34057         this_arg_conv.inner = (void*)(this_arg & (~1));
34058         this_arg_conv.is_owned = false;
34059         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34060         jboolean ret_val = NodeFeatures_requires_unknown_bits(&this_arg_conv);
34061         return ret_val;
34062 }
34063
34064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1empty(JNIEnv *env, jclass clz) {
34065         LDKChannelFeatures ret_var = ChannelFeatures_empty();
34066         uint64_t ret_ref = 0;
34067         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34068         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34069         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34070         ret_ref = (uint64_t)ret_var.inner;
34071         if (ret_var.is_owned) {
34072                 ret_ref |= 1;
34073         }
34074         return ret_ref;
34075 }
34076
34077 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1known(JNIEnv *env, jclass clz) {
34078         LDKChannelFeatures ret_var = ChannelFeatures_known();
34079         uint64_t ret_ref = 0;
34080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34083         ret_ref = (uint64_t)ret_var.inner;
34084         if (ret_var.is_owned) {
34085                 ret_ref |= 1;
34086         }
34087         return ret_ref;
34088 }
34089
34090 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34091         LDKChannelFeatures this_arg_conv;
34092         this_arg_conv.inner = (void*)(this_arg & (~1));
34093         this_arg_conv.is_owned = false;
34094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34095         jboolean ret_val = ChannelFeatures_requires_unknown_bits(&this_arg_conv);
34096         return ret_val;
34097 }
34098
34099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1empty(JNIEnv *env, jclass clz) {
34100         LDKInvoiceFeatures ret_var = InvoiceFeatures_empty();
34101         uint64_t ret_ref = 0;
34102         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34103         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34104         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34105         ret_ref = (uint64_t)ret_var.inner;
34106         if (ret_var.is_owned) {
34107                 ret_ref |= 1;
34108         }
34109         return ret_ref;
34110 }
34111
34112 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1known(JNIEnv *env, jclass clz) {
34113         LDKInvoiceFeatures ret_var = InvoiceFeatures_known();
34114         uint64_t ret_ref = 0;
34115         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34116         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34118         ret_ref = (uint64_t)ret_var.inner;
34119         if (ret_var.is_owned) {
34120                 ret_ref |= 1;
34121         }
34122         return ret_ref;
34123 }
34124
34125 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1requires_1unknown_1bits(JNIEnv *env, jclass clz, int64_t this_arg) {
34126         LDKInvoiceFeatures this_arg_conv;
34127         this_arg_conv.inner = (void*)(this_arg & (~1));
34128         this_arg_conv.is_owned = false;
34129         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34130         jboolean ret_val = InvoiceFeatures_requires_unknown_bits(&this_arg_conv);
34131         return ret_val;
34132 }
34133
34134 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InitFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
34135         LDKInitFeatures this_arg_conv;
34136         this_arg_conv.inner = (void*)(this_arg & (~1));
34137         this_arg_conv.is_owned = false;
34138         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34139         jboolean ret_val = InitFeatures_supports_payment_secret(&this_arg_conv);
34140         return ret_val;
34141 }
34142
34143 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
34144         LDKNodeFeatures this_arg_conv;
34145         this_arg_conv.inner = (void*)(this_arg & (~1));
34146         this_arg_conv.is_owned = false;
34147         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34148         jboolean ret_val = NodeFeatures_supports_payment_secret(&this_arg_conv);
34149         return ret_val;
34150 }
34151
34152 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1supports_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
34153         LDKInvoiceFeatures this_arg_conv;
34154         this_arg_conv.inner = (void*)(this_arg & (~1));
34155         this_arg_conv.is_owned = false;
34156         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34157         jboolean ret_val = InvoiceFeatures_supports_payment_secret(&this_arg_conv);
34158         return ret_val;
34159 }
34160
34161 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InitFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34162         LDKInitFeatures obj_conv;
34163         obj_conv.inner = (void*)(obj & (~1));
34164         obj_conv.is_owned = false;
34165         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34166         LDKCVec_u8Z ret_var = InitFeatures_write(&obj_conv);
34167         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34168         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34169         CVec_u8Z_free(ret_var);
34170         return ret_arr;
34171 }
34172
34173 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34174         LDKNodeFeatures obj_conv;
34175         obj_conv.inner = (void*)(obj & (~1));
34176         obj_conv.is_owned = false;
34177         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34178         LDKCVec_u8Z ret_var = NodeFeatures_write(&obj_conv);
34179         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34180         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34181         CVec_u8Z_free(ret_var);
34182         return ret_arr;
34183 }
34184
34185 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34186         LDKChannelFeatures obj_conv;
34187         obj_conv.inner = (void*)(obj & (~1));
34188         obj_conv.is_owned = false;
34189         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34190         LDKCVec_u8Z ret_var = ChannelFeatures_write(&obj_conv);
34191         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34192         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34193         CVec_u8Z_free(ret_var);
34194         return ret_arr;
34195 }
34196
34197 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1write(JNIEnv *env, jclass clz, int64_t obj) {
34198         LDKInvoiceFeatures obj_conv;
34199         obj_conv.inner = (void*)(obj & (~1));
34200         obj_conv.is_owned = false;
34201         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34202         LDKCVec_u8Z ret_var = InvoiceFeatures_write(&obj_conv);
34203         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34204         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34205         CVec_u8Z_free(ret_var);
34206         return ret_arr;
34207 }
34208
34209 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InitFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34210         LDKu8slice ser_ref;
34211         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34212         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34213         LDKCResult_InitFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InitFeaturesDecodeErrorZ), "LDKCResult_InitFeaturesDecodeErrorZ");
34214         *ret_conv = InitFeatures_read(ser_ref);
34215         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34216         return (uint64_t)ret_conv;
34217 }
34218
34219 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34220         LDKu8slice ser_ref;
34221         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34222         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34223         LDKCResult_NodeFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeFeaturesDecodeErrorZ), "LDKCResult_NodeFeaturesDecodeErrorZ");
34224         *ret_conv = NodeFeatures_read(ser_ref);
34225         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34226         return (uint64_t)ret_conv;
34227 }
34228
34229 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34230         LDKu8slice ser_ref;
34231         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34232         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34233         LDKCResult_ChannelFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelFeaturesDecodeErrorZ), "LDKCResult_ChannelFeaturesDecodeErrorZ");
34234         *ret_conv = ChannelFeatures_read(ser_ref);
34235         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34236         return (uint64_t)ret_conv;
34237 }
34238
34239 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceFeatures_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34240         LDKu8slice ser_ref;
34241         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34242         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34243         LDKCResult_InvoiceFeaturesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceFeaturesDecodeErrorZ), "LDKCResult_InvoiceFeaturesDecodeErrorZ");
34244         *ret_conv = InvoiceFeatures_read(ser_ref);
34245         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34246         return (uint64_t)ret_conv;
34247 }
34248
34249 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34250         LDKShutdownScript this_obj_conv;
34251         this_obj_conv.inner = (void*)(this_obj & (~1));
34252         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34253         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34254         ShutdownScript_free(this_obj_conv);
34255 }
34256
34257 static inline uint64_t ShutdownScript_clone_ptr(LDKShutdownScript *NONNULL_PTR arg) {
34258         LDKShutdownScript ret_var = ShutdownScript_clone(arg);
34259 uint64_t ret_ref = 0;
34260 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34261 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34262 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34263 ret_ref = (uint64_t)ret_var.inner;
34264 if (ret_var.is_owned) {
34265         ret_ref |= 1;
34266 }
34267         return ret_ref;
34268 }
34269 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34270         LDKShutdownScript arg_conv;
34271         arg_conv.inner = (void*)(arg & (~1));
34272         arg_conv.is_owned = false;
34273         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34274         int64_t ret_val = ShutdownScript_clone_ptr(&arg_conv);
34275         return ret_val;
34276 }
34277
34278 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34279         LDKShutdownScript orig_conv;
34280         orig_conv.inner = (void*)(orig & (~1));
34281         orig_conv.is_owned = false;
34282         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34283         LDKShutdownScript ret_var = ShutdownScript_clone(&orig_conv);
34284         uint64_t ret_ref = 0;
34285         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34286         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34288         ret_ref = (uint64_t)ret_var.inner;
34289         if (ret_var.is_owned) {
34290                 ret_ref |= 1;
34291         }
34292         return ret_ref;
34293 }
34294
34295 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34296         LDKInvalidShutdownScript this_obj_conv;
34297         this_obj_conv.inner = (void*)(this_obj & (~1));
34298         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34299         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34300         InvalidShutdownScript_free(this_obj_conv);
34301 }
34302
34303 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1get_1script(JNIEnv *env, jclass clz, int64_t this_ptr) {
34304         LDKInvalidShutdownScript this_ptr_conv;
34305         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34306         this_ptr_conv.is_owned = false;
34307         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34308         LDKu8slice ret_var = InvalidShutdownScript_get_script(&this_ptr_conv);
34309         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34310         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34311         return ret_arr;
34312 }
34313
34314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1set_1script(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
34315         LDKInvalidShutdownScript this_ptr_conv;
34316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34317         this_ptr_conv.is_owned = false;
34318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34319         LDKCVec_u8Z val_ref;
34320         val_ref.datalen = (*env)->GetArrayLength(env, val);
34321         val_ref.data = MALLOC(val_ref.datalen, "LDKCVec_u8Z Bytes");
34322         (*env)->GetByteArrayRegion(env, val, 0, val_ref.datalen, val_ref.data);
34323         InvalidShutdownScript_set_script(&this_ptr_conv, val_ref);
34324 }
34325
34326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1new(JNIEnv *env, jclass clz, int8_tArray script_arg) {
34327         LDKCVec_u8Z script_arg_ref;
34328         script_arg_ref.datalen = (*env)->GetArrayLength(env, script_arg);
34329         script_arg_ref.data = MALLOC(script_arg_ref.datalen, "LDKCVec_u8Z Bytes");
34330         (*env)->GetByteArrayRegion(env, script_arg, 0, script_arg_ref.datalen, script_arg_ref.data);
34331         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_new(script_arg_ref);
34332         uint64_t ret_ref = 0;
34333         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34334         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34335         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34336         ret_ref = (uint64_t)ret_var.inner;
34337         if (ret_var.is_owned) {
34338                 ret_ref |= 1;
34339         }
34340         return ret_ref;
34341 }
34342
34343 static inline uint64_t InvalidShutdownScript_clone_ptr(LDKInvalidShutdownScript *NONNULL_PTR arg) {
34344         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(arg);
34345 uint64_t ret_ref = 0;
34346 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34347 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34348 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34349 ret_ref = (uint64_t)ret_var.inner;
34350 if (ret_var.is_owned) {
34351         ret_ref |= 1;
34352 }
34353         return ret_ref;
34354 }
34355 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34356         LDKInvalidShutdownScript arg_conv;
34357         arg_conv.inner = (void*)(arg & (~1));
34358         arg_conv.is_owned = false;
34359         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34360         int64_t ret_val = InvalidShutdownScript_clone_ptr(&arg_conv);
34361         return ret_val;
34362 }
34363
34364 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvalidShutdownScript_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34365         LDKInvalidShutdownScript orig_conv;
34366         orig_conv.inner = (void*)(orig & (~1));
34367         orig_conv.is_owned = false;
34368         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34369         LDKInvalidShutdownScript ret_var = InvalidShutdownScript_clone(&orig_conv);
34370         uint64_t ret_ref = 0;
34371         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34372         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34373         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34374         ret_ref = (uint64_t)ret_var.inner;
34375         if (ret_var.is_owned) {
34376                 ret_ref |= 1;
34377         }
34378         return ret_ref;
34379 }
34380
34381 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1write(JNIEnv *env, jclass clz, int64_t obj) {
34382         LDKShutdownScript obj_conv;
34383         obj_conv.inner = (void*)(obj & (~1));
34384         obj_conv.is_owned = false;
34385         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34386         LDKCVec_u8Z ret_var = ShutdownScript_write(&obj_conv);
34387         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34388         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34389         CVec_u8Z_free(ret_var);
34390         return ret_arr;
34391 }
34392
34393 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34394         LDKu8slice ser_ref;
34395         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34396         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34397         LDKCResult_ShutdownScriptDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptDecodeErrorZ), "LDKCResult_ShutdownScriptDecodeErrorZ");
34398         *ret_conv = ShutdownScript_read(ser_ref);
34399         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34400         return (uint64_t)ret_conv;
34401 }
34402
34403 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wpkh(JNIEnv *env, jclass clz, int8_tArray pubkey_hash) {
34404         unsigned char pubkey_hash_arr[20];
34405         CHECK((*env)->GetArrayLength(env, pubkey_hash) == 20);
34406         (*env)->GetByteArrayRegion(env, pubkey_hash, 0, 20, pubkey_hash_arr);
34407         unsigned char (*pubkey_hash_ref)[20] = &pubkey_hash_arr;
34408         LDKShutdownScript ret_var = ShutdownScript_new_p2wpkh(pubkey_hash_ref);
34409         uint64_t ret_ref = 0;
34410         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34411         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34412         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34413         ret_ref = (uint64_t)ret_var.inner;
34414         if (ret_var.is_owned) {
34415                 ret_ref |= 1;
34416         }
34417         return ret_ref;
34418 }
34419
34420 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1p2wsh(JNIEnv *env, jclass clz, int8_tArray script_hash) {
34421         unsigned char script_hash_arr[32];
34422         CHECK((*env)->GetArrayLength(env, script_hash) == 32);
34423         (*env)->GetByteArrayRegion(env, script_hash, 0, 32, script_hash_arr);
34424         unsigned char (*script_hash_ref)[32] = &script_hash_arr;
34425         LDKShutdownScript ret_var = ShutdownScript_new_p2wsh(script_hash_ref);
34426         uint64_t ret_ref = 0;
34427         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34428         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34429         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34430         ret_ref = (uint64_t)ret_var.inner;
34431         if (ret_var.is_owned) {
34432                 ret_ref |= 1;
34433         }
34434         return ret_ref;
34435 }
34436
34437 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1new_1witness_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
34438         LDKu8slice program_ref;
34439         program_ref.datalen = (*env)->GetArrayLength(env, program);
34440         program_ref.data = (*env)->GetByteArrayElements (env, program, NULL);
34441         LDKCResult_ShutdownScriptInvalidShutdownScriptZ* ret_conv = MALLOC(sizeof(LDKCResult_ShutdownScriptInvalidShutdownScriptZ), "LDKCResult_ShutdownScriptInvalidShutdownScriptZ");
34442         *ret_conv = ShutdownScript_new_witness_program(version, program_ref);
34443         (*env)->ReleaseByteArrayElements(env, program, (int8_t*)program_ref.data, 0);
34444         return (uint64_t)ret_conv;
34445 }
34446
34447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
34448         LDKShutdownScript this_arg_conv;
34449         this_arg_conv.inner = (void*)(this_arg & (~1));
34450         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
34451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34452         this_arg_conv = ShutdownScript_clone(&this_arg_conv);
34453         LDKCVec_u8Z ret_var = ShutdownScript_into_inner(this_arg_conv);
34454         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34455         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34456         CVec_u8Z_free(ret_var);
34457         return ret_arr;
34458 }
34459
34460 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1as_1legacy_1pubkey(JNIEnv *env, jclass clz, int64_t this_arg) {
34461         LDKShutdownScript this_arg_conv;
34462         this_arg_conv.inner = (void*)(this_arg & (~1));
34463         this_arg_conv.is_owned = false;
34464         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34465         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
34466         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, ShutdownScript_as_legacy_pubkey(&this_arg_conv).compressed_form);
34467         return ret_arr;
34468 }
34469
34470 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ShutdownScript_1is_1compatible(JNIEnv *env, jclass clz, int64_t this_arg, int64_t features) {
34471         LDKShutdownScript this_arg_conv;
34472         this_arg_conv.inner = (void*)(this_arg & (~1));
34473         this_arg_conv.is_owned = false;
34474         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34475         LDKInitFeatures features_conv;
34476         features_conv.inner = (void*)(features & (~1));
34477         features_conv.is_owned = false;
34478         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_conv);
34479         jboolean ret_val = ShutdownScript_is_compatible(&this_arg_conv, &features_conv);
34480         return ret_val;
34481 }
34482
34483 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_CustomMessageReader_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34484         if ((this_ptr & 1) != 0) return;
34485         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34486         CHECK_ACCESS(this_ptr_ptr);
34487         LDKCustomMessageReader this_ptr_conv = *(LDKCustomMessageReader*)(this_ptr_ptr);
34488         FREE((void*)this_ptr);
34489         CustomMessageReader_free(this_ptr_conv);
34490 }
34491
34492 static inline uint64_t Type_clone_ptr(LDKType *NONNULL_PTR arg) {
34493         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
34494         *ret_ret = Type_clone(arg);
34495         return (uint64_t)ret_ret;
34496 }
34497 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34498         void* arg_ptr = (void*)(((uint64_t)arg) & ~1);
34499         if (!(arg & 1)) { CHECK_ACCESS(arg_ptr); }
34500         LDKType* arg_conv = (LDKType*)arg_ptr;
34501         int64_t ret_val = Type_clone_ptr(arg_conv);
34502         return ret_val;
34503 }
34504
34505 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Type_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34506         void* orig_ptr = (void*)(((uint64_t)orig) & ~1);
34507         if (!(orig & 1)) { CHECK_ACCESS(orig_ptr); }
34508         LDKType* orig_conv = (LDKType*)orig_ptr;
34509         LDKType* ret_ret = MALLOC(sizeof(LDKType), "LDKType");
34510         *ret_ret = Type_clone(orig_conv);
34511         return (uint64_t)ret_ret;
34512 }
34513
34514 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Type_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34515         if ((this_ptr & 1) != 0) return;
34516         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34517         CHECK_ACCESS(this_ptr_ptr);
34518         LDKType this_ptr_conv = *(LDKType*)(this_ptr_ptr);
34519         FREE((void*)this_ptr);
34520         Type_free(this_ptr_conv);
34521 }
34522
34523 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Score_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34524         if ((this_ptr & 1) != 0) return;
34525         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34526         CHECK_ACCESS(this_ptr_ptr);
34527         LDKScore this_ptr_conv = *(LDKScore*)(this_ptr_ptr);
34528         FREE((void*)this_ptr);
34529         Score_free(this_ptr_conv);
34530 }
34531
34532 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_LockableScore_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34533         LDKLockableScore this_obj_conv;
34534         this_obj_conv.inner = (void*)(this_obj & (~1));
34535         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34536         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34537         LockableScore_free(this_obj_conv);
34538 }
34539
34540 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_LockableScore_1new(JNIEnv *env, jclass clz, int64_t score) {
34541         void* score_ptr = (void*)(((uint64_t)score) & ~1);
34542         CHECK_ACCESS(score_ptr);
34543         LDKScore score_conv = *(LDKScore*)(score_ptr);
34544         if (score_conv.free == LDKScore_JCalls_free) {
34545                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34546                 LDKScore_JCalls_cloned(&score_conv);
34547         }
34548         LDKLockableScore ret_var = LockableScore_new(score_conv);
34549         uint64_t ret_ref = 0;
34550         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34551         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34552         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34553         ret_ref = (uint64_t)ret_var.inner;
34554         if (ret_var.is_owned) {
34555                 ret_ref |= 1;
34556         }
34557         return ret_ref;
34558 }
34559
34560 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_LockableScore_1write(JNIEnv *env, jclass clz, int64_t obj) {
34561         LDKLockableScore obj_conv;
34562         obj_conv.inner = (void*)(obj & (~1));
34563         obj_conv.is_owned = false;
34564         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34565         LDKCVec_u8Z ret_var = LockableScore_write(&obj_conv);
34566         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34567         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34568         CVec_u8Z_free(ret_var);
34569         return ret_arr;
34570 }
34571
34572 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeId_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34573         LDKNodeId this_obj_conv;
34574         this_obj_conv.inner = (void*)(this_obj & (~1));
34575         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34577         NodeId_free(this_obj_conv);
34578 }
34579
34580 static inline uint64_t NodeId_clone_ptr(LDKNodeId *NONNULL_PTR arg) {
34581         LDKNodeId ret_var = NodeId_clone(arg);
34582 uint64_t ret_ref = 0;
34583 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34584 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34585 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34586 ret_ref = (uint64_t)ret_var.inner;
34587 if (ret_var.is_owned) {
34588         ret_ref |= 1;
34589 }
34590         return ret_ref;
34591 }
34592 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34593         LDKNodeId arg_conv;
34594         arg_conv.inner = (void*)(arg & (~1));
34595         arg_conv.is_owned = false;
34596         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34597         int64_t ret_val = NodeId_clone_ptr(&arg_conv);
34598         return ret_val;
34599 }
34600
34601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34602         LDKNodeId orig_conv;
34603         orig_conv.inner = (void*)(orig & (~1));
34604         orig_conv.is_owned = false;
34605         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34606         LDKNodeId ret_var = NodeId_clone(&orig_conv);
34607         uint64_t ret_ref = 0;
34608         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34609         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34610         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34611         ret_ref = (uint64_t)ret_var.inner;
34612         if (ret_var.is_owned) {
34613                 ret_ref |= 1;
34614         }
34615         return ret_ref;
34616 }
34617
34618 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1from_1pubkey(JNIEnv *env, jclass clz, int8_tArray pubkey) {
34619         LDKPublicKey pubkey_ref;
34620         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
34621         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
34622         LDKNodeId ret_var = NodeId_from_pubkey(pubkey_ref);
34623         uint64_t ret_ref = 0;
34624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34627         ret_ref = (uint64_t)ret_var.inner;
34628         if (ret_var.is_owned) {
34629                 ret_ref |= 1;
34630         }
34631         return ret_ref;
34632 }
34633
34634 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1as_1slice(JNIEnv *env, jclass clz, int64_t this_arg) {
34635         LDKNodeId this_arg_conv;
34636         this_arg_conv.inner = (void*)(this_arg & (~1));
34637         this_arg_conv.is_owned = false;
34638         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34639         LDKu8slice ret_var = NodeId_as_slice(&this_arg_conv);
34640         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34641         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34642         return ret_arr;
34643 }
34644
34645 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1hash(JNIEnv *env, jclass clz, int64_t o) {
34646         LDKNodeId o_conv;
34647         o_conv.inner = (void*)(o & (~1));
34648         o_conv.is_owned = false;
34649         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
34650         int64_t ret_val = NodeId_hash(&o_conv);
34651         return ret_val;
34652 }
34653
34654 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeId_1write(JNIEnv *env, jclass clz, int64_t obj) {
34655         LDKNodeId obj_conv;
34656         obj_conv.inner = (void*)(obj & (~1));
34657         obj_conv.is_owned = false;
34658         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
34659         LDKCVec_u8Z ret_var = NodeId_write(&obj_conv);
34660         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34661         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34662         CVec_u8Z_free(ret_var);
34663         return ret_arr;
34664 }
34665
34666 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeId_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34667         LDKu8slice ser_ref;
34668         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34669         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34670         LDKCResult_NodeIdDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeIdDecodeErrorZ), "LDKCResult_NodeIdDecodeErrorZ");
34671         *ret_conv = NodeId_read(ser_ref);
34672         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34673         return (uint64_t)ret_conv;
34674 }
34675
34676 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34677         LDKNetworkGraph this_obj_conv;
34678         this_obj_conv.inner = (void*)(this_obj & (~1));
34679         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34680         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34681         NetworkGraph_free(this_obj_conv);
34682 }
34683
34684 static inline uint64_t NetworkGraph_clone_ptr(LDKNetworkGraph *NONNULL_PTR arg) {
34685         LDKNetworkGraph ret_var = NetworkGraph_clone(arg);
34686 uint64_t ret_ref = 0;
34687 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34688 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34689 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34690 ret_ref = (uint64_t)ret_var.inner;
34691 if (ret_var.is_owned) {
34692         ret_ref |= 1;
34693 }
34694         return ret_ref;
34695 }
34696 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34697         LDKNetworkGraph arg_conv;
34698         arg_conv.inner = (void*)(arg & (~1));
34699         arg_conv.is_owned = false;
34700         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
34701         int64_t ret_val = NetworkGraph_clone_ptr(&arg_conv);
34702         return ret_val;
34703 }
34704
34705 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34706         LDKNetworkGraph orig_conv;
34707         orig_conv.inner = (void*)(orig & (~1));
34708         orig_conv.is_owned = false;
34709         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
34710         LDKNetworkGraph ret_var = NetworkGraph_clone(&orig_conv);
34711         uint64_t ret_ref = 0;
34712         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34713         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34714         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34715         ret_ref = (uint64_t)ret_var.inner;
34716         if (ret_var.is_owned) {
34717                 ret_ref |= 1;
34718         }
34719         return ret_ref;
34720 }
34721
34722 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34723         LDKReadOnlyNetworkGraph this_obj_conv;
34724         this_obj_conv.inner = (void*)(this_obj & (~1));
34725         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34726         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34727         ReadOnlyNetworkGraph_free(this_obj_conv);
34728 }
34729
34730 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
34731         if ((this_ptr & 1) != 0) return;
34732         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
34733         CHECK_ACCESS(this_ptr_ptr);
34734         LDKNetworkUpdate this_ptr_conv = *(LDKNetworkUpdate*)(this_ptr_ptr);
34735         FREE((void*)this_ptr);
34736         NetworkUpdate_free(this_ptr_conv);
34737 }
34738
34739 static inline uint64_t NetworkUpdate_clone_ptr(LDKNetworkUpdate *NONNULL_PTR arg) {
34740         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34741         *ret_copy = NetworkUpdate_clone(arg);
34742 uint64_t ret_ref = (uint64_t)ret_copy;
34743         return ret_ref;
34744 }
34745 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
34746         LDKNetworkUpdate* arg_conv = (LDKNetworkUpdate*)arg;
34747         int64_t ret_val = NetworkUpdate_clone_ptr(arg_conv);
34748         return ret_val;
34749 }
34750
34751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1clone(JNIEnv *env, jclass clz, int64_t orig) {
34752         LDKNetworkUpdate* orig_conv = (LDKNetworkUpdate*)orig;
34753         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34754         *ret_copy = NetworkUpdate_clone(orig_conv);
34755         uint64_t ret_ref = (uint64_t)ret_copy;
34756         return ret_ref;
34757 }
34758
34759 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1update_1message(JNIEnv *env, jclass clz, int64_t msg) {
34760         LDKChannelUpdate msg_conv;
34761         msg_conv.inner = (void*)(msg & (~1));
34762         msg_conv.is_owned = (msg & 1) || (msg == 0);
34763         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
34764         msg_conv = ChannelUpdate_clone(&msg_conv);
34765         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34766         *ret_copy = NetworkUpdate_channel_update_message(msg_conv);
34767         uint64_t ret_ref = (uint64_t)ret_copy;
34768         return ret_ref;
34769 }
34770
34771 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1channel_1closed(JNIEnv *env, jclass clz, int64_t short_channel_id, jboolean is_permanent) {
34772         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34773         *ret_copy = NetworkUpdate_channel_closed(short_channel_id, is_permanent);
34774         uint64_t ret_ref = (uint64_t)ret_copy;
34775         return ret_ref;
34776 }
34777
34778 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1node_1failure(JNIEnv *env, jclass clz, int8_tArray node_id, jboolean is_permanent) {
34779         LDKPublicKey node_id_ref;
34780         CHECK((*env)->GetArrayLength(env, node_id) == 33);
34781         (*env)->GetByteArrayRegion(env, node_id, 0, 33, node_id_ref.compressed_form);
34782         LDKNetworkUpdate *ret_copy = MALLOC(sizeof(LDKNetworkUpdate), "LDKNetworkUpdate");
34783         *ret_copy = NetworkUpdate_node_failure(node_id_ref, is_permanent);
34784         uint64_t ret_ref = (uint64_t)ret_copy;
34785         return ret_ref;
34786 }
34787
34788 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1write(JNIEnv *env, jclass clz, int64_t obj) {
34789         LDKNetworkUpdate* obj_conv = (LDKNetworkUpdate*)obj;
34790         LDKCVec_u8Z ret_var = NetworkUpdate_write(obj_conv);
34791         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
34792         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
34793         CVec_u8Z_free(ret_var);
34794         return ret_arr;
34795 }
34796
34797 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkUpdate_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
34798         LDKu8slice ser_ref;
34799         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
34800         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
34801         LDKCResult_COption_NetworkUpdateZDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_COption_NetworkUpdateZDecodeErrorZ), "LDKCResult_COption_NetworkUpdateZDecodeErrorZ");
34802         *ret_conv = NetworkUpdate_read(ser_ref);
34803         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
34804         return (uint64_t)ret_conv;
34805 }
34806
34807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
34808         LDKNetGraphMsgHandler this_arg_conv;
34809         this_arg_conv.inner = (void*)(this_arg & (~1));
34810         this_arg_conv.is_owned = false;
34811         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34812         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
34813         *ret_ret = NetGraphMsgHandler_as_EventHandler(&this_arg_conv);
34814         return (uint64_t)ret_ret;
34815 }
34816
34817 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34818         LDKNetGraphMsgHandler this_obj_conv;
34819         this_obj_conv.inner = (void*)(this_obj & (~1));
34820         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34821         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34822         NetGraphMsgHandler_free(this_obj_conv);
34823 }
34824
34825 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) {
34826         LDKNetworkGraph network_graph_conv;
34827         network_graph_conv.inner = (void*)(network_graph & (~1));
34828         network_graph_conv.is_owned = false;
34829         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
34830         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
34831         CHECK_ACCESS(chain_access_ptr);
34832         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
34833         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
34834         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
34835                 // Manually implement clone for Java trait instances
34836                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
34837                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34838                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
34839                 }
34840         }
34841         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
34842         CHECK_ACCESS(logger_ptr);
34843         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
34844         if (logger_conv.free == LDKLogger_JCalls_free) {
34845                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34846                 LDKLogger_JCalls_cloned(&logger_conv);
34847         }
34848         LDKNetGraphMsgHandler ret_var = NetGraphMsgHandler_new(&network_graph_conv, chain_access_conv, logger_conv);
34849         uint64_t ret_ref = 0;
34850         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
34851         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
34852         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
34853         ret_ref = (uint64_t)ret_var.inner;
34854         if (ret_var.is_owned) {
34855                 ret_ref |= 1;
34856         }
34857         return ret_ref;
34858 }
34859
34860 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1add_1chain_1access(JNIEnv *env, jclass clz, int64_t this_arg, int64_t chain_access) {
34861         LDKNetGraphMsgHandler this_arg_conv;
34862         this_arg_conv.inner = (void*)(this_arg & (~1));
34863         this_arg_conv.is_owned = false;
34864         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34865         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
34866         CHECK_ACCESS(chain_access_ptr);
34867         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
34868         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
34869         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
34870                 // Manually implement clone for Java trait instances
34871                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
34872                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
34873                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
34874                 }
34875         }
34876         NetGraphMsgHandler_add_chain_access(&this_arg_conv, chain_access_conv);
34877 }
34878
34879 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1RoutingMessageHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
34880         LDKNetGraphMsgHandler this_arg_conv;
34881         this_arg_conv.inner = (void*)(this_arg & (~1));
34882         this_arg_conv.is_owned = false;
34883         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34884         LDKRoutingMessageHandler* ret_ret = MALLOC(sizeof(LDKRoutingMessageHandler), "LDKRoutingMessageHandler");
34885         *ret_ret = NetGraphMsgHandler_as_RoutingMessageHandler(&this_arg_conv);
34886         return (uint64_t)ret_ret;
34887 }
34888
34889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetGraphMsgHandler_1as_1MessageSendEventsProvider(JNIEnv *env, jclass clz, int64_t this_arg) {
34890         LDKNetGraphMsgHandler this_arg_conv;
34891         this_arg_conv.inner = (void*)(this_arg & (~1));
34892         this_arg_conv.is_owned = false;
34893         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
34894         LDKMessageSendEventsProvider* ret_ret = MALLOC(sizeof(LDKMessageSendEventsProvider), "LDKMessageSendEventsProvider");
34895         *ret_ret = NetGraphMsgHandler_as_MessageSendEventsProvider(&this_arg_conv);
34896         return (uint64_t)ret_ret;
34897 }
34898
34899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
34900         LDKDirectionalChannelInfo this_obj_conv;
34901         this_obj_conv.inner = (void*)(this_obj & (~1));
34902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
34903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
34904         DirectionalChannelInfo_free(this_obj_conv);
34905 }
34906
34907 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
34908         LDKDirectionalChannelInfo this_ptr_conv;
34909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34910         this_ptr_conv.is_owned = false;
34911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34912         int32_t ret_val = DirectionalChannelInfo_get_last_update(&this_ptr_conv);
34913         return ret_val;
34914 }
34915
34916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
34917         LDKDirectionalChannelInfo this_ptr_conv;
34918         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34919         this_ptr_conv.is_owned = false;
34920         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34921         DirectionalChannelInfo_set_last_update(&this_ptr_conv, val);
34922 }
34923
34924 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr) {
34925         LDKDirectionalChannelInfo this_ptr_conv;
34926         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34927         this_ptr_conv.is_owned = false;
34928         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34929         jboolean ret_val = DirectionalChannelInfo_get_enabled(&this_ptr_conv);
34930         return ret_val;
34931 }
34932
34933 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1enabled(JNIEnv *env, jclass clz, int64_t this_ptr, jboolean val) {
34934         LDKDirectionalChannelInfo this_ptr_conv;
34935         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34936         this_ptr_conv.is_owned = false;
34937         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34938         DirectionalChannelInfo_set_enabled(&this_ptr_conv, val);
34939 }
34940
34941 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
34942         LDKDirectionalChannelInfo this_ptr_conv;
34943         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34944         this_ptr_conv.is_owned = false;
34945         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34946         int16_t ret_val = DirectionalChannelInfo_get_cltv_expiry_delta(&this_ptr_conv);
34947         return ret_val;
34948 }
34949
34950 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
34951         LDKDirectionalChannelInfo this_ptr_conv;
34952         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34953         this_ptr_conv.is_owned = false;
34954         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34955         DirectionalChannelInfo_set_cltv_expiry_delta(&this_ptr_conv, val);
34956 }
34957
34958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34959         LDKDirectionalChannelInfo this_ptr_conv;
34960         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34961         this_ptr_conv.is_owned = false;
34962         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34963         int64_t ret_val = DirectionalChannelInfo_get_htlc_minimum_msat(&this_ptr_conv);
34964         return ret_val;
34965 }
34966
34967 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34968         LDKDirectionalChannelInfo this_ptr_conv;
34969         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34970         this_ptr_conv.is_owned = false;
34971         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34972         DirectionalChannelInfo_set_htlc_minimum_msat(&this_ptr_conv, val);
34973 }
34974
34975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
34976         LDKDirectionalChannelInfo this_ptr_conv;
34977         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34978         this_ptr_conv.is_owned = false;
34979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34980         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
34981         *ret_copy = DirectionalChannelInfo_get_htlc_maximum_msat(&this_ptr_conv);
34982         uint64_t ret_ref = (uint64_t)ret_copy;
34983         return ret_ref;
34984 }
34985
34986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
34987         LDKDirectionalChannelInfo this_ptr_conv;
34988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
34989         this_ptr_conv.is_owned = false;
34990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
34991         void* val_ptr = (void*)(((uint64_t)val) & ~1);
34992         CHECK_ACCESS(val_ptr);
34993         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
34994         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
34995         DirectionalChannelInfo_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
34996 }
34997
34998 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
34999         LDKDirectionalChannelInfo this_ptr_conv;
35000         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35001         this_ptr_conv.is_owned = false;
35002         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35003         LDKRoutingFees ret_var = DirectionalChannelInfo_get_fees(&this_ptr_conv);
35004         uint64_t ret_ref = 0;
35005         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35006         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35007         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35008         ret_ref = (uint64_t)ret_var.inner;
35009         if (ret_var.is_owned) {
35010                 ret_ref |= 1;
35011         }
35012         return ret_ref;
35013 }
35014
35015 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35016         LDKDirectionalChannelInfo this_ptr_conv;
35017         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35018         this_ptr_conv.is_owned = false;
35019         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35020         LDKRoutingFees val_conv;
35021         val_conv.inner = (void*)(val & (~1));
35022         val_conv.is_owned = (val & 1) || (val == 0);
35023         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35024         val_conv = RoutingFees_clone(&val_conv);
35025         DirectionalChannelInfo_set_fees(&this_ptr_conv, val_conv);
35026 }
35027
35028 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1get_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
35029         LDKDirectionalChannelInfo this_ptr_conv;
35030         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35031         this_ptr_conv.is_owned = false;
35032         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35033         LDKChannelUpdate ret_var = DirectionalChannelInfo_get_last_update_message(&this_ptr_conv);
35034         uint64_t ret_ref = 0;
35035         if ((uint64_t)ret_var.inner > 4096) {
35036                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35037                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35038         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35039                 ret_ref = (uint64_t)ret_var.inner;
35040                 if (ret_var.is_owned) {
35041                         ret_ref |= 1;
35042                 }
35043         }
35044         return ret_ref;
35045 }
35046
35047 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1set_1last_1update_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35048         LDKDirectionalChannelInfo this_ptr_conv;
35049         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35050         this_ptr_conv.is_owned = false;
35051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35052         LDKChannelUpdate val_conv;
35053         val_conv.inner = (void*)(val & (~1));
35054         val_conv.is_owned = (val & 1) || (val == 0);
35055         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35056         val_conv = ChannelUpdate_clone(&val_conv);
35057         DirectionalChannelInfo_set_last_update_message(&this_ptr_conv, val_conv);
35058 }
35059
35060 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) {
35061         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
35062         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
35063         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
35064         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
35065         LDKRoutingFees fees_arg_conv;
35066         fees_arg_conv.inner = (void*)(fees_arg & (~1));
35067         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
35068         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
35069         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
35070         LDKChannelUpdate last_update_message_arg_conv;
35071         last_update_message_arg_conv.inner = (void*)(last_update_message_arg & (~1));
35072         last_update_message_arg_conv.is_owned = (last_update_message_arg & 1) || (last_update_message_arg == 0);
35073         CHECK_INNER_FIELD_ACCESS_OR_NULL(last_update_message_arg_conv);
35074         last_update_message_arg_conv = ChannelUpdate_clone(&last_update_message_arg_conv);
35075         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);
35076         uint64_t ret_ref = 0;
35077         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35078         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35079         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35080         ret_ref = (uint64_t)ret_var.inner;
35081         if (ret_var.is_owned) {
35082                 ret_ref |= 1;
35083         }
35084         return ret_ref;
35085 }
35086
35087 static inline uint64_t DirectionalChannelInfo_clone_ptr(LDKDirectionalChannelInfo *NONNULL_PTR arg) {
35088         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(arg);
35089 uint64_t ret_ref = 0;
35090 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35091 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35092 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35093 ret_ref = (uint64_t)ret_var.inner;
35094 if (ret_var.is_owned) {
35095         ret_ref |= 1;
35096 }
35097         return ret_ref;
35098 }
35099 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35100         LDKDirectionalChannelInfo arg_conv;
35101         arg_conv.inner = (void*)(arg & (~1));
35102         arg_conv.is_owned = false;
35103         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35104         int64_t ret_val = DirectionalChannelInfo_clone_ptr(&arg_conv);
35105         return ret_val;
35106 }
35107
35108 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35109         LDKDirectionalChannelInfo orig_conv;
35110         orig_conv.inner = (void*)(orig & (~1));
35111         orig_conv.is_owned = false;
35112         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35113         LDKDirectionalChannelInfo ret_var = DirectionalChannelInfo_clone(&orig_conv);
35114         uint64_t ret_ref = 0;
35115         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35116         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35117         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35118         ret_ref = (uint64_t)ret_var.inner;
35119         if (ret_var.is_owned) {
35120                 ret_ref |= 1;
35121         }
35122         return ret_ref;
35123 }
35124
35125 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
35126         LDKDirectionalChannelInfo obj_conv;
35127         obj_conv.inner = (void*)(obj & (~1));
35128         obj_conv.is_owned = false;
35129         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35130         LDKCVec_u8Z ret_var = DirectionalChannelInfo_write(&obj_conv);
35131         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35132         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35133         CVec_u8Z_free(ret_var);
35134         return ret_arr;
35135 }
35136
35137 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DirectionalChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35138         LDKu8slice ser_ref;
35139         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35140         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35141         LDKCResult_DirectionalChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DirectionalChannelInfoDecodeErrorZ), "LDKCResult_DirectionalChannelInfoDecodeErrorZ");
35142         *ret_conv = DirectionalChannelInfo_read(ser_ref);
35143         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35144         return (uint64_t)ret_conv;
35145 }
35146
35147 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35148         LDKChannelInfo this_obj_conv;
35149         this_obj_conv.inner = (void*)(this_obj & (~1));
35150         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35151         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35152         ChannelInfo_free(this_obj_conv);
35153 }
35154
35155 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35156         LDKChannelInfo this_ptr_conv;
35157         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35158         this_ptr_conv.is_owned = false;
35159         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35160         LDKChannelFeatures ret_var = ChannelInfo_get_features(&this_ptr_conv);
35161         uint64_t ret_ref = 0;
35162         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35163         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35164         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35165         ret_ref = (uint64_t)ret_var.inner;
35166         if (ret_var.is_owned) {
35167                 ret_ref |= 1;
35168         }
35169         return ret_ref;
35170 }
35171
35172 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35173         LDKChannelInfo this_ptr_conv;
35174         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35175         this_ptr_conv.is_owned = false;
35176         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35177         LDKChannelFeatures val_conv;
35178         val_conv.inner = (void*)(val & (~1));
35179         val_conv.is_owned = (val & 1) || (val == 0);
35180         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35181         val_conv = ChannelFeatures_clone(&val_conv);
35182         ChannelInfo_set_features(&this_ptr_conv, val_conv);
35183 }
35184
35185 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
35186         LDKChannelInfo this_ptr_conv;
35187         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35188         this_ptr_conv.is_owned = false;
35189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35190         LDKNodeId ret_var = ChannelInfo_get_node_one(&this_ptr_conv);
35191         uint64_t ret_ref = 0;
35192         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35193         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35194         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35195         ret_ref = (uint64_t)ret_var.inner;
35196         if (ret_var.is_owned) {
35197                 ret_ref |= 1;
35198         }
35199         return ret_ref;
35200 }
35201
35202 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35203         LDKChannelInfo this_ptr_conv;
35204         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35205         this_ptr_conv.is_owned = false;
35206         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35207         LDKNodeId val_conv;
35208         val_conv.inner = (void*)(val & (~1));
35209         val_conv.is_owned = (val & 1) || (val == 0);
35210         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35211         val_conv = NodeId_clone(&val_conv);
35212         ChannelInfo_set_node_one(&this_ptr_conv, val_conv);
35213 }
35214
35215 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
35216         LDKChannelInfo this_ptr_conv;
35217         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35218         this_ptr_conv.is_owned = false;
35219         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35220         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_one_to_two(&this_ptr_conv);
35221         uint64_t ret_ref = 0;
35222         if ((uint64_t)ret_var.inner > 4096) {
35223                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35224                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35226                 ret_ref = (uint64_t)ret_var.inner;
35227                 if (ret_var.is_owned) {
35228                         ret_ref |= 1;
35229                 }
35230         }
35231         return ret_ref;
35232 }
35233
35234 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1one_1to_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35235         LDKChannelInfo this_ptr_conv;
35236         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35237         this_ptr_conv.is_owned = false;
35238         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35239         LDKDirectionalChannelInfo val_conv;
35240         val_conv.inner = (void*)(val & (~1));
35241         val_conv.is_owned = (val & 1) || (val == 0);
35242         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35243         val_conv = DirectionalChannelInfo_clone(&val_conv);
35244         ChannelInfo_set_one_to_two(&this_ptr_conv, val_conv);
35245 }
35246
35247 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr) {
35248         LDKChannelInfo this_ptr_conv;
35249         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35250         this_ptr_conv.is_owned = false;
35251         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35252         LDKNodeId ret_var = ChannelInfo_get_node_two(&this_ptr_conv);
35253         uint64_t ret_ref = 0;
35254         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35255         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35256         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35257         ret_ref = (uint64_t)ret_var.inner;
35258         if (ret_var.is_owned) {
35259                 ret_ref |= 1;
35260         }
35261         return ret_ref;
35262 }
35263
35264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1node_1two(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35265         LDKChannelInfo this_ptr_conv;
35266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35267         this_ptr_conv.is_owned = false;
35268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35269         LDKNodeId val_conv;
35270         val_conv.inner = (void*)(val & (~1));
35271         val_conv.is_owned = (val & 1) || (val == 0);
35272         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35273         val_conv = NodeId_clone(&val_conv);
35274         ChannelInfo_set_node_two(&this_ptr_conv, val_conv);
35275 }
35276
35277 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr) {
35278         LDKChannelInfo this_ptr_conv;
35279         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35280         this_ptr_conv.is_owned = false;
35281         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35282         LDKDirectionalChannelInfo ret_var = ChannelInfo_get_two_to_one(&this_ptr_conv);
35283         uint64_t ret_ref = 0;
35284         if ((uint64_t)ret_var.inner > 4096) {
35285                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35286                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35287         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35288                 ret_ref = (uint64_t)ret_var.inner;
35289                 if (ret_var.is_owned) {
35290                         ret_ref |= 1;
35291                 }
35292         }
35293         return ret_ref;
35294 }
35295
35296 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1two_1to_1one(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35297         LDKChannelInfo this_ptr_conv;
35298         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35299         this_ptr_conv.is_owned = false;
35300         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35301         LDKDirectionalChannelInfo val_conv;
35302         val_conv.inner = (void*)(val & (~1));
35303         val_conv.is_owned = (val & 1) || (val == 0);
35304         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35305         val_conv = DirectionalChannelInfo_clone(&val_conv);
35306         ChannelInfo_set_two_to_one(&this_ptr_conv, val_conv);
35307 }
35308
35309 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr) {
35310         LDKChannelInfo this_ptr_conv;
35311         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35312         this_ptr_conv.is_owned = false;
35313         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35314         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
35315         *ret_copy = ChannelInfo_get_capacity_sats(&this_ptr_conv);
35316         uint64_t ret_ref = (uint64_t)ret_copy;
35317         return ret_ref;
35318 }
35319
35320 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1capacity_1sats(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35321         LDKChannelInfo this_ptr_conv;
35322         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35323         this_ptr_conv.is_owned = false;
35324         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35325         void* val_ptr = (void*)(((uint64_t)val) & ~1);
35326         CHECK_ACCESS(val_ptr);
35327         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
35328         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
35329         ChannelInfo_set_capacity_sats(&this_ptr_conv, val_conv);
35330 }
35331
35332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
35333         LDKChannelInfo this_ptr_conv;
35334         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35335         this_ptr_conv.is_owned = false;
35336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35337         LDKChannelAnnouncement ret_var = ChannelInfo_get_announcement_message(&this_ptr_conv);
35338         uint64_t ret_ref = 0;
35339         if ((uint64_t)ret_var.inner > 4096) {
35340                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35341                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35342         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35343                 ret_ref = (uint64_t)ret_var.inner;
35344                 if (ret_var.is_owned) {
35345                         ret_ref |= 1;
35346                 }
35347         }
35348         return ret_ref;
35349 }
35350
35351 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35352         LDKChannelInfo this_ptr_conv;
35353         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35354         this_ptr_conv.is_owned = false;
35355         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35356         LDKChannelAnnouncement val_conv;
35357         val_conv.inner = (void*)(val & (~1));
35358         val_conv.is_owned = (val & 1) || (val == 0);
35359         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35360         val_conv = ChannelAnnouncement_clone(&val_conv);
35361         ChannelInfo_set_announcement_message(&this_ptr_conv, val_conv);
35362 }
35363
35364 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) {
35365         LDKChannelFeatures features_arg_conv;
35366         features_arg_conv.inner = (void*)(features_arg & (~1));
35367         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
35368         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
35369         features_arg_conv = ChannelFeatures_clone(&features_arg_conv);
35370         LDKNodeId node_one_arg_conv;
35371         node_one_arg_conv.inner = (void*)(node_one_arg & (~1));
35372         node_one_arg_conv.is_owned = (node_one_arg & 1) || (node_one_arg == 0);
35373         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_one_arg_conv);
35374         node_one_arg_conv = NodeId_clone(&node_one_arg_conv);
35375         LDKDirectionalChannelInfo one_to_two_arg_conv;
35376         one_to_two_arg_conv.inner = (void*)(one_to_two_arg & (~1));
35377         one_to_two_arg_conv.is_owned = (one_to_two_arg & 1) || (one_to_two_arg == 0);
35378         CHECK_INNER_FIELD_ACCESS_OR_NULL(one_to_two_arg_conv);
35379         one_to_two_arg_conv = DirectionalChannelInfo_clone(&one_to_two_arg_conv);
35380         LDKNodeId node_two_arg_conv;
35381         node_two_arg_conv.inner = (void*)(node_two_arg & (~1));
35382         node_two_arg_conv.is_owned = (node_two_arg & 1) || (node_two_arg == 0);
35383         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_two_arg_conv);
35384         node_two_arg_conv = NodeId_clone(&node_two_arg_conv);
35385         LDKDirectionalChannelInfo two_to_one_arg_conv;
35386         two_to_one_arg_conv.inner = (void*)(two_to_one_arg & (~1));
35387         two_to_one_arg_conv.is_owned = (two_to_one_arg & 1) || (two_to_one_arg == 0);
35388         CHECK_INNER_FIELD_ACCESS_OR_NULL(two_to_one_arg_conv);
35389         two_to_one_arg_conv = DirectionalChannelInfo_clone(&two_to_one_arg_conv);
35390         void* capacity_sats_arg_ptr = (void*)(((uint64_t)capacity_sats_arg) & ~1);
35391         CHECK_ACCESS(capacity_sats_arg_ptr);
35392         LDKCOption_u64Z capacity_sats_arg_conv = *(LDKCOption_u64Z*)(capacity_sats_arg_ptr);
35393         capacity_sats_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)capacity_sats_arg) & ~1));
35394         LDKChannelAnnouncement announcement_message_arg_conv;
35395         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
35396         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
35397         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
35398         announcement_message_arg_conv = ChannelAnnouncement_clone(&announcement_message_arg_conv);
35399         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);
35400         uint64_t ret_ref = 0;
35401         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35402         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35403         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35404         ret_ref = (uint64_t)ret_var.inner;
35405         if (ret_var.is_owned) {
35406                 ret_ref |= 1;
35407         }
35408         return ret_ref;
35409 }
35410
35411 static inline uint64_t ChannelInfo_clone_ptr(LDKChannelInfo *NONNULL_PTR arg) {
35412         LDKChannelInfo ret_var = ChannelInfo_clone(arg);
35413 uint64_t ret_ref = 0;
35414 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35415 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35416 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35417 ret_ref = (uint64_t)ret_var.inner;
35418 if (ret_var.is_owned) {
35419         ret_ref |= 1;
35420 }
35421         return ret_ref;
35422 }
35423 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35424         LDKChannelInfo arg_conv;
35425         arg_conv.inner = (void*)(arg & (~1));
35426         arg_conv.is_owned = false;
35427         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35428         int64_t ret_val = ChannelInfo_clone_ptr(&arg_conv);
35429         return ret_val;
35430 }
35431
35432 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35433         LDKChannelInfo orig_conv;
35434         orig_conv.inner = (void*)(orig & (~1));
35435         orig_conv.is_owned = false;
35436         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35437         LDKChannelInfo ret_var = ChannelInfo_clone(&orig_conv);
35438         uint64_t ret_ref = 0;
35439         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35440         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35441         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35442         ret_ref = (uint64_t)ret_var.inner;
35443         if (ret_var.is_owned) {
35444                 ret_ref |= 1;
35445         }
35446         return ret_ref;
35447 }
35448
35449 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
35450         LDKChannelInfo obj_conv;
35451         obj_conv.inner = (void*)(obj & (~1));
35452         obj_conv.is_owned = false;
35453         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35454         LDKCVec_u8Z ret_var = ChannelInfo_write(&obj_conv);
35455         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35456         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35457         CVec_u8Z_free(ret_var);
35458         return ret_arr;
35459 }
35460
35461 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35462         LDKu8slice ser_ref;
35463         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35464         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35465         LDKCResult_ChannelInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ChannelInfoDecodeErrorZ), "LDKCResult_ChannelInfoDecodeErrorZ");
35466         *ret_conv = ChannelInfo_read(ser_ref);
35467         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35468         return (uint64_t)ret_conv;
35469 }
35470
35471 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35472         LDKRoutingFees this_obj_conv;
35473         this_obj_conv.inner = (void*)(this_obj & (~1));
35474         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35475         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35476         RoutingFees_free(this_obj_conv);
35477 }
35478
35479 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
35480         LDKRoutingFees this_ptr_conv;
35481         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35482         this_ptr_conv.is_owned = false;
35483         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35484         int32_t ret_val = RoutingFees_get_base_msat(&this_ptr_conv);
35485         return ret_val;
35486 }
35487
35488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1base_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35489         LDKRoutingFees this_ptr_conv;
35490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35491         this_ptr_conv.is_owned = false;
35492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35493         RoutingFees_set_base_msat(&this_ptr_conv, val);
35494 }
35495
35496 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1get_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr) {
35497         LDKRoutingFees this_ptr_conv;
35498         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35499         this_ptr_conv.is_owned = false;
35500         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35501         int32_t ret_val = RoutingFees_get_proportional_millionths(&this_ptr_conv);
35502         return ret_val;
35503 }
35504
35505 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RoutingFees_1set_1proportional_1millionths(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35506         LDKRoutingFees this_ptr_conv;
35507         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35508         this_ptr_conv.is_owned = false;
35509         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35510         RoutingFees_set_proportional_millionths(&this_ptr_conv, val);
35511 }
35512
35513 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) {
35514         LDKRoutingFees ret_var = RoutingFees_new(base_msat_arg, proportional_millionths_arg);
35515         uint64_t ret_ref = 0;
35516         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35517         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35518         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35519         ret_ref = (uint64_t)ret_var.inner;
35520         if (ret_var.is_owned) {
35521                 ret_ref |= 1;
35522         }
35523         return ret_ref;
35524 }
35525
35526 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RoutingFees_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
35527         LDKRoutingFees a_conv;
35528         a_conv.inner = (void*)(a & (~1));
35529         a_conv.is_owned = false;
35530         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
35531         LDKRoutingFees b_conv;
35532         b_conv.inner = (void*)(b & (~1));
35533         b_conv.is_owned = false;
35534         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
35535         jboolean ret_val = RoutingFees_eq(&a_conv, &b_conv);
35536         return ret_val;
35537 }
35538
35539 static inline uint64_t RoutingFees_clone_ptr(LDKRoutingFees *NONNULL_PTR arg) {
35540         LDKRoutingFees ret_var = RoutingFees_clone(arg);
35541 uint64_t ret_ref = 0;
35542 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35543 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35544 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35545 ret_ref = (uint64_t)ret_var.inner;
35546 if (ret_var.is_owned) {
35547         ret_ref |= 1;
35548 }
35549         return ret_ref;
35550 }
35551 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35552         LDKRoutingFees arg_conv;
35553         arg_conv.inner = (void*)(arg & (~1));
35554         arg_conv.is_owned = false;
35555         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35556         int64_t ret_val = RoutingFees_clone_ptr(&arg_conv);
35557         return ret_val;
35558 }
35559
35560 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35561         LDKRoutingFees orig_conv;
35562         orig_conv.inner = (void*)(orig & (~1));
35563         orig_conv.is_owned = false;
35564         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35565         LDKRoutingFees ret_var = RoutingFees_clone(&orig_conv);
35566         uint64_t ret_ref = 0;
35567         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35568         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35569         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35570         ret_ref = (uint64_t)ret_var.inner;
35571         if (ret_var.is_owned) {
35572                 ret_ref |= 1;
35573         }
35574         return ret_ref;
35575 }
35576
35577 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1hash(JNIEnv *env, jclass clz, int64_t o) {
35578         LDKRoutingFees o_conv;
35579         o_conv.inner = (void*)(o & (~1));
35580         o_conv.is_owned = false;
35581         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
35582         int64_t ret_val = RoutingFees_hash(&o_conv);
35583         return ret_val;
35584 }
35585
35586 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RoutingFees_1write(JNIEnv *env, jclass clz, int64_t obj) {
35587         LDKRoutingFees obj_conv;
35588         obj_conv.inner = (void*)(obj & (~1));
35589         obj_conv.is_owned = false;
35590         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35591         LDKCVec_u8Z ret_var = RoutingFees_write(&obj_conv);
35592         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35593         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35594         CVec_u8Z_free(ret_var);
35595         return ret_arr;
35596 }
35597
35598 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RoutingFees_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35599         LDKu8slice ser_ref;
35600         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35601         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35602         LDKCResult_RoutingFeesDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RoutingFeesDecodeErrorZ), "LDKCResult_RoutingFeesDecodeErrorZ");
35603         *ret_conv = RoutingFees_read(ser_ref);
35604         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35605         return (uint64_t)ret_conv;
35606 }
35607
35608 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35609         LDKNodeAnnouncementInfo this_obj_conv;
35610         this_obj_conv.inner = (void*)(this_obj & (~1));
35611         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35612         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35613         NodeAnnouncementInfo_free(this_obj_conv);
35614 }
35615
35616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
35617         LDKNodeAnnouncementInfo this_ptr_conv;
35618         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35619         this_ptr_conv.is_owned = false;
35620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35621         LDKNodeFeatures ret_var = NodeAnnouncementInfo_get_features(&this_ptr_conv);
35622         uint64_t ret_ref = 0;
35623         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35624         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35625         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35626         ret_ref = (uint64_t)ret_var.inner;
35627         if (ret_var.is_owned) {
35628                 ret_ref |= 1;
35629         }
35630         return ret_ref;
35631 }
35632
35633 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35634         LDKNodeAnnouncementInfo this_ptr_conv;
35635         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35636         this_ptr_conv.is_owned = false;
35637         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35638         LDKNodeFeatures val_conv;
35639         val_conv.inner = (void*)(val & (~1));
35640         val_conv.is_owned = (val & 1) || (val == 0);
35641         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35642         val_conv = NodeFeatures_clone(&val_conv);
35643         NodeAnnouncementInfo_set_features(&this_ptr_conv, val_conv);
35644 }
35645
35646 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr) {
35647         LDKNodeAnnouncementInfo this_ptr_conv;
35648         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35649         this_ptr_conv.is_owned = false;
35650         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35651         int32_t ret_val = NodeAnnouncementInfo_get_last_update(&this_ptr_conv);
35652         return ret_val;
35653 }
35654
35655 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1last_1update(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
35656         LDKNodeAnnouncementInfo this_ptr_conv;
35657         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35658         this_ptr_conv.is_owned = false;
35659         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35660         NodeAnnouncementInfo_set_last_update(&this_ptr_conv, val);
35661 }
35662
35663 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr) {
35664         LDKNodeAnnouncementInfo this_ptr_conv;
35665         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35666         this_ptr_conv.is_owned = false;
35667         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35668         int8_tArray ret_arr = (*env)->NewByteArray(env, 3);
35669         (*env)->SetByteArrayRegion(env, ret_arr, 0, 3, *NodeAnnouncementInfo_get_rgb(&this_ptr_conv));
35670         return ret_arr;
35671 }
35672
35673 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1rgb(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35674         LDKNodeAnnouncementInfo this_ptr_conv;
35675         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35676         this_ptr_conv.is_owned = false;
35677         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35678         LDKThreeBytes val_ref;
35679         CHECK((*env)->GetArrayLength(env, val) == 3);
35680         (*env)->GetByteArrayRegion(env, val, 0, 3, val_ref.data);
35681         NodeAnnouncementInfo_set_rgb(&this_ptr_conv, val_ref);
35682 }
35683
35684 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1alias(JNIEnv *env, jclass clz, int64_t this_ptr) {
35685         LDKNodeAnnouncementInfo this_ptr_conv;
35686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35687         this_ptr_conv.is_owned = false;
35688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35689         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
35690         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *NodeAnnouncementInfo_get_alias(&this_ptr_conv));
35691         return ret_arr;
35692 }
35693
35694 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1alias(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
35695         LDKNodeAnnouncementInfo this_ptr_conv;
35696         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35697         this_ptr_conv.is_owned = false;
35698         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35699         LDKThirtyTwoBytes val_ref;
35700         CHECK((*env)->GetArrayLength(env, val) == 32);
35701         (*env)->GetByteArrayRegion(env, val, 0, 32, val_ref.data);
35702         NodeAnnouncementInfo_set_alias(&this_ptr_conv, val_ref);
35703 }
35704
35705 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1addresses(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35706         LDKNodeAnnouncementInfo this_ptr_conv;
35707         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35708         this_ptr_conv.is_owned = false;
35709         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35710         LDKCVec_NetAddressZ val_constr;
35711         val_constr.datalen = (*env)->GetArrayLength(env, val);
35712         if (val_constr.datalen > 0)
35713                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35714         else
35715                 val_constr.data = NULL;
35716         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35717         for (size_t m = 0; m < val_constr.datalen; m++) {
35718                 int64_t val_conv_12 = val_vals[m];
35719                 void* val_conv_12_ptr = (void*)(((uint64_t)val_conv_12) & ~1);
35720                 CHECK_ACCESS(val_conv_12_ptr);
35721                 LDKNetAddress val_conv_12_conv = *(LDKNetAddress*)(val_conv_12_ptr);
35722                 val_conv_12_conv = NetAddress_clone((LDKNetAddress*)(((uint64_t)val_conv_12) & ~1));
35723                 val_constr.data[m] = val_conv_12_conv;
35724         }
35725         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35726         NodeAnnouncementInfo_set_addresses(&this_ptr_conv, val_constr);
35727 }
35728
35729 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1get_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr) {
35730         LDKNodeAnnouncementInfo this_ptr_conv;
35731         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35732         this_ptr_conv.is_owned = false;
35733         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35734         LDKNodeAnnouncement ret_var = NodeAnnouncementInfo_get_announcement_message(&this_ptr_conv);
35735         uint64_t ret_ref = 0;
35736         if ((uint64_t)ret_var.inner > 4096) {
35737                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35738                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35739         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35740                 ret_ref = (uint64_t)ret_var.inner;
35741                 if (ret_var.is_owned) {
35742                         ret_ref |= 1;
35743                 }
35744         }
35745         return ret_ref;
35746 }
35747
35748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1set_1announcement_1message(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35749         LDKNodeAnnouncementInfo this_ptr_conv;
35750         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35751         this_ptr_conv.is_owned = false;
35752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35753         LDKNodeAnnouncement val_conv;
35754         val_conv.inner = (void*)(val & (~1));
35755         val_conv.is_owned = (val & 1) || (val == 0);
35756         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35757         val_conv = NodeAnnouncement_clone(&val_conv);
35758         NodeAnnouncementInfo_set_announcement_message(&this_ptr_conv, val_conv);
35759 }
35760
35761 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) {
35762         LDKNodeFeatures features_arg_conv;
35763         features_arg_conv.inner = (void*)(features_arg & (~1));
35764         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
35765         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
35766         features_arg_conv = NodeFeatures_clone(&features_arg_conv);
35767         LDKThreeBytes rgb_arg_ref;
35768         CHECK((*env)->GetArrayLength(env, rgb_arg) == 3);
35769         (*env)->GetByteArrayRegion(env, rgb_arg, 0, 3, rgb_arg_ref.data);
35770         LDKThirtyTwoBytes alias_arg_ref;
35771         CHECK((*env)->GetArrayLength(env, alias_arg) == 32);
35772         (*env)->GetByteArrayRegion(env, alias_arg, 0, 32, alias_arg_ref.data);
35773         LDKCVec_NetAddressZ addresses_arg_constr;
35774         addresses_arg_constr.datalen = (*env)->GetArrayLength(env, addresses_arg);
35775         if (addresses_arg_constr.datalen > 0)
35776                 addresses_arg_constr.data = MALLOC(addresses_arg_constr.datalen * sizeof(LDKNetAddress), "LDKCVec_NetAddressZ Elements");
35777         else
35778                 addresses_arg_constr.data = NULL;
35779         int64_t* addresses_arg_vals = (*env)->GetLongArrayElements (env, addresses_arg, NULL);
35780         for (size_t m = 0; m < addresses_arg_constr.datalen; m++) {
35781                 int64_t addresses_arg_conv_12 = addresses_arg_vals[m];
35782                 void* addresses_arg_conv_12_ptr = (void*)(((uint64_t)addresses_arg_conv_12) & ~1);
35783                 CHECK_ACCESS(addresses_arg_conv_12_ptr);
35784                 LDKNetAddress addresses_arg_conv_12_conv = *(LDKNetAddress*)(addresses_arg_conv_12_ptr);
35785                 addresses_arg_constr.data[m] = addresses_arg_conv_12_conv;
35786         }
35787         (*env)->ReleaseLongArrayElements(env, addresses_arg, addresses_arg_vals, 0);
35788         LDKNodeAnnouncement announcement_message_arg_conv;
35789         announcement_message_arg_conv.inner = (void*)(announcement_message_arg & (~1));
35790         announcement_message_arg_conv.is_owned = (announcement_message_arg & 1) || (announcement_message_arg == 0);
35791         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_message_arg_conv);
35792         announcement_message_arg_conv = NodeAnnouncement_clone(&announcement_message_arg_conv);
35793         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_new(features_arg_conv, last_update_arg, rgb_arg_ref, alias_arg_ref, addresses_arg_constr, announcement_message_arg_conv);
35794         uint64_t ret_ref = 0;
35795         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35796         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35798         ret_ref = (uint64_t)ret_var.inner;
35799         if (ret_var.is_owned) {
35800                 ret_ref |= 1;
35801         }
35802         return ret_ref;
35803 }
35804
35805 static inline uint64_t NodeAnnouncementInfo_clone_ptr(LDKNodeAnnouncementInfo *NONNULL_PTR arg) {
35806         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(arg);
35807 uint64_t ret_ref = 0;
35808 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35809 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35810 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35811 ret_ref = (uint64_t)ret_var.inner;
35812 if (ret_var.is_owned) {
35813         ret_ref |= 1;
35814 }
35815         return ret_ref;
35816 }
35817 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
35818         LDKNodeAnnouncementInfo arg_conv;
35819         arg_conv.inner = (void*)(arg & (~1));
35820         arg_conv.is_owned = false;
35821         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
35822         int64_t ret_val = NodeAnnouncementInfo_clone_ptr(&arg_conv);
35823         return ret_val;
35824 }
35825
35826 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
35827         LDKNodeAnnouncementInfo orig_conv;
35828         orig_conv.inner = (void*)(orig & (~1));
35829         orig_conv.is_owned = false;
35830         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
35831         LDKNodeAnnouncementInfo ret_var = NodeAnnouncementInfo_clone(&orig_conv);
35832         uint64_t ret_ref = 0;
35833         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35834         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35835         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35836         ret_ref = (uint64_t)ret_var.inner;
35837         if (ret_var.is_owned) {
35838                 ret_ref |= 1;
35839         }
35840         return ret_ref;
35841 }
35842
35843 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
35844         LDKNodeAnnouncementInfo obj_conv;
35845         obj_conv.inner = (void*)(obj & (~1));
35846         obj_conv.is_owned = false;
35847         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
35848         LDKCVec_u8Z ret_var = NodeAnnouncementInfo_write(&obj_conv);
35849         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
35850         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
35851         CVec_u8Z_free(ret_var);
35852         return ret_arr;
35853 }
35854
35855 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeAnnouncementInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
35856         LDKu8slice ser_ref;
35857         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
35858         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
35859         LDKCResult_NodeAnnouncementInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeAnnouncementInfoDecodeErrorZ), "LDKCResult_NodeAnnouncementInfoDecodeErrorZ");
35860         *ret_conv = NodeAnnouncementInfo_read(ser_ref);
35861         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
35862         return (uint64_t)ret_conv;
35863 }
35864
35865 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
35866         LDKNodeInfo this_obj_conv;
35867         this_obj_conv.inner = (void*)(this_obj & (~1));
35868         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
35869         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
35870         NodeInfo_free(this_obj_conv);
35871 }
35872
35873 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1channels(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
35874         LDKNodeInfo this_ptr_conv;
35875         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35876         this_ptr_conv.is_owned = false;
35877         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35878         LDKCVec_u64Z val_constr;
35879         val_constr.datalen = (*env)->GetArrayLength(env, val);
35880         if (val_constr.datalen > 0)
35881                 val_constr.data = MALLOC(val_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35882         else
35883                 val_constr.data = NULL;
35884         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
35885         for (size_t g = 0; g < val_constr.datalen; g++) {
35886                 int64_t val_conv_6 = val_vals[g];
35887                 val_constr.data[g] = val_conv_6;
35888         }
35889         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
35890         NodeInfo_set_channels(&this_ptr_conv, val_constr);
35891 }
35892
35893 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1lowest_1inbound_1channel_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
35894         LDKNodeInfo this_ptr_conv;
35895         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35896         this_ptr_conv.is_owned = false;
35897         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35898         LDKRoutingFees ret_var = NodeInfo_get_lowest_inbound_channel_fees(&this_ptr_conv);
35899         uint64_t ret_ref = 0;
35900         if ((uint64_t)ret_var.inner > 4096) {
35901                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35902                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35903         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35904                 ret_ref = (uint64_t)ret_var.inner;
35905                 if (ret_var.is_owned) {
35906                         ret_ref |= 1;
35907                 }
35908         }
35909         return ret_ref;
35910 }
35911
35912 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) {
35913         LDKNodeInfo this_ptr_conv;
35914         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35915         this_ptr_conv.is_owned = false;
35916         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35917         LDKRoutingFees val_conv;
35918         val_conv.inner = (void*)(val & (~1));
35919         val_conv.is_owned = (val & 1) || (val == 0);
35920         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35921         val_conv = RoutingFees_clone(&val_conv);
35922         NodeInfo_set_lowest_inbound_channel_fees(&this_ptr_conv, val_conv);
35923 }
35924
35925 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1get_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr) {
35926         LDKNodeInfo this_ptr_conv;
35927         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35928         this_ptr_conv.is_owned = false;
35929         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35930         LDKNodeAnnouncementInfo ret_var = NodeInfo_get_announcement_info(&this_ptr_conv);
35931         uint64_t ret_ref = 0;
35932         if ((uint64_t)ret_var.inner > 4096) {
35933                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35934                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35935         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35936                 ret_ref = (uint64_t)ret_var.inner;
35937                 if (ret_var.is_owned) {
35938                         ret_ref |= 1;
35939                 }
35940         }
35941         return ret_ref;
35942 }
35943
35944 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_NodeInfo_1set_1announcement_1info(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
35945         LDKNodeInfo this_ptr_conv;
35946         this_ptr_conv.inner = (void*)(this_ptr & (~1));
35947         this_ptr_conv.is_owned = false;
35948         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
35949         LDKNodeAnnouncementInfo val_conv;
35950         val_conv.inner = (void*)(val & (~1));
35951         val_conv.is_owned = (val & 1) || (val == 0);
35952         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
35953         val_conv = NodeAnnouncementInfo_clone(&val_conv);
35954         NodeInfo_set_announcement_info(&this_ptr_conv, val_conv);
35955 }
35956
35957 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) {
35958         LDKCVec_u64Z channels_arg_constr;
35959         channels_arg_constr.datalen = (*env)->GetArrayLength(env, channels_arg);
35960         if (channels_arg_constr.datalen > 0)
35961                 channels_arg_constr.data = MALLOC(channels_arg_constr.datalen * sizeof(int64_t), "LDKCVec_u64Z Elements");
35962         else
35963                 channels_arg_constr.data = NULL;
35964         int64_t* channels_arg_vals = (*env)->GetLongArrayElements (env, channels_arg, NULL);
35965         for (size_t g = 0; g < channels_arg_constr.datalen; g++) {
35966                 int64_t channels_arg_conv_6 = channels_arg_vals[g];
35967                 channels_arg_constr.data[g] = channels_arg_conv_6;
35968         }
35969         (*env)->ReleaseLongArrayElements(env, channels_arg, channels_arg_vals, 0);
35970         LDKRoutingFees lowest_inbound_channel_fees_arg_conv;
35971         lowest_inbound_channel_fees_arg_conv.inner = (void*)(lowest_inbound_channel_fees_arg & (~1));
35972         lowest_inbound_channel_fees_arg_conv.is_owned = (lowest_inbound_channel_fees_arg & 1) || (lowest_inbound_channel_fees_arg == 0);
35973         CHECK_INNER_FIELD_ACCESS_OR_NULL(lowest_inbound_channel_fees_arg_conv);
35974         lowest_inbound_channel_fees_arg_conv = RoutingFees_clone(&lowest_inbound_channel_fees_arg_conv);
35975         LDKNodeAnnouncementInfo announcement_info_arg_conv;
35976         announcement_info_arg_conv.inner = (void*)(announcement_info_arg & (~1));
35977         announcement_info_arg_conv.is_owned = (announcement_info_arg & 1) || (announcement_info_arg == 0);
35978         CHECK_INNER_FIELD_ACCESS_OR_NULL(announcement_info_arg_conv);
35979         announcement_info_arg_conv = NodeAnnouncementInfo_clone(&announcement_info_arg_conv);
35980         LDKNodeInfo ret_var = NodeInfo_new(channels_arg_constr, lowest_inbound_channel_fees_arg_conv, announcement_info_arg_conv);
35981         uint64_t ret_ref = 0;
35982         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35983         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35984         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35985         ret_ref = (uint64_t)ret_var.inner;
35986         if (ret_var.is_owned) {
35987                 ret_ref |= 1;
35988         }
35989         return ret_ref;
35990 }
35991
35992 static inline uint64_t NodeInfo_clone_ptr(LDKNodeInfo *NONNULL_PTR arg) {
35993         LDKNodeInfo ret_var = NodeInfo_clone(arg);
35994 uint64_t ret_ref = 0;
35995 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
35996 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
35997 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
35998 ret_ref = (uint64_t)ret_var.inner;
35999 if (ret_var.is_owned) {
36000         ret_ref |= 1;
36001 }
36002         return ret_ref;
36003 }
36004 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36005         LDKNodeInfo arg_conv;
36006         arg_conv.inner = (void*)(arg & (~1));
36007         arg_conv.is_owned = false;
36008         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36009         int64_t ret_val = NodeInfo_clone_ptr(&arg_conv);
36010         return ret_val;
36011 }
36012
36013 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36014         LDKNodeInfo orig_conv;
36015         orig_conv.inner = (void*)(orig & (~1));
36016         orig_conv.is_owned = false;
36017         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36018         LDKNodeInfo ret_var = NodeInfo_clone(&orig_conv);
36019         uint64_t ret_ref = 0;
36020         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36021         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36022         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36023         ret_ref = (uint64_t)ret_var.inner;
36024         if (ret_var.is_owned) {
36025                 ret_ref |= 1;
36026         }
36027         return ret_ref;
36028 }
36029
36030 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NodeInfo_1write(JNIEnv *env, jclass clz, int64_t obj) {
36031         LDKNodeInfo obj_conv;
36032         obj_conv.inner = (void*)(obj & (~1));
36033         obj_conv.is_owned = false;
36034         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36035         LDKCVec_u8Z ret_var = NodeInfo_write(&obj_conv);
36036         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36037         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36038         CVec_u8Z_free(ret_var);
36039         return ret_arr;
36040 }
36041
36042 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NodeInfo_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36043         LDKu8slice ser_ref;
36044         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36045         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36046         LDKCResult_NodeInfoDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NodeInfoDecodeErrorZ), "LDKCResult_NodeInfoDecodeErrorZ");
36047         *ret_conv = NodeInfo_read(ser_ref);
36048         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36049         return (uint64_t)ret_conv;
36050 }
36051
36052 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1write(JNIEnv *env, jclass clz, int64_t obj) {
36053         LDKNetworkGraph obj_conv;
36054         obj_conv.inner = (void*)(obj & (~1));
36055         obj_conv.is_owned = false;
36056         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36057         LDKCVec_u8Z ret_var = NetworkGraph_write(&obj_conv);
36058         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36059         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36060         CVec_u8Z_free(ret_var);
36061         return ret_arr;
36062 }
36063
36064 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36065         LDKu8slice ser_ref;
36066         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36067         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36068         LDKCResult_NetworkGraphDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NetworkGraphDecodeErrorZ), "LDKCResult_NetworkGraphDecodeErrorZ");
36069         *ret_conv = NetworkGraph_read(ser_ref);
36070         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36071         return (uint64_t)ret_conv;
36072 }
36073
36074 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1new(JNIEnv *env, jclass clz, int8_tArray genesis_hash) {
36075         LDKThirtyTwoBytes genesis_hash_ref;
36076         CHECK((*env)->GetArrayLength(env, genesis_hash) == 32);
36077         (*env)->GetByteArrayRegion(env, genesis_hash, 0, 32, genesis_hash_ref.data);
36078         LDKNetworkGraph ret_var = NetworkGraph_new(genesis_hash_ref);
36079         uint64_t ret_ref = 0;
36080         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36081         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36082         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36083         ret_ref = (uint64_t)ret_var.inner;
36084         if (ret_var.is_owned) {
36085                 ret_ref |= 1;
36086         }
36087         return ret_ref;
36088 }
36089
36090 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1read_1only(JNIEnv *env, jclass clz, int64_t this_arg) {
36091         LDKNetworkGraph this_arg_conv;
36092         this_arg_conv.inner = (void*)(this_arg & (~1));
36093         this_arg_conv.is_owned = false;
36094         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36095         LDKReadOnlyNetworkGraph ret_var = NetworkGraph_read_only(&this_arg_conv);
36096         uint64_t ret_ref = 0;
36097         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36098         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36099         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36100         ret_ref = (uint64_t)ret_var.inner;
36101         if (ret_var.is_owned) {
36102                 ret_ref |= 1;
36103         }
36104         return ret_ref;
36105 }
36106
36107 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) {
36108         LDKNetworkGraph this_arg_conv;
36109         this_arg_conv.inner = (void*)(this_arg & (~1));
36110         this_arg_conv.is_owned = false;
36111         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36112         LDKNodeAnnouncement msg_conv;
36113         msg_conv.inner = (void*)(msg & (~1));
36114         msg_conv.is_owned = false;
36115         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36116         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36117         *ret_conv = NetworkGraph_update_node_from_announcement(&this_arg_conv, &msg_conv);
36118         return (uint64_t)ret_conv;
36119 }
36120
36121 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) {
36122         LDKNetworkGraph this_arg_conv;
36123         this_arg_conv.inner = (void*)(this_arg & (~1));
36124         this_arg_conv.is_owned = false;
36125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36126         LDKUnsignedNodeAnnouncement msg_conv;
36127         msg_conv.inner = (void*)(msg & (~1));
36128         msg_conv.is_owned = false;
36129         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36130         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36131         *ret_conv = NetworkGraph_update_node_from_unsigned_announcement(&this_arg_conv, &msg_conv);
36132         return (uint64_t)ret_conv;
36133 }
36134
36135 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) {
36136         LDKNetworkGraph this_arg_conv;
36137         this_arg_conv.inner = (void*)(this_arg & (~1));
36138         this_arg_conv.is_owned = false;
36139         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36140         LDKChannelAnnouncement msg_conv;
36141         msg_conv.inner = (void*)(msg & (~1));
36142         msg_conv.is_owned = false;
36143         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36144         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
36145         CHECK_ACCESS(chain_access_ptr);
36146         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36147         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
36148         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36149                 // Manually implement clone for Java trait instances
36150                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36151                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36152                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36153                 }
36154         }
36155         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36156         *ret_conv = NetworkGraph_update_channel_from_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
36157         return (uint64_t)ret_conv;
36158 }
36159
36160 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) {
36161         LDKNetworkGraph this_arg_conv;
36162         this_arg_conv.inner = (void*)(this_arg & (~1));
36163         this_arg_conv.is_owned = false;
36164         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36165         LDKUnsignedChannelAnnouncement msg_conv;
36166         msg_conv.inner = (void*)(msg & (~1));
36167         msg_conv.is_owned = false;
36168         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36169         void* chain_access_ptr = (void*)(((uint64_t)chain_access) & ~1);
36170         CHECK_ACCESS(chain_access_ptr);
36171         LDKCOption_AccessZ chain_access_conv = *(LDKCOption_AccessZ*)(chain_access_ptr);
36172         // Warning: we may need a move here but no clone is available for LDKCOption_AccessZ
36173         if (chain_access_conv.tag == LDKCOption_AccessZ_Some) {
36174                 // Manually implement clone for Java trait instances
36175                 if (chain_access_conv.some.free == LDKAccess_JCalls_free) {
36176                         // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
36177                         LDKAccess_JCalls_cloned(&chain_access_conv.some);
36178                 }
36179         }
36180         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36181         *ret_conv = NetworkGraph_update_channel_from_unsigned_announcement(&this_arg_conv, &msg_conv, chain_access_conv);
36182         return (uint64_t)ret_conv;
36183 }
36184
36185 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) {
36186         LDKNetworkGraph this_arg_conv;
36187         this_arg_conv.inner = (void*)(this_arg & (~1));
36188         this_arg_conv.is_owned = false;
36189         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36190         NetworkGraph_close_channel_from_update(&this_arg_conv, short_channel_id, is_permanent);
36191 }
36192
36193 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) {
36194         LDKNetworkGraph this_arg_conv;
36195         this_arg_conv.inner = (void*)(this_arg & (~1));
36196         this_arg_conv.is_owned = false;
36197         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36198         LDKPublicKey _node_id_ref;
36199         CHECK((*env)->GetArrayLength(env, _node_id) == 33);
36200         (*env)->GetByteArrayRegion(env, _node_id, 0, 33, _node_id_ref.compressed_form);
36201         NetworkGraph_fail_node(&this_arg_conv, _node_id_ref, is_permanent);
36202 }
36203
36204 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
36205         LDKNetworkGraph this_arg_conv;
36206         this_arg_conv.inner = (void*)(this_arg & (~1));
36207         this_arg_conv.is_owned = false;
36208         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36209         LDKChannelUpdate msg_conv;
36210         msg_conv.inner = (void*)(msg & (~1));
36211         msg_conv.is_owned = false;
36212         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36213         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36214         *ret_conv = NetworkGraph_update_channel(&this_arg_conv, &msg_conv);
36215         return (uint64_t)ret_conv;
36216 }
36217
36218 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_NetworkGraph_1update_1channel_1unsigned(JNIEnv *env, jclass clz, int64_t this_arg, int64_t msg) {
36219         LDKNetworkGraph this_arg_conv;
36220         this_arg_conv.inner = (void*)(this_arg & (~1));
36221         this_arg_conv.is_owned = false;
36222         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36223         LDKUnsignedChannelUpdate msg_conv;
36224         msg_conv.inner = (void*)(msg & (~1));
36225         msg_conv.is_owned = false;
36226         CHECK_INNER_FIELD_ACCESS_OR_NULL(msg_conv);
36227         LDKCResult_NoneLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneLightningErrorZ), "LDKCResult_NoneLightningErrorZ");
36228         *ret_conv = NetworkGraph_update_channel_unsigned(&this_arg_conv, &msg_conv);
36229         return (uint64_t)ret_conv;
36230 }
36231
36232 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ReadOnlyNetworkGraph_1get_1addresses(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray pubkey) {
36233         LDKReadOnlyNetworkGraph this_arg_conv;
36234         this_arg_conv.inner = (void*)(this_arg & (~1));
36235         this_arg_conv.is_owned = false;
36236         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36237         LDKPublicKey pubkey_ref;
36238         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
36239         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
36240         LDKCOption_CVec_NetAddressZZ *ret_copy = MALLOC(sizeof(LDKCOption_CVec_NetAddressZZ), "LDKCOption_CVec_NetAddressZZ");
36241         *ret_copy = ReadOnlyNetworkGraph_get_addresses(&this_arg_conv, pubkey_ref);
36242         uint64_t ret_ref = (uint64_t)ret_copy;
36243         return ret_ref;
36244 }
36245
36246 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36247         LDKRouteHop this_obj_conv;
36248         this_obj_conv.inner = (void*)(this_obj & (~1));
36249         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36250         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36251         RouteHop_free(this_obj_conv);
36252 }
36253
36254 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36255         LDKRouteHop this_ptr_conv;
36256         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36257         this_ptr_conv.is_owned = false;
36258         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36259         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36260         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHop_get_pubkey(&this_ptr_conv).compressed_form);
36261         return ret_arr;
36262 }
36263
36264 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36265         LDKRouteHop this_ptr_conv;
36266         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36267         this_ptr_conv.is_owned = false;
36268         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36269         LDKPublicKey val_ref;
36270         CHECK((*env)->GetArrayLength(env, val) == 33);
36271         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36272         RouteHop_set_pubkey(&this_ptr_conv, val_ref);
36273 }
36274
36275 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36276         LDKRouteHop this_ptr_conv;
36277         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36278         this_ptr_conv.is_owned = false;
36279         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36280         LDKNodeFeatures ret_var = RouteHop_get_node_features(&this_ptr_conv);
36281         uint64_t ret_ref = 0;
36282         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36283         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36284         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36285         ret_ref = (uint64_t)ret_var.inner;
36286         if (ret_var.is_owned) {
36287                 ret_ref |= 1;
36288         }
36289         return ret_ref;
36290 }
36291
36292 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1node_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36293         LDKRouteHop this_ptr_conv;
36294         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36295         this_ptr_conv.is_owned = false;
36296         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36297         LDKNodeFeatures val_conv;
36298         val_conv.inner = (void*)(val & (~1));
36299         val_conv.is_owned = (val & 1) || (val == 0);
36300         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36301         val_conv = NodeFeatures_clone(&val_conv);
36302         RouteHop_set_node_features(&this_ptr_conv, val_conv);
36303 }
36304
36305 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
36306         LDKRouteHop this_ptr_conv;
36307         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36308         this_ptr_conv.is_owned = false;
36309         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36310         int64_t ret_val = RouteHop_get_short_channel_id(&this_ptr_conv);
36311         return ret_val;
36312 }
36313
36314 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36315         LDKRouteHop this_ptr_conv;
36316         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36317         this_ptr_conv.is_owned = false;
36318         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36319         RouteHop_set_short_channel_id(&this_ptr_conv, val);
36320 }
36321
36322 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36323         LDKRouteHop this_ptr_conv;
36324         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36325         this_ptr_conv.is_owned = false;
36326         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36327         LDKChannelFeatures ret_var = RouteHop_get_channel_features(&this_ptr_conv);
36328         uint64_t ret_ref = 0;
36329         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36330         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36331         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36332         ret_ref = (uint64_t)ret_var.inner;
36333         if (ret_var.is_owned) {
36334                 ret_ref |= 1;
36335         }
36336         return ret_ref;
36337 }
36338
36339 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1channel_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36340         LDKRouteHop this_ptr_conv;
36341         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36342         this_ptr_conv.is_owned = false;
36343         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36344         LDKChannelFeatures val_conv;
36345         val_conv.inner = (void*)(val & (~1));
36346         val_conv.is_owned = (val & 1) || (val == 0);
36347         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36348         val_conv = ChannelFeatures_clone(&val_conv);
36349         RouteHop_set_channel_features(&this_ptr_conv, val_conv);
36350 }
36351
36352 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36353         LDKRouteHop this_ptr_conv;
36354         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36355         this_ptr_conv.is_owned = false;
36356         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36357         int64_t ret_val = RouteHop_get_fee_msat(&this_ptr_conv);
36358         return ret_val;
36359 }
36360
36361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1fee_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36362         LDKRouteHop this_ptr_conv;
36363         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36364         this_ptr_conv.is_owned = false;
36365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36366         RouteHop_set_fee_msat(&this_ptr_conv, val);
36367 }
36368
36369 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
36370         LDKRouteHop this_ptr_conv;
36371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36372         this_ptr_conv.is_owned = false;
36373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36374         int32_t ret_val = RouteHop_get_cltv_expiry_delta(&this_ptr_conv);
36375         return ret_val;
36376 }
36377
36378 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int32_t val) {
36379         LDKRouteHop this_ptr_conv;
36380         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36381         this_ptr_conv.is_owned = false;
36382         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36383         RouteHop_set_cltv_expiry_delta(&this_ptr_conv, val);
36384 }
36385
36386 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) {
36387         LDKPublicKey pubkey_arg_ref;
36388         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
36389         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
36390         LDKNodeFeatures node_features_arg_conv;
36391         node_features_arg_conv.inner = (void*)(node_features_arg & (~1));
36392         node_features_arg_conv.is_owned = (node_features_arg & 1) || (node_features_arg == 0);
36393         CHECK_INNER_FIELD_ACCESS_OR_NULL(node_features_arg_conv);
36394         node_features_arg_conv = NodeFeatures_clone(&node_features_arg_conv);
36395         LDKChannelFeatures channel_features_arg_conv;
36396         channel_features_arg_conv.inner = (void*)(channel_features_arg & (~1));
36397         channel_features_arg_conv.is_owned = (channel_features_arg & 1) || (channel_features_arg == 0);
36398         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_features_arg_conv);
36399         channel_features_arg_conv = ChannelFeatures_clone(&channel_features_arg_conv);
36400         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);
36401         uint64_t ret_ref = 0;
36402         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36403         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36404         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36405         ret_ref = (uint64_t)ret_var.inner;
36406         if (ret_var.is_owned) {
36407                 ret_ref |= 1;
36408         }
36409         return ret_ref;
36410 }
36411
36412 static inline uint64_t RouteHop_clone_ptr(LDKRouteHop *NONNULL_PTR arg) {
36413         LDKRouteHop ret_var = RouteHop_clone(arg);
36414 uint64_t ret_ref = 0;
36415 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36416 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36417 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36418 ret_ref = (uint64_t)ret_var.inner;
36419 if (ret_var.is_owned) {
36420         ret_ref |= 1;
36421 }
36422         return ret_ref;
36423 }
36424 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36425         LDKRouteHop arg_conv;
36426         arg_conv.inner = (void*)(arg & (~1));
36427         arg_conv.is_owned = false;
36428         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36429         int64_t ret_val = RouteHop_clone_ptr(&arg_conv);
36430         return ret_val;
36431 }
36432
36433 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36434         LDKRouteHop orig_conv;
36435         orig_conv.inner = (void*)(orig & (~1));
36436         orig_conv.is_owned = false;
36437         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36438         LDKRouteHop ret_var = RouteHop_clone(&orig_conv);
36439         uint64_t ret_ref = 0;
36440         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36441         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36442         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36443         ret_ref = (uint64_t)ret_var.inner;
36444         if (ret_var.is_owned) {
36445                 ret_ref |= 1;
36446         }
36447         return ret_ref;
36448 }
36449
36450 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
36451         LDKRouteHop o_conv;
36452         o_conv.inner = (void*)(o & (~1));
36453         o_conv.is_owned = false;
36454         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36455         int64_t ret_val = RouteHop_hash(&o_conv);
36456         return ret_val;
36457 }
36458
36459 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36460         LDKRouteHop a_conv;
36461         a_conv.inner = (void*)(a & (~1));
36462         a_conv.is_owned = false;
36463         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36464         LDKRouteHop b_conv;
36465         b_conv.inner = (void*)(b & (~1));
36466         b_conv.is_owned = false;
36467         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36468         jboolean ret_val = RouteHop_eq(&a_conv, &b_conv);
36469         return ret_val;
36470 }
36471
36472 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
36473         LDKRouteHop obj_conv;
36474         obj_conv.inner = (void*)(obj & (~1));
36475         obj_conv.is_owned = false;
36476         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36477         LDKCVec_u8Z ret_var = RouteHop_write(&obj_conv);
36478         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36479         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36480         CVec_u8Z_free(ret_var);
36481         return ret_arr;
36482 }
36483
36484 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36485         LDKu8slice ser_ref;
36486         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36487         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36488         LDKCResult_RouteHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHopDecodeErrorZ), "LDKCResult_RouteHopDecodeErrorZ");
36489         *ret_conv = RouteHop_read(ser_ref);
36490         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36491         return (uint64_t)ret_conv;
36492 }
36493
36494 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36495         LDKRoute this_obj_conv;
36496         this_obj_conv.inner = (void*)(this_obj & (~1));
36497         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36498         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36499         Route_free(this_obj_conv);
36500 }
36501
36502 JNIEXPORT jobjectArray JNICALL Java_org_ldk_impl_bindings_Route_1get_1paths(JNIEnv *env, jclass clz, int64_t this_ptr) {
36503         LDKRoute this_ptr_conv;
36504         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36505         this_ptr_conv.is_owned = false;
36506         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36507         LDKCVec_CVec_RouteHopZZ ret_var = Route_get_paths(&this_ptr_conv);
36508         jobjectArray ret_arr = NULL;
36509         ret_arr = (*env)->NewObjectArray(env, ret_var.datalen, arr_of_J_clz, NULL);
36510         ;
36511         for (size_t m = 0; m < ret_var.datalen; m++) {
36512                 LDKCVec_RouteHopZ ret_conv_12_var = ret_var.data[m];
36513                 int64_tArray ret_conv_12_arr = NULL;
36514                 ret_conv_12_arr = (*env)->NewLongArray(env, ret_conv_12_var.datalen);
36515                 int64_t *ret_conv_12_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_conv_12_arr, NULL);
36516                 for (size_t k = 0; k < ret_conv_12_var.datalen; k++) {
36517                         LDKRouteHop ret_conv_12_conv_10_var = ret_conv_12_var.data[k];
36518                         uint64_t ret_conv_12_conv_10_ref = 0;
36519                         CHECK((((uint64_t)ret_conv_12_conv_10_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36520                         CHECK((((uint64_t)&ret_conv_12_conv_10_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36521                         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_12_conv_10_var);
36522                         ret_conv_12_conv_10_ref = (uint64_t)ret_conv_12_conv_10_var.inner;
36523                         if (ret_conv_12_conv_10_var.is_owned) {
36524                                 ret_conv_12_conv_10_ref |= 1;
36525                         }
36526                         ret_conv_12_arr_ptr[k] = ret_conv_12_conv_10_ref;
36527                 }
36528                 (*env)->ReleasePrimitiveArrayCritical(env, ret_conv_12_arr, ret_conv_12_arr_ptr, 0);
36529                 FREE(ret_conv_12_var.data);
36530                 (*env)->SetObjectArrayElement(env, ret_arr, m, ret_conv_12_arr);
36531         }
36532         
36533         FREE(ret_var.data);
36534         return ret_arr;
36535 }
36536
36537 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1paths(JNIEnv *env, jclass clz, int64_t this_ptr, jobjectArray val) {
36538         LDKRoute this_ptr_conv;
36539         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36540         this_ptr_conv.is_owned = false;
36541         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36542         LDKCVec_CVec_RouteHopZZ val_constr;
36543         val_constr.datalen = (*env)->GetArrayLength(env, val);
36544         if (val_constr.datalen > 0)
36545                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
36546         else
36547                 val_constr.data = NULL;
36548         for (size_t m = 0; m < val_constr.datalen; m++) {
36549                 int64_tArray val_conv_12 = (*env)->GetObjectArrayElement(env, val, m);
36550                 LDKCVec_RouteHopZ val_conv_12_constr;
36551                 val_conv_12_constr.datalen = (*env)->GetArrayLength(env, val_conv_12);
36552                 if (val_conv_12_constr.datalen > 0)
36553                         val_conv_12_constr.data = MALLOC(val_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
36554                 else
36555                         val_conv_12_constr.data = NULL;
36556                 int64_t* val_conv_12_vals = (*env)->GetLongArrayElements (env, val_conv_12, NULL);
36557                 for (size_t k = 0; k < val_conv_12_constr.datalen; k++) {
36558                         int64_t val_conv_12_conv_10 = val_conv_12_vals[k];
36559                         LDKRouteHop val_conv_12_conv_10_conv;
36560                         val_conv_12_conv_10_conv.inner = (void*)(val_conv_12_conv_10 & (~1));
36561                         val_conv_12_conv_10_conv.is_owned = (val_conv_12_conv_10 & 1) || (val_conv_12_conv_10 == 0);
36562                         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_12_conv_10_conv);
36563                         val_conv_12_conv_10_conv = RouteHop_clone(&val_conv_12_conv_10_conv);
36564                         val_conv_12_constr.data[k] = val_conv_12_conv_10_conv;
36565                 }
36566                 (*env)->ReleaseLongArrayElements(env, val_conv_12, val_conv_12_vals, 0);
36567                 val_constr.data[m] = val_conv_12_constr;
36568         }
36569         Route_set_paths(&this_ptr_conv, val_constr);
36570 }
36571
36572 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
36573         LDKRoute this_ptr_conv;
36574         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36575         this_ptr_conv.is_owned = false;
36576         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36577         LDKPayee ret_var = Route_get_payee(&this_ptr_conv);
36578         uint64_t ret_ref = 0;
36579         if ((uint64_t)ret_var.inner > 4096) {
36580                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36581                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36582         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36583                 ret_ref = (uint64_t)ret_var.inner;
36584                 if (ret_var.is_owned) {
36585                         ret_ref |= 1;
36586                 }
36587         }
36588         return ret_ref;
36589 }
36590
36591 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Route_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36592         LDKRoute this_ptr_conv;
36593         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36594         this_ptr_conv.is_owned = false;
36595         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36596         LDKPayee val_conv;
36597         val_conv.inner = (void*)(val & (~1));
36598         val_conv.is_owned = (val & 1) || (val == 0);
36599         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36600         val_conv = Payee_clone(&val_conv);
36601         Route_set_payee(&this_ptr_conv, val_conv);
36602 }
36603
36604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1new(JNIEnv *env, jclass clz, jobjectArray paths_arg, int64_t payee_arg) {
36605         LDKCVec_CVec_RouteHopZZ paths_arg_constr;
36606         paths_arg_constr.datalen = (*env)->GetArrayLength(env, paths_arg);
36607         if (paths_arg_constr.datalen > 0)
36608                 paths_arg_constr.data = MALLOC(paths_arg_constr.datalen * sizeof(LDKCVec_RouteHopZ), "LDKCVec_CVec_RouteHopZZ Elements");
36609         else
36610                 paths_arg_constr.data = NULL;
36611         for (size_t m = 0; m < paths_arg_constr.datalen; m++) {
36612                 int64_tArray paths_arg_conv_12 = (*env)->GetObjectArrayElement(env, paths_arg, m);
36613                 LDKCVec_RouteHopZ paths_arg_conv_12_constr;
36614                 paths_arg_conv_12_constr.datalen = (*env)->GetArrayLength(env, paths_arg_conv_12);
36615                 if (paths_arg_conv_12_constr.datalen > 0)
36616                         paths_arg_conv_12_constr.data = MALLOC(paths_arg_conv_12_constr.datalen * sizeof(LDKRouteHop), "LDKCVec_RouteHopZ Elements");
36617                 else
36618                         paths_arg_conv_12_constr.data = NULL;
36619                 int64_t* paths_arg_conv_12_vals = (*env)->GetLongArrayElements (env, paths_arg_conv_12, NULL);
36620                 for (size_t k = 0; k < paths_arg_conv_12_constr.datalen; k++) {
36621                         int64_t paths_arg_conv_12_conv_10 = paths_arg_conv_12_vals[k];
36622                         LDKRouteHop paths_arg_conv_12_conv_10_conv;
36623                         paths_arg_conv_12_conv_10_conv.inner = (void*)(paths_arg_conv_12_conv_10 & (~1));
36624                         paths_arg_conv_12_conv_10_conv.is_owned = (paths_arg_conv_12_conv_10 & 1) || (paths_arg_conv_12_conv_10 == 0);
36625                         CHECK_INNER_FIELD_ACCESS_OR_NULL(paths_arg_conv_12_conv_10_conv);
36626                         paths_arg_conv_12_conv_10_conv = RouteHop_clone(&paths_arg_conv_12_conv_10_conv);
36627                         paths_arg_conv_12_constr.data[k] = paths_arg_conv_12_conv_10_conv;
36628                 }
36629                 (*env)->ReleaseLongArrayElements(env, paths_arg_conv_12, paths_arg_conv_12_vals, 0);
36630                 paths_arg_constr.data[m] = paths_arg_conv_12_constr;
36631         }
36632         LDKPayee payee_arg_conv;
36633         payee_arg_conv.inner = (void*)(payee_arg & (~1));
36634         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
36635         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
36636         payee_arg_conv = Payee_clone(&payee_arg_conv);
36637         LDKRoute ret_var = Route_new(paths_arg_constr, payee_arg_conv);
36638         uint64_t ret_ref = 0;
36639         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36640         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36641         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36642         ret_ref = (uint64_t)ret_var.inner;
36643         if (ret_var.is_owned) {
36644                 ret_ref |= 1;
36645         }
36646         return ret_ref;
36647 }
36648
36649 static inline uint64_t Route_clone_ptr(LDKRoute *NONNULL_PTR arg) {
36650         LDKRoute ret_var = Route_clone(arg);
36651 uint64_t ret_ref = 0;
36652 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36653 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36654 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36655 ret_ref = (uint64_t)ret_var.inner;
36656 if (ret_var.is_owned) {
36657         ret_ref |= 1;
36658 }
36659         return ret_ref;
36660 }
36661 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36662         LDKRoute arg_conv;
36663         arg_conv.inner = (void*)(arg & (~1));
36664         arg_conv.is_owned = false;
36665         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36666         int64_t ret_val = Route_clone_ptr(&arg_conv);
36667         return ret_val;
36668 }
36669
36670 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36671         LDKRoute orig_conv;
36672         orig_conv.inner = (void*)(orig & (~1));
36673         orig_conv.is_owned = false;
36674         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36675         LDKRoute ret_var = Route_clone(&orig_conv);
36676         uint64_t ret_ref = 0;
36677         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36678         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36679         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36680         ret_ref = (uint64_t)ret_var.inner;
36681         if (ret_var.is_owned) {
36682                 ret_ref |= 1;
36683         }
36684         return ret_ref;
36685 }
36686
36687 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1hash(JNIEnv *env, jclass clz, int64_t o) {
36688         LDKRoute o_conv;
36689         o_conv.inner = (void*)(o & (~1));
36690         o_conv.is_owned = false;
36691         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
36692         int64_t ret_val = Route_hash(&o_conv);
36693         return ret_val;
36694 }
36695
36696 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Route_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
36697         LDKRoute a_conv;
36698         a_conv.inner = (void*)(a & (~1));
36699         a_conv.is_owned = false;
36700         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
36701         LDKRoute b_conv;
36702         b_conv.inner = (void*)(b & (~1));
36703         b_conv.is_owned = false;
36704         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
36705         jboolean ret_val = Route_eq(&a_conv, &b_conv);
36706         return ret_val;
36707 }
36708
36709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1fees(JNIEnv *env, jclass clz, int64_t this_arg) {
36710         LDKRoute this_arg_conv;
36711         this_arg_conv.inner = (void*)(this_arg & (~1));
36712         this_arg_conv.is_owned = false;
36713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36714         int64_t ret_val = Route_get_total_fees(&this_arg_conv);
36715         return ret_val;
36716 }
36717
36718 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1get_1total_1amount(JNIEnv *env, jclass clz, int64_t this_arg) {
36719         LDKRoute this_arg_conv;
36720         this_arg_conv.inner = (void*)(this_arg & (~1));
36721         this_arg_conv.is_owned = false;
36722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
36723         int64_t ret_val = Route_get_total_amount(&this_arg_conv);
36724         return ret_val;
36725 }
36726
36727 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Route_1write(JNIEnv *env, jclass clz, int64_t obj) {
36728         LDKRoute obj_conv;
36729         obj_conv.inner = (void*)(obj & (~1));
36730         obj_conv.is_owned = false;
36731         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36732         LDKCVec_u8Z ret_var = Route_write(&obj_conv);
36733         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36734         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36735         CVec_u8Z_free(ret_var);
36736         return ret_arr;
36737 }
36738
36739 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Route_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36740         LDKu8slice ser_ref;
36741         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36742         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36743         LDKCResult_RouteDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteDecodeErrorZ), "LDKCResult_RouteDecodeErrorZ");
36744         *ret_conv = Route_read(ser_ref);
36745         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36746         return (uint64_t)ret_conv;
36747 }
36748
36749 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36750         LDKRouteParameters this_obj_conv;
36751         this_obj_conv.inner = (void*)(this_obj & (~1));
36752         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36753         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36754         RouteParameters_free(this_obj_conv);
36755 }
36756
36757 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1payee(JNIEnv *env, jclass clz, int64_t this_ptr) {
36758         LDKRouteParameters this_ptr_conv;
36759         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36760         this_ptr_conv.is_owned = false;
36761         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36762         LDKPayee ret_var = RouteParameters_get_payee(&this_ptr_conv);
36763         uint64_t ret_ref = 0;
36764         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36765         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36766         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36767         ret_ref = (uint64_t)ret_var.inner;
36768         if (ret_var.is_owned) {
36769                 ret_ref |= 1;
36770         }
36771         return ret_ref;
36772 }
36773
36774 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1payee(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36775         LDKRouteParameters this_ptr_conv;
36776         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36777         this_ptr_conv.is_owned = false;
36778         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36779         LDKPayee val_conv;
36780         val_conv.inner = (void*)(val & (~1));
36781         val_conv.is_owned = (val & 1) || (val == 0);
36782         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36783         val_conv = Payee_clone(&val_conv);
36784         RouteParameters_set_payee(&this_ptr_conv, val_conv);
36785 }
36786
36787 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
36788         LDKRouteParameters this_ptr_conv;
36789         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36790         this_ptr_conv.is_owned = false;
36791         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36792         int64_t ret_val = RouteParameters_get_final_value_msat(&this_ptr_conv);
36793         return ret_val;
36794 }
36795
36796 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteParameters_1set_1final_1value_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36797         LDKRouteParameters this_ptr_conv;
36798         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36799         this_ptr_conv.is_owned = false;
36800         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36801         RouteParameters_set_final_value_msat(&this_ptr_conv, val);
36802 }
36803
36804 JNIEXPORT int32_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1get_1final_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
36805         LDKRouteParameters this_ptr_conv;
36806         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36807         this_ptr_conv.is_owned = false;
36808         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36809         int32_t ret_val = RouteParameters_get_final_cltv_expiry_delta(&this_ptr_conv);
36810         return ret_val;
36811 }
36812
36813 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) {
36814         LDKRouteParameters this_ptr_conv;
36815         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36816         this_ptr_conv.is_owned = false;
36817         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36818         RouteParameters_set_final_cltv_expiry_delta(&this_ptr_conv, val);
36819 }
36820
36821 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) {
36822         LDKPayee payee_arg_conv;
36823         payee_arg_conv.inner = (void*)(payee_arg & (~1));
36824         payee_arg_conv.is_owned = (payee_arg & 1) || (payee_arg == 0);
36825         CHECK_INNER_FIELD_ACCESS_OR_NULL(payee_arg_conv);
36826         payee_arg_conv = Payee_clone(&payee_arg_conv);
36827         LDKRouteParameters ret_var = RouteParameters_new(payee_arg_conv, final_value_msat_arg, final_cltv_expiry_delta_arg);
36828         uint64_t ret_ref = 0;
36829         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36830         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36831         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36832         ret_ref = (uint64_t)ret_var.inner;
36833         if (ret_var.is_owned) {
36834                 ret_ref |= 1;
36835         }
36836         return ret_ref;
36837 }
36838
36839 static inline uint64_t RouteParameters_clone_ptr(LDKRouteParameters *NONNULL_PTR arg) {
36840         LDKRouteParameters ret_var = RouteParameters_clone(arg);
36841 uint64_t ret_ref = 0;
36842 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36843 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36844 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36845 ret_ref = (uint64_t)ret_var.inner;
36846 if (ret_var.is_owned) {
36847         ret_ref |= 1;
36848 }
36849         return ret_ref;
36850 }
36851 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
36852         LDKRouteParameters arg_conv;
36853         arg_conv.inner = (void*)(arg & (~1));
36854         arg_conv.is_owned = false;
36855         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
36856         int64_t ret_val = RouteParameters_clone_ptr(&arg_conv);
36857         return ret_val;
36858 }
36859
36860 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1clone(JNIEnv *env, jclass clz, int64_t orig) {
36861         LDKRouteParameters orig_conv;
36862         orig_conv.inner = (void*)(orig & (~1));
36863         orig_conv.is_owned = false;
36864         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
36865         LDKRouteParameters ret_var = RouteParameters_clone(&orig_conv);
36866         uint64_t ret_ref = 0;
36867         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36868         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36869         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36870         ret_ref = (uint64_t)ret_var.inner;
36871         if (ret_var.is_owned) {
36872                 ret_ref |= 1;
36873         }
36874         return ret_ref;
36875 }
36876
36877 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
36878         LDKRouteParameters obj_conv;
36879         obj_conv.inner = (void*)(obj & (~1));
36880         obj_conv.is_owned = false;
36881         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
36882         LDKCVec_u8Z ret_var = RouteParameters_write(&obj_conv);
36883         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
36884         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
36885         CVec_u8Z_free(ret_var);
36886         return ret_arr;
36887 }
36888
36889 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
36890         LDKu8slice ser_ref;
36891         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
36892         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
36893         LDKCResult_RouteParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteParametersDecodeErrorZ), "LDKCResult_RouteParametersDecodeErrorZ");
36894         *ret_conv = RouteParameters_read(ser_ref);
36895         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
36896         return (uint64_t)ret_conv;
36897 }
36898
36899 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
36900         LDKPayee this_obj_conv;
36901         this_obj_conv.inner = (void*)(this_obj & (~1));
36902         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
36903         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
36904         Payee_free(this_obj_conv);
36905 }
36906
36907 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr) {
36908         LDKPayee this_ptr_conv;
36909         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36910         this_ptr_conv.is_owned = false;
36911         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36912         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
36913         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Payee_get_pubkey(&this_ptr_conv).compressed_form);
36914         return ret_arr;
36915 }
36916
36917 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1pubkey(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
36918         LDKPayee this_ptr_conv;
36919         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36920         this_ptr_conv.is_owned = false;
36921         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36922         LDKPublicKey val_ref;
36923         CHECK((*env)->GetArrayLength(env, val) == 33);
36924         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
36925         Payee_set_pubkey(&this_ptr_conv, val_ref);
36926 }
36927
36928 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1features(JNIEnv *env, jclass clz, int64_t this_ptr) {
36929         LDKPayee this_ptr_conv;
36930         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36931         this_ptr_conv.is_owned = false;
36932         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36933         LDKInvoiceFeatures ret_var = Payee_get_features(&this_ptr_conv);
36934         uint64_t ret_ref = 0;
36935         if ((uint64_t)ret_var.inner > 4096) {
36936                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36937                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36938         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
36939                 ret_ref = (uint64_t)ret_var.inner;
36940                 if (ret_var.is_owned) {
36941                         ret_ref |= 1;
36942                 }
36943         }
36944         return ret_ref;
36945 }
36946
36947 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1features(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
36948         LDKPayee this_ptr_conv;
36949         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36950         this_ptr_conv.is_owned = false;
36951         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36952         LDKInvoiceFeatures val_conv;
36953         val_conv.inner = (void*)(val & (~1));
36954         val_conv.is_owned = (val & 1) || (val == 0);
36955         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
36956         val_conv = InvoiceFeatures_clone(&val_conv);
36957         Payee_set_features(&this_ptr_conv, val_conv);
36958 }
36959
36960 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1get_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr) {
36961         LDKPayee this_ptr_conv;
36962         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36963         this_ptr_conv.is_owned = false;
36964         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36965         LDKCVec_RouteHintZ ret_var = Payee_get_route_hints(&this_ptr_conv);
36966         int64_tArray ret_arr = NULL;
36967         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
36968         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
36969         for (size_t l = 0; l < ret_var.datalen; l++) {
36970                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
36971                 uint64_t ret_conv_11_ref = 0;
36972                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
36973                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
36974                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
36975                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
36976                 if (ret_conv_11_var.is_owned) {
36977                         ret_conv_11_ref |= 1;
36978                 }
36979                 ret_arr_ptr[l] = ret_conv_11_ref;
36980         }
36981         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
36982         FREE(ret_var.data);
36983         return ret_arr;
36984 }
36985
36986 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1route_1hints(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
36987         LDKPayee this_ptr_conv;
36988         this_ptr_conv.inner = (void*)(this_ptr & (~1));
36989         this_ptr_conv.is_owned = false;
36990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
36991         LDKCVec_RouteHintZ val_constr;
36992         val_constr.datalen = (*env)->GetArrayLength(env, val);
36993         if (val_constr.datalen > 0)
36994                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
36995         else
36996                 val_constr.data = NULL;
36997         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
36998         for (size_t l = 0; l < val_constr.datalen; l++) {
36999                 int64_t val_conv_11 = val_vals[l];
37000                 LDKRouteHint val_conv_11_conv;
37001                 val_conv_11_conv.inner = (void*)(val_conv_11 & (~1));
37002                 val_conv_11_conv.is_owned = (val_conv_11 & 1) || (val_conv_11 == 0);
37003                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_11_conv);
37004                 val_conv_11_conv = RouteHint_clone(&val_conv_11_conv);
37005                 val_constr.data[l] = val_conv_11_conv;
37006         }
37007         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37008         Payee_set_route_hints(&this_ptr_conv, val_constr);
37009 }
37010
37011 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1get_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr) {
37012         LDKPayee this_ptr_conv;
37013         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37014         this_ptr_conv.is_owned = false;
37015         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37016         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37017         *ret_copy = Payee_get_expiry_time(&this_ptr_conv);
37018         uint64_t ret_ref = (uint64_t)ret_copy;
37019         return ret_ref;
37020 }
37021
37022 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payee_1set_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37023         LDKPayee this_ptr_conv;
37024         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37025         this_ptr_conv.is_owned = false;
37026         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37027         void* val_ptr = (void*)(((uint64_t)val) & ~1);
37028         CHECK_ACCESS(val_ptr);
37029         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37030         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
37031         Payee_set_expiry_time(&this_ptr_conv, val_conv);
37032 }
37033
37034 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) {
37035         LDKPublicKey pubkey_arg_ref;
37036         CHECK((*env)->GetArrayLength(env, pubkey_arg) == 33);
37037         (*env)->GetByteArrayRegion(env, pubkey_arg, 0, 33, pubkey_arg_ref.compressed_form);
37038         LDKInvoiceFeatures features_arg_conv;
37039         features_arg_conv.inner = (void*)(features_arg & (~1));
37040         features_arg_conv.is_owned = (features_arg & 1) || (features_arg == 0);
37041         CHECK_INNER_FIELD_ACCESS_OR_NULL(features_arg_conv);
37042         features_arg_conv = InvoiceFeatures_clone(&features_arg_conv);
37043         LDKCVec_RouteHintZ route_hints_arg_constr;
37044         route_hints_arg_constr.datalen = (*env)->GetArrayLength(env, route_hints_arg);
37045         if (route_hints_arg_constr.datalen > 0)
37046                 route_hints_arg_constr.data = MALLOC(route_hints_arg_constr.datalen * sizeof(LDKRouteHint), "LDKCVec_RouteHintZ Elements");
37047         else
37048                 route_hints_arg_constr.data = NULL;
37049         int64_t* route_hints_arg_vals = (*env)->GetLongArrayElements (env, route_hints_arg, NULL);
37050         for (size_t l = 0; l < route_hints_arg_constr.datalen; l++) {
37051                 int64_t route_hints_arg_conv_11 = route_hints_arg_vals[l];
37052                 LDKRouteHint route_hints_arg_conv_11_conv;
37053                 route_hints_arg_conv_11_conv.inner = (void*)(route_hints_arg_conv_11 & (~1));
37054                 route_hints_arg_conv_11_conv.is_owned = (route_hints_arg_conv_11 & 1) || (route_hints_arg_conv_11 == 0);
37055                 CHECK_INNER_FIELD_ACCESS_OR_NULL(route_hints_arg_conv_11_conv);
37056                 route_hints_arg_conv_11_conv = RouteHint_clone(&route_hints_arg_conv_11_conv);
37057                 route_hints_arg_constr.data[l] = route_hints_arg_conv_11_conv;
37058         }
37059         (*env)->ReleaseLongArrayElements(env, route_hints_arg, route_hints_arg_vals, 0);
37060         void* expiry_time_arg_ptr = (void*)(((uint64_t)expiry_time_arg) & ~1);
37061         CHECK_ACCESS(expiry_time_arg_ptr);
37062         LDKCOption_u64Z expiry_time_arg_conv = *(LDKCOption_u64Z*)(expiry_time_arg_ptr);
37063         expiry_time_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)expiry_time_arg) & ~1));
37064         LDKPayee ret_var = Payee_new(pubkey_arg_ref, features_arg_conv, route_hints_arg_constr, expiry_time_arg_conv);
37065         uint64_t ret_ref = 0;
37066         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37067         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37068         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37069         ret_ref = (uint64_t)ret_var.inner;
37070         if (ret_var.is_owned) {
37071                 ret_ref |= 1;
37072         }
37073         return ret_ref;
37074 }
37075
37076 static inline uint64_t Payee_clone_ptr(LDKPayee *NONNULL_PTR arg) {
37077         LDKPayee ret_var = Payee_clone(arg);
37078 uint64_t ret_ref = 0;
37079 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37080 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37081 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37082 ret_ref = (uint64_t)ret_var.inner;
37083 if (ret_var.is_owned) {
37084         ret_ref |= 1;
37085 }
37086         return ret_ref;
37087 }
37088 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37089         LDKPayee arg_conv;
37090         arg_conv.inner = (void*)(arg & (~1));
37091         arg_conv.is_owned = false;
37092         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37093         int64_t ret_val = Payee_clone_ptr(&arg_conv);
37094         return ret_val;
37095 }
37096
37097 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37098         LDKPayee orig_conv;
37099         orig_conv.inner = (void*)(orig & (~1));
37100         orig_conv.is_owned = false;
37101         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37102         LDKPayee ret_var = Payee_clone(&orig_conv);
37103         uint64_t ret_ref = 0;
37104         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37105         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37106         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37107         ret_ref = (uint64_t)ret_var.inner;
37108         if (ret_var.is_owned) {
37109                 ret_ref |= 1;
37110         }
37111         return ret_ref;
37112 }
37113
37114 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1hash(JNIEnv *env, jclass clz, int64_t o) {
37115         LDKPayee o_conv;
37116         o_conv.inner = (void*)(o & (~1));
37117         o_conv.is_owned = false;
37118         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37119         int64_t ret_val = Payee_hash(&o_conv);
37120         return ret_val;
37121 }
37122
37123 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Payee_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37124         LDKPayee a_conv;
37125         a_conv.inner = (void*)(a & (~1));
37126         a_conv.is_owned = false;
37127         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37128         LDKPayee b_conv;
37129         b_conv.inner = (void*)(b & (~1));
37130         b_conv.is_owned = false;
37131         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37132         jboolean ret_val = Payee_eq(&a_conv, &b_conv);
37133         return ret_val;
37134 }
37135
37136 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Payee_1write(JNIEnv *env, jclass clz, int64_t obj) {
37137         LDKPayee obj_conv;
37138         obj_conv.inner = (void*)(obj & (~1));
37139         obj_conv.is_owned = false;
37140         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37141         LDKCVec_u8Z ret_var = Payee_write(&obj_conv);
37142         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37143         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37144         CVec_u8Z_free(ret_var);
37145         return ret_arr;
37146 }
37147
37148 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37149         LDKu8slice ser_ref;
37150         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37151         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37152         LDKCResult_PayeeDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeeDecodeErrorZ), "LDKCResult_PayeeDecodeErrorZ");
37153         *ret_conv = Payee_read(ser_ref);
37154         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37155         return (uint64_t)ret_conv;
37156 }
37157
37158 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1from_1node_1id(JNIEnv *env, jclass clz, int8_tArray pubkey) {
37159         LDKPublicKey pubkey_ref;
37160         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
37161         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
37162         LDKPayee ret_var = Payee_from_node_id(pubkey_ref);
37163         uint64_t ret_ref = 0;
37164         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37165         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37166         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37167         ret_ref = (uint64_t)ret_var.inner;
37168         if (ret_var.is_owned) {
37169                 ret_ref |= 1;
37170         }
37171         return ret_ref;
37172 }
37173
37174 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Payee_1for_1keysend(JNIEnv *env, jclass clz, int8_tArray pubkey) {
37175         LDKPublicKey pubkey_ref;
37176         CHECK((*env)->GetArrayLength(env, pubkey) == 33);
37177         (*env)->GetByteArrayRegion(env, pubkey, 0, 33, pubkey_ref.compressed_form);
37178         LDKPayee ret_var = Payee_for_keysend(pubkey_ref);
37179         uint64_t ret_ref = 0;
37180         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37181         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37182         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37183         ret_ref = (uint64_t)ret_var.inner;
37184         if (ret_var.is_owned) {
37185                 ret_ref |= 1;
37186         }
37187         return ret_ref;
37188 }
37189
37190 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37191         LDKRouteHint this_obj_conv;
37192         this_obj_conv.inner = (void*)(this_obj & (~1));
37193         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37194         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37195         RouteHint_free(this_obj_conv);
37196 }
37197
37198 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
37199         LDKRouteHint this_ptr_conv;
37200         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37201         this_ptr_conv.is_owned = false;
37202         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37203         LDKCVec_RouteHintHopZ ret_var = RouteHint_get_a(&this_ptr_conv);
37204         int64_tArray ret_arr = NULL;
37205         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
37206         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
37207         for (size_t o = 0; o < ret_var.datalen; o++) {
37208                 LDKRouteHintHop ret_conv_14_var = ret_var.data[o];
37209                 uint64_t ret_conv_14_ref = 0;
37210                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37211                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37212                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
37213                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
37214                 if (ret_conv_14_var.is_owned) {
37215                         ret_conv_14_ref |= 1;
37216                 }
37217                 ret_arr_ptr[o] = ret_conv_14_ref;
37218         }
37219         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
37220         FREE(ret_var.data);
37221         return ret_arr;
37222 }
37223
37224 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHint_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_tArray val) {
37225         LDKRouteHint this_ptr_conv;
37226         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37227         this_ptr_conv.is_owned = false;
37228         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37229         LDKCVec_RouteHintHopZ val_constr;
37230         val_constr.datalen = (*env)->GetArrayLength(env, val);
37231         if (val_constr.datalen > 0)
37232                 val_constr.data = MALLOC(val_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
37233         else
37234                 val_constr.data = NULL;
37235         int64_t* val_vals = (*env)->GetLongArrayElements (env, val, NULL);
37236         for (size_t o = 0; o < val_constr.datalen; o++) {
37237                 int64_t val_conv_14 = val_vals[o];
37238                 LDKRouteHintHop val_conv_14_conv;
37239                 val_conv_14_conv.inner = (void*)(val_conv_14 & (~1));
37240                 val_conv_14_conv.is_owned = (val_conv_14 & 1) || (val_conv_14 == 0);
37241                 CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv_14_conv);
37242                 val_conv_14_conv = RouteHintHop_clone(&val_conv_14_conv);
37243                 val_constr.data[o] = val_conv_14_conv;
37244         }
37245         (*env)->ReleaseLongArrayElements(env, val, val_vals, 0);
37246         RouteHint_set_a(&this_ptr_conv, val_constr);
37247 }
37248
37249 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1new(JNIEnv *env, jclass clz, int64_tArray a_arg) {
37250         LDKCVec_RouteHintHopZ a_arg_constr;
37251         a_arg_constr.datalen = (*env)->GetArrayLength(env, a_arg);
37252         if (a_arg_constr.datalen > 0)
37253                 a_arg_constr.data = MALLOC(a_arg_constr.datalen * sizeof(LDKRouteHintHop), "LDKCVec_RouteHintHopZ Elements");
37254         else
37255                 a_arg_constr.data = NULL;
37256         int64_t* a_arg_vals = (*env)->GetLongArrayElements (env, a_arg, NULL);
37257         for (size_t o = 0; o < a_arg_constr.datalen; o++) {
37258                 int64_t a_arg_conv_14 = a_arg_vals[o];
37259                 LDKRouteHintHop a_arg_conv_14_conv;
37260                 a_arg_conv_14_conv.inner = (void*)(a_arg_conv_14 & (~1));
37261                 a_arg_conv_14_conv.is_owned = (a_arg_conv_14 & 1) || (a_arg_conv_14 == 0);
37262                 CHECK_INNER_FIELD_ACCESS_OR_NULL(a_arg_conv_14_conv);
37263                 a_arg_conv_14_conv = RouteHintHop_clone(&a_arg_conv_14_conv);
37264                 a_arg_constr.data[o] = a_arg_conv_14_conv;
37265         }
37266         (*env)->ReleaseLongArrayElements(env, a_arg, a_arg_vals, 0);
37267         LDKRouteHint ret_var = RouteHint_new(a_arg_constr);
37268         uint64_t ret_ref = 0;
37269         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37270         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37271         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37272         ret_ref = (uint64_t)ret_var.inner;
37273         if (ret_var.is_owned) {
37274                 ret_ref |= 1;
37275         }
37276         return ret_ref;
37277 }
37278
37279 static inline uint64_t RouteHint_clone_ptr(LDKRouteHint *NONNULL_PTR arg) {
37280         LDKRouteHint ret_var = RouteHint_clone(arg);
37281 uint64_t ret_ref = 0;
37282 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37283 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37284 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37285 ret_ref = (uint64_t)ret_var.inner;
37286 if (ret_var.is_owned) {
37287         ret_ref |= 1;
37288 }
37289         return ret_ref;
37290 }
37291 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37292         LDKRouteHint arg_conv;
37293         arg_conv.inner = (void*)(arg & (~1));
37294         arg_conv.is_owned = false;
37295         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37296         int64_t ret_val = RouteHint_clone_ptr(&arg_conv);
37297         return ret_val;
37298 }
37299
37300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37301         LDKRouteHint orig_conv;
37302         orig_conv.inner = (void*)(orig & (~1));
37303         orig_conv.is_owned = false;
37304         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37305         LDKRouteHint ret_var = RouteHint_clone(&orig_conv);
37306         uint64_t ret_ref = 0;
37307         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37308         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37309         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37310         ret_ref = (uint64_t)ret_var.inner;
37311         if (ret_var.is_owned) {
37312                 ret_ref |= 1;
37313         }
37314         return ret_ref;
37315 }
37316
37317 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1hash(JNIEnv *env, jclass clz, int64_t o) {
37318         LDKRouteHint o_conv;
37319         o_conv.inner = (void*)(o & (~1));
37320         o_conv.is_owned = false;
37321         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37322         int64_t ret_val = RouteHint_hash(&o_conv);
37323         return ret_val;
37324 }
37325
37326 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHint_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37327         LDKRouteHint a_conv;
37328         a_conv.inner = (void*)(a & (~1));
37329         a_conv.is_owned = false;
37330         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37331         LDKRouteHint b_conv;
37332         b_conv.inner = (void*)(b & (~1));
37333         b_conv.is_owned = false;
37334         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37335         jboolean ret_val = RouteHint_eq(&a_conv, &b_conv);
37336         return ret_val;
37337 }
37338
37339 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHint_1write(JNIEnv *env, jclass clz, int64_t obj) {
37340         LDKRouteHint obj_conv;
37341         obj_conv.inner = (void*)(obj & (~1));
37342         obj_conv.is_owned = false;
37343         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37344         LDKCVec_u8Z ret_var = RouteHint_write(&obj_conv);
37345         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37346         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37347         CVec_u8Z_free(ret_var);
37348         return ret_arr;
37349 }
37350
37351 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHint_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37352         LDKu8slice ser_ref;
37353         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37354         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37355         LDKCResult_RouteHintDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintDecodeErrorZ), "LDKCResult_RouteHintDecodeErrorZ");
37356         *ret_conv = RouteHint_read(ser_ref);
37357         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37358         return (uint64_t)ret_conv;
37359 }
37360
37361 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37362         LDKRouteHintHop this_obj_conv;
37363         this_obj_conv.inner = (void*)(this_obj & (~1));
37364         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37365         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37366         RouteHintHop_free(this_obj_conv);
37367 }
37368
37369 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37370         LDKRouteHintHop this_ptr_conv;
37371         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37372         this_ptr_conv.is_owned = false;
37373         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37374         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
37375         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, RouteHintHop_get_src_node_id(&this_ptr_conv).compressed_form);
37376         return ret_arr;
37377 }
37378
37379 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1src_1node_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
37380         LDKRouteHintHop this_ptr_conv;
37381         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37382         this_ptr_conv.is_owned = false;
37383         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37384         LDKPublicKey val_ref;
37385         CHECK((*env)->GetArrayLength(env, val) == 33);
37386         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
37387         RouteHintHop_set_src_node_id(&this_ptr_conv, val_ref);
37388 }
37389
37390 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr) {
37391         LDKRouteHintHop this_ptr_conv;
37392         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37393         this_ptr_conv.is_owned = false;
37394         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37395         int64_t ret_val = RouteHintHop_get_short_channel_id(&this_ptr_conv);
37396         return ret_val;
37397 }
37398
37399 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1short_1channel_1id(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37400         LDKRouteHintHop this_ptr_conv;
37401         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37402         this_ptr_conv.is_owned = false;
37403         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37404         RouteHintHop_set_short_channel_id(&this_ptr_conv, val);
37405 }
37406
37407 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1fees(JNIEnv *env, jclass clz, int64_t this_ptr) {
37408         LDKRouteHintHop this_ptr_conv;
37409         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37410         this_ptr_conv.is_owned = false;
37411         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37412         LDKRoutingFees ret_var = RouteHintHop_get_fees(&this_ptr_conv);
37413         uint64_t ret_ref = 0;
37414         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37415         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37416         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37417         ret_ref = (uint64_t)ret_var.inner;
37418         if (ret_var.is_owned) {
37419                 ret_ref |= 1;
37420         }
37421         return ret_ref;
37422 }
37423
37424 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1fees(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37425         LDKRouteHintHop this_ptr_conv;
37426         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37427         this_ptr_conv.is_owned = false;
37428         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37429         LDKRoutingFees val_conv;
37430         val_conv.inner = (void*)(val & (~1));
37431         val_conv.is_owned = (val & 1) || (val == 0);
37432         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
37433         val_conv = RoutingFees_clone(&val_conv);
37434         RouteHintHop_set_fees(&this_ptr_conv, val_conv);
37435 }
37436
37437 JNIEXPORT int16_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr) {
37438         LDKRouteHintHop this_ptr_conv;
37439         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37440         this_ptr_conv.is_owned = false;
37441         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37442         int16_t ret_val = RouteHintHop_get_cltv_expiry_delta(&this_ptr_conv);
37443         return ret_val;
37444 }
37445
37446 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1cltv_1expiry_1delta(JNIEnv *env, jclass clz, int64_t this_ptr, int16_t val) {
37447         LDKRouteHintHop this_ptr_conv;
37448         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37449         this_ptr_conv.is_owned = false;
37450         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37451         RouteHintHop_set_cltv_expiry_delta(&this_ptr_conv, val);
37452 }
37453
37454 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37455         LDKRouteHintHop this_ptr_conv;
37456         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37457         this_ptr_conv.is_owned = false;
37458         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37459         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37460         *ret_copy = RouteHintHop_get_htlc_minimum_msat(&this_ptr_conv);
37461         uint64_t ret_ref = (uint64_t)ret_copy;
37462         return ret_ref;
37463 }
37464
37465 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1minimum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37466         LDKRouteHintHop this_ptr_conv;
37467         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37468         this_ptr_conv.is_owned = false;
37469         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37470         void* val_ptr = (void*)(((uint64_t)val) & ~1);
37471         CHECK_ACCESS(val_ptr);
37472         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37473         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
37474         RouteHintHop_set_htlc_minimum_msat(&this_ptr_conv, val_conv);
37475 }
37476
37477 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1get_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37478         LDKRouteHintHop this_ptr_conv;
37479         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37480         this_ptr_conv.is_owned = false;
37481         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37482         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
37483         *ret_copy = RouteHintHop_get_htlc_maximum_msat(&this_ptr_conv);
37484         uint64_t ret_ref = (uint64_t)ret_copy;
37485         return ret_ref;
37486 }
37487
37488 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1set_1htlc_1maximum_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37489         LDKRouteHintHop this_ptr_conv;
37490         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37491         this_ptr_conv.is_owned = false;
37492         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37493         void* val_ptr = (void*)(((uint64_t)val) & ~1);
37494         CHECK_ACCESS(val_ptr);
37495         LDKCOption_u64Z val_conv = *(LDKCOption_u64Z*)(val_ptr);
37496         val_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)val) & ~1));
37497         RouteHintHop_set_htlc_maximum_msat(&this_ptr_conv, val_conv);
37498 }
37499
37500 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) {
37501         LDKPublicKey src_node_id_arg_ref;
37502         CHECK((*env)->GetArrayLength(env, src_node_id_arg) == 33);
37503         (*env)->GetByteArrayRegion(env, src_node_id_arg, 0, 33, src_node_id_arg_ref.compressed_form);
37504         LDKRoutingFees fees_arg_conv;
37505         fees_arg_conv.inner = (void*)(fees_arg & (~1));
37506         fees_arg_conv.is_owned = (fees_arg & 1) || (fees_arg == 0);
37507         CHECK_INNER_FIELD_ACCESS_OR_NULL(fees_arg_conv);
37508         fees_arg_conv = RoutingFees_clone(&fees_arg_conv);
37509         void* htlc_minimum_msat_arg_ptr = (void*)(((uint64_t)htlc_minimum_msat_arg) & ~1);
37510         CHECK_ACCESS(htlc_minimum_msat_arg_ptr);
37511         LDKCOption_u64Z htlc_minimum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_minimum_msat_arg_ptr);
37512         htlc_minimum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_minimum_msat_arg) & ~1));
37513         void* htlc_maximum_msat_arg_ptr = (void*)(((uint64_t)htlc_maximum_msat_arg) & ~1);
37514         CHECK_ACCESS(htlc_maximum_msat_arg_ptr);
37515         LDKCOption_u64Z htlc_maximum_msat_arg_conv = *(LDKCOption_u64Z*)(htlc_maximum_msat_arg_ptr);
37516         htlc_maximum_msat_arg_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)htlc_maximum_msat_arg) & ~1));
37517         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);
37518         uint64_t ret_ref = 0;
37519         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37520         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37521         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37522         ret_ref = (uint64_t)ret_var.inner;
37523         if (ret_var.is_owned) {
37524                 ret_ref |= 1;
37525         }
37526         return ret_ref;
37527 }
37528
37529 static inline uint64_t RouteHintHop_clone_ptr(LDKRouteHintHop *NONNULL_PTR arg) {
37530         LDKRouteHintHop ret_var = RouteHintHop_clone(arg);
37531 uint64_t ret_ref = 0;
37532 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37533 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37534 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37535 ret_ref = (uint64_t)ret_var.inner;
37536 if (ret_var.is_owned) {
37537         ret_ref |= 1;
37538 }
37539         return ret_ref;
37540 }
37541 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
37542         LDKRouteHintHop arg_conv;
37543         arg_conv.inner = (void*)(arg & (~1));
37544         arg_conv.is_owned = false;
37545         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
37546         int64_t ret_val = RouteHintHop_clone_ptr(&arg_conv);
37547         return ret_val;
37548 }
37549
37550 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1clone(JNIEnv *env, jclass clz, int64_t orig) {
37551         LDKRouteHintHop orig_conv;
37552         orig_conv.inner = (void*)(orig & (~1));
37553         orig_conv.is_owned = false;
37554         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
37555         LDKRouteHintHop ret_var = RouteHintHop_clone(&orig_conv);
37556         uint64_t ret_ref = 0;
37557         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37558         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37559         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37560         ret_ref = (uint64_t)ret_var.inner;
37561         if (ret_var.is_owned) {
37562                 ret_ref |= 1;
37563         }
37564         return ret_ref;
37565 }
37566
37567 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1hash(JNIEnv *env, jclass clz, int64_t o) {
37568         LDKRouteHintHop o_conv;
37569         o_conv.inner = (void*)(o & (~1));
37570         o_conv.is_owned = false;
37571         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
37572         int64_t ret_val = RouteHintHop_hash(&o_conv);
37573         return ret_val;
37574 }
37575
37576 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
37577         LDKRouteHintHop a_conv;
37578         a_conv.inner = (void*)(a & (~1));
37579         a_conv.is_owned = false;
37580         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
37581         LDKRouteHintHop b_conv;
37582         b_conv.inner = (void*)(b & (~1));
37583         b_conv.is_owned = false;
37584         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
37585         jboolean ret_val = RouteHintHop_eq(&a_conv, &b_conv);
37586         return ret_val;
37587 }
37588
37589 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1write(JNIEnv *env, jclass clz, int64_t obj) {
37590         LDKRouteHintHop obj_conv;
37591         obj_conv.inner = (void*)(obj & (~1));
37592         obj_conv.is_owned = false;
37593         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37594         LDKCVec_u8Z ret_var = RouteHintHop_write(&obj_conv);
37595         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37596         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37597         CVec_u8Z_free(ret_var);
37598         return ret_arr;
37599 }
37600
37601 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RouteHintHop_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37602         LDKu8slice ser_ref;
37603         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37604         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37605         LDKCResult_RouteHintHopDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteHintHopDecodeErrorZ), "LDKCResult_RouteHintHopDecodeErrorZ");
37606         *ret_conv = RouteHintHop_read(ser_ref);
37607         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37608         return (uint64_t)ret_conv;
37609 }
37610
37611 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) {
37612         LDKPublicKey our_node_pubkey_ref;
37613         CHECK((*env)->GetArrayLength(env, our_node_pubkey) == 33);
37614         (*env)->GetByteArrayRegion(env, our_node_pubkey, 0, 33, our_node_pubkey_ref.compressed_form);
37615         LDKRouteParameters params_conv;
37616         params_conv.inner = (void*)(params & (~1));
37617         params_conv.is_owned = false;
37618         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
37619         LDKNetworkGraph network_conv;
37620         network_conv.inner = (void*)(network & (~1));
37621         network_conv.is_owned = false;
37622         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_conv);
37623         LDKCVec_ChannelDetailsZ first_hops_constr;
37624         LDKCVec_ChannelDetailsZ *first_hops_ptr = NULL;
37625         if (first_hops != NULL) {
37626                 first_hops_constr.datalen = (*env)->GetArrayLength(env, first_hops);
37627                 if (first_hops_constr.datalen > 0)
37628                         first_hops_constr.data = MALLOC(first_hops_constr.datalen * sizeof(LDKChannelDetails), "LDKCVec_ChannelDetailsZ Elements");
37629                 else
37630                         first_hops_constr.data = NULL;
37631                 int64_t* first_hops_vals = (*env)->GetLongArrayElements (env, first_hops, NULL);
37632                 for (size_t q = 0; q < first_hops_constr.datalen; q++) {
37633                         int64_t first_hops_conv_16 = first_hops_vals[q];
37634                         LDKChannelDetails first_hops_conv_16_conv;
37635                         first_hops_conv_16_conv.inner = (void*)(first_hops_conv_16 & (~1));
37636                         first_hops_conv_16_conv.is_owned = (first_hops_conv_16 & 1) || (first_hops_conv_16 == 0);
37637                         CHECK_INNER_FIELD_ACCESS_OR_NULL(first_hops_conv_16_conv);
37638                         first_hops_constr.data[q] = first_hops_conv_16_conv;
37639                 }
37640                 (*env)->ReleaseLongArrayElements(env, first_hops, first_hops_vals, 0);
37641                 first_hops_ptr = &first_hops_constr;
37642         }
37643         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
37644         CHECK_ACCESS(logger_ptr);
37645         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37646         if (logger_conv.free == LDKLogger_JCalls_free) {
37647                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37648                 LDKLogger_JCalls_cloned(&logger_conv);
37649         }
37650         void* scorer_ptr = (void*)(((uint64_t)scorer) & ~1);
37651         if (!(scorer & 1)) { CHECK_ACCESS(scorer_ptr); }
37652         LDKScore* scorer_conv = (LDKScore*)scorer_ptr;
37653         LDKCResult_RouteLightningErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_RouteLightningErrorZ), "LDKCResult_RouteLightningErrorZ");
37654         *ret_conv = find_route(our_node_pubkey_ref, &params_conv, &network_conv, first_hops_ptr, logger_conv, scorer_conv);
37655         if (first_hops_ptr != NULL) { FREE(first_hops_constr.data); }
37656         return (uint64_t)ret_conv;
37657 }
37658
37659 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Scorer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37660         LDKScorer this_obj_conv;
37661         this_obj_conv.inner = (void*)(this_obj & (~1));
37662         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37663         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37664         Scorer_free(this_obj_conv);
37665 }
37666
37667 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37668         LDKScoringParameters this_obj_conv;
37669         this_obj_conv.inner = (void*)(this_obj & (~1));
37670         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37671         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37672         ScoringParameters_free(this_obj_conv);
37673 }
37674
37675 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37676         LDKScoringParameters this_ptr_conv;
37677         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37678         this_ptr_conv.is_owned = false;
37679         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37680         int64_t ret_val = ScoringParameters_get_base_penalty_msat(&this_ptr_conv);
37681         return ret_val;
37682 }
37683
37684 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1base_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37685         LDKScoringParameters this_ptr_conv;
37686         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37687         this_ptr_conv.is_owned = false;
37688         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37689         ScoringParameters_set_base_penalty_msat(&this_ptr_conv, val);
37690 }
37691
37692 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr) {
37693         LDKScoringParameters this_ptr_conv;
37694         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37695         this_ptr_conv.is_owned = false;
37696         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37697         int64_t ret_val = ScoringParameters_get_failure_penalty_msat(&this_ptr_conv);
37698         return ret_val;
37699 }
37700
37701 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1set_1failure_1penalty_1msat(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
37702         LDKScoringParameters this_ptr_conv;
37703         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37704         this_ptr_conv.is_owned = false;
37705         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37706         ScoringParameters_set_failure_penalty_msat(&this_ptr_conv, val);
37707 }
37708
37709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1get_1failure_1penalty_1half_1life(JNIEnv *env, jclass clz, int64_t this_ptr) {
37710         LDKScoringParameters this_ptr_conv;
37711         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37712         this_ptr_conv.is_owned = false;
37713         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37714         int64_t ret_val = ScoringParameters_get_failure_penalty_half_life(&this_ptr_conv);
37715         return ret_val;
37716 }
37717
37718 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) {
37719         LDKScoringParameters this_ptr_conv;
37720         this_ptr_conv.inner = (void*)(this_ptr & (~1));
37721         this_ptr_conv.is_owned = false;
37722         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
37723         ScoringParameters_set_failure_penalty_half_life(&this_ptr_conv, val);
37724 }
37725
37726 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) {
37727         LDKScoringParameters ret_var = ScoringParameters_new(base_penalty_msat_arg, failure_penalty_msat_arg, failure_penalty_half_life_arg);
37728         uint64_t ret_ref = 0;
37729         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37730         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37731         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37732         ret_ref = (uint64_t)ret_var.inner;
37733         if (ret_var.is_owned) {
37734                 ret_ref |= 1;
37735         }
37736         return ret_ref;
37737 }
37738
37739 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1write(JNIEnv *env, jclass clz, int64_t obj) {
37740         LDKScoringParameters obj_conv;
37741         obj_conv.inner = (void*)(obj & (~1));
37742         obj_conv.is_owned = false;
37743         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37744         LDKCVec_u8Z ret_var = ScoringParameters_write(&obj_conv);
37745         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37746         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37747         CVec_u8Z_free(ret_var);
37748         return ret_arr;
37749 }
37750
37751 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37752         LDKu8slice ser_ref;
37753         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37754         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37755         LDKCResult_ScoringParametersDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScoringParametersDecodeErrorZ), "LDKCResult_ScoringParametersDecodeErrorZ");
37756         *ret_conv = ScoringParameters_read(ser_ref);
37757         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37758         return (uint64_t)ret_conv;
37759 }
37760
37761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1new(JNIEnv *env, jclass clz, int64_t params) {
37762         LDKScoringParameters params_conv;
37763         params_conv.inner = (void*)(params & (~1));
37764         params_conv.is_owned = (params & 1) || (params == 0);
37765         CHECK_INNER_FIELD_ACCESS_OR_NULL(params_conv);
37766         // Warning: we need a move here but no clone is available for LDKScoringParameters
37767         LDKScorer ret_var = Scorer_new(params_conv);
37768         uint64_t ret_ref = 0;
37769         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37770         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37771         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37772         ret_ref = (uint64_t)ret_var.inner;
37773         if (ret_var.is_owned) {
37774                 ret_ref |= 1;
37775         }
37776         return ret_ref;
37777 }
37778
37779 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1default(JNIEnv *env, jclass clz) {
37780         LDKScorer ret_var = Scorer_default();
37781         uint64_t ret_ref = 0;
37782         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37783         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37784         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37785         ret_ref = (uint64_t)ret_var.inner;
37786         if (ret_var.is_owned) {
37787                 ret_ref |= 1;
37788         }
37789         return ret_ref;
37790 }
37791
37792 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ScoringParameters_1default(JNIEnv *env, jclass clz) {
37793         LDKScoringParameters ret_var = ScoringParameters_default();
37794         uint64_t ret_ref = 0;
37795         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37796         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37797         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37798         ret_ref = (uint64_t)ret_var.inner;
37799         if (ret_var.is_owned) {
37800                 ret_ref |= 1;
37801         }
37802         return ret_ref;
37803 }
37804
37805 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1as_1Score(JNIEnv *env, jclass clz, int64_t this_arg) {
37806         LDKScorer this_arg_conv;
37807         this_arg_conv.inner = (void*)(this_arg & (~1));
37808         this_arg_conv.is_owned = false;
37809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37810         LDKScore* ret_ret = MALLOC(sizeof(LDKScore), "LDKScore");
37811         *ret_ret = Scorer_as_Score(&this_arg_conv);
37812         return (uint64_t)ret_ret;
37813 }
37814
37815 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Scorer_1write(JNIEnv *env, jclass clz, int64_t obj) {
37816         LDKScorer obj_conv;
37817         obj_conv.inner = (void*)(obj & (~1));
37818         obj_conv.is_owned = false;
37819         CHECK_INNER_FIELD_ACCESS_OR_NULL(obj_conv);
37820         LDKCVec_u8Z ret_var = Scorer_write(&obj_conv);
37821         int8_tArray ret_arr = (*env)->NewByteArray(env, ret_var.datalen);
37822         (*env)->SetByteArrayRegion(env, ret_arr, 0, ret_var.datalen, ret_var.data);
37823         CVec_u8Z_free(ret_var);
37824         return ret_arr;
37825 }
37826
37827 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Scorer_1read(JNIEnv *env, jclass clz, int8_tArray ser) {
37828         LDKu8slice ser_ref;
37829         ser_ref.datalen = (*env)->GetArrayLength(env, ser);
37830         ser_ref.data = (*env)->GetByteArrayElements (env, ser, NULL);
37831         LDKCResult_ScorerDecodeErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ScorerDecodeErrorZ), "LDKCResult_ScorerDecodeErrorZ");
37832         *ret_conv = Scorer_read(ser_ref);
37833         (*env)->ReleaseByteArrayElements(env, ser, (int8_t*)ser_ref.data, 0);
37834         return (uint64_t)ret_conv;
37835 }
37836
37837 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37838         LDKFilesystemPersister this_obj_conv;
37839         this_obj_conv.inner = (void*)(this_obj & (~1));
37840         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37841         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37842         FilesystemPersister_free(this_obj_conv);
37843 }
37844
37845 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1new(JNIEnv *env, jclass clz, jstring path_to_channel_data) {
37846         LDKStr path_to_channel_data_conv = java_to_owned_str(env, path_to_channel_data);
37847         LDKFilesystemPersister ret_var = FilesystemPersister_new(path_to_channel_data_conv);
37848         uint64_t ret_ref = 0;
37849         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37850         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37851         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37852         ret_ref = (uint64_t)ret_var.inner;
37853         if (ret_var.is_owned) {
37854                 ret_ref |= 1;
37855         }
37856         return ret_ref;
37857 }
37858
37859 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1get_1data_1dir(JNIEnv *env, jclass clz, int64_t this_arg) {
37860         LDKFilesystemPersister this_arg_conv;
37861         this_arg_conv.inner = (void*)(this_arg & (~1));
37862         this_arg_conv.is_owned = false;
37863         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37864         LDKStr ret_str = FilesystemPersister_get_data_dir(&this_arg_conv);
37865         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
37866         Str_free(ret_str);
37867         return ret_conv;
37868 }
37869
37870 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1persist_1manager(JNIEnv *env, jclass clz, jstring data_dir, int64_t manager) {
37871         LDKStr data_dir_conv = java_to_owned_str(env, data_dir);
37872         LDKChannelManager manager_conv;
37873         manager_conv.inner = (void*)(manager & (~1));
37874         manager_conv.is_owned = false;
37875         CHECK_INNER_FIELD_ACCESS_OR_NULL(manager_conv);
37876         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
37877         *ret_conv = FilesystemPersister_persist_manager(data_dir_conv, &manager_conv);
37878         return (uint64_t)ret_conv;
37879 }
37880
37881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1read_1channelmonitors(JNIEnv *env, jclass clz, int64_t this_arg, int64_t keys_manager) {
37882         LDKFilesystemPersister this_arg_conv;
37883         this_arg_conv.inner = (void*)(this_arg & (~1));
37884         this_arg_conv.is_owned = false;
37885         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37886         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
37887         CHECK_ACCESS(keys_manager_ptr);
37888         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
37889         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
37890                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37891                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
37892         }
37893         LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ), "LDKCResult_CVec_C2Tuple_BlockHashChannelMonitorZZErrorZ");
37894         *ret_conv = FilesystemPersister_read_channelmonitors(&this_arg_conv, keys_manager_conv);
37895         return (uint64_t)ret_conv;
37896 }
37897
37898 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_FilesystemPersister_1as_1Persist(JNIEnv *env, jclass clz, int64_t this_arg) {
37899         LDKFilesystemPersister this_arg_conv;
37900         this_arg_conv.inner = (void*)(this_arg & (~1));
37901         this_arg_conv.is_owned = false;
37902         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37903         LDKPersist* ret_ret = MALLOC(sizeof(LDKPersist), "LDKPersist");
37904         *ret_ret = FilesystemPersister_as_Persist(&this_arg_conv);
37905         return (uint64_t)ret_ret;
37906 }
37907
37908 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
37909         LDKBackgroundProcessor this_obj_conv;
37910         this_obj_conv.inner = (void*)(this_obj & (~1));
37911         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
37912         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
37913         BackgroundProcessor_free(this_obj_conv);
37914 }
37915
37916 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ChannelManagerPersister_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
37917         if ((this_ptr & 1) != 0) return;
37918         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
37919         CHECK_ACCESS(this_ptr_ptr);
37920         LDKChannelManagerPersister this_ptr_conv = *(LDKChannelManagerPersister*)(this_ptr_ptr);
37921         FREE((void*)this_ptr);
37922         ChannelManagerPersister_free(this_ptr_conv);
37923 }
37924
37925 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) {
37926         void* persister_ptr = (void*)(((uint64_t)persister) & ~1);
37927         CHECK_ACCESS(persister_ptr);
37928         LDKChannelManagerPersister persister_conv = *(LDKChannelManagerPersister*)(persister_ptr);
37929         if (persister_conv.free == LDKChannelManagerPersister_JCalls_free) {
37930                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37931                 LDKChannelManagerPersister_JCalls_cloned(&persister_conv);
37932         }
37933         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
37934         CHECK_ACCESS(event_handler_ptr);
37935         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
37936         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
37937                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37938                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
37939         }
37940         LDKChainMonitor chain_monitor_conv;
37941         chain_monitor_conv.inner = (void*)(chain_monitor & (~1));
37942         chain_monitor_conv.is_owned = false;
37943         CHECK_INNER_FIELD_ACCESS_OR_NULL(chain_monitor_conv);
37944         LDKChannelManager channel_manager_conv;
37945         channel_manager_conv.inner = (void*)(channel_manager & (~1));
37946         channel_manager_conv.is_owned = false;
37947         CHECK_INNER_FIELD_ACCESS_OR_NULL(channel_manager_conv);
37948         LDKNetGraphMsgHandler net_graph_msg_handler_conv;
37949         net_graph_msg_handler_conv.inner = (void*)(net_graph_msg_handler & (~1));
37950         net_graph_msg_handler_conv.is_owned = (net_graph_msg_handler & 1) || (net_graph_msg_handler == 0);
37951         CHECK_INNER_FIELD_ACCESS_OR_NULL(net_graph_msg_handler_conv);
37952         LDKPeerManager peer_manager_conv;
37953         peer_manager_conv.inner = (void*)(peer_manager & (~1));
37954         peer_manager_conv.is_owned = false;
37955         CHECK_INNER_FIELD_ACCESS_OR_NULL(peer_manager_conv);
37956         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
37957         CHECK_ACCESS(logger_ptr);
37958         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
37959         if (logger_conv.free == LDKLogger_JCalls_free) {
37960                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
37961                 LDKLogger_JCalls_cloned(&logger_conv);
37962         }
37963         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);
37964         uint64_t ret_ref = 0;
37965         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
37966         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
37967         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
37968         ret_ref = (uint64_t)ret_var.inner;
37969         if (ret_var.is_owned) {
37970                 ret_ref |= 1;
37971         }
37972         return ret_ref;
37973 }
37974
37975 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1join(JNIEnv *env, jclass clz, int64_t this_arg) {
37976         LDKBackgroundProcessor this_arg_conv;
37977         this_arg_conv.inner = (void*)(this_arg & (~1));
37978         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
37979         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37980         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
37981         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
37982         *ret_conv = BackgroundProcessor_join(this_arg_conv);
37983         return (uint64_t)ret_conv;
37984 }
37985
37986 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_BackgroundProcessor_1stop(JNIEnv *env, jclass clz, int64_t this_arg) {
37987         LDKBackgroundProcessor this_arg_conv;
37988         this_arg_conv.inner = (void*)(this_arg & (~1));
37989         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
37990         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
37991         // Warning: we need a move here but no clone is available for LDKBackgroundProcessor
37992         LDKCResult_NoneErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneErrorZ), "LDKCResult_NoneErrorZ");
37993         *ret_conv = BackgroundProcessor_stop(this_arg_conv);
37994         return (uint64_t)ret_conv;
37995 }
37996
37997 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_check_1platform(JNIEnv *env, jclass clz) {
37998         check_platform();
37999 }
38000
38001 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Invoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38002         LDKInvoice this_obj_conv;
38003         this_obj_conv.inner = (void*)(this_obj & (~1));
38004         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38005         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38006         Invoice_free(this_obj_conv);
38007 }
38008
38009 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38010         LDKInvoice a_conv;
38011         a_conv.inner = (void*)(a & (~1));
38012         a_conv.is_owned = false;
38013         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38014         LDKInvoice b_conv;
38015         b_conv.inner = (void*)(b & (~1));
38016         b_conv.is_owned = false;
38017         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38018         jboolean ret_val = Invoice_eq(&a_conv, &b_conv);
38019         return ret_val;
38020 }
38021
38022 static inline uint64_t Invoice_clone_ptr(LDKInvoice *NONNULL_PTR arg) {
38023         LDKInvoice ret_var = Invoice_clone(arg);
38024 uint64_t ret_ref = 0;
38025 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38026 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38027 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38028 ret_ref = (uint64_t)ret_var.inner;
38029 if (ret_var.is_owned) {
38030         ret_ref |= 1;
38031 }
38032         return ret_ref;
38033 }
38034 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38035         LDKInvoice arg_conv;
38036         arg_conv.inner = (void*)(arg & (~1));
38037         arg_conv.is_owned = false;
38038         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38039         int64_t ret_val = Invoice_clone_ptr(&arg_conv);
38040         return ret_val;
38041 }
38042
38043 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38044         LDKInvoice orig_conv;
38045         orig_conv.inner = (void*)(orig & (~1));
38046         orig_conv.is_owned = false;
38047         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38048         LDKInvoice ret_var = Invoice_clone(&orig_conv);
38049         uint64_t ret_ref = 0;
38050         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38051         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38052         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38053         ret_ref = (uint64_t)ret_var.inner;
38054         if (ret_var.is_owned) {
38055                 ret_ref |= 1;
38056         }
38057         return ret_ref;
38058 }
38059
38060 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38061         LDKSignedRawInvoice this_obj_conv;
38062         this_obj_conv.inner = (void*)(this_obj & (~1));
38063         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38064         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38065         SignedRawInvoice_free(this_obj_conv);
38066 }
38067
38068 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38069         LDKSignedRawInvoice a_conv;
38070         a_conv.inner = (void*)(a & (~1));
38071         a_conv.is_owned = false;
38072         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38073         LDKSignedRawInvoice b_conv;
38074         b_conv.inner = (void*)(b & (~1));
38075         b_conv.is_owned = false;
38076         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38077         jboolean ret_val = SignedRawInvoice_eq(&a_conv, &b_conv);
38078         return ret_val;
38079 }
38080
38081 static inline uint64_t SignedRawInvoice_clone_ptr(LDKSignedRawInvoice *NONNULL_PTR arg) {
38082         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(arg);
38083 uint64_t ret_ref = 0;
38084 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38085 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38086 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38087 ret_ref = (uint64_t)ret_var.inner;
38088 if (ret_var.is_owned) {
38089         ret_ref |= 1;
38090 }
38091         return ret_ref;
38092 }
38093 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38094         LDKSignedRawInvoice arg_conv;
38095         arg_conv.inner = (void*)(arg & (~1));
38096         arg_conv.is_owned = false;
38097         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38098         int64_t ret_val = SignedRawInvoice_clone_ptr(&arg_conv);
38099         return ret_val;
38100 }
38101
38102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38103         LDKSignedRawInvoice orig_conv;
38104         orig_conv.inner = (void*)(orig & (~1));
38105         orig_conv.is_owned = false;
38106         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38107         LDKSignedRawInvoice ret_var = SignedRawInvoice_clone(&orig_conv);
38108         uint64_t ret_ref = 0;
38109         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38110         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38111         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38112         ret_ref = (uint64_t)ret_var.inner;
38113         if (ret_var.is_owned) {
38114                 ret_ref |= 1;
38115         }
38116         return ret_ref;
38117 }
38118
38119 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38120         LDKRawInvoice this_obj_conv;
38121         this_obj_conv.inner = (void*)(this_obj & (~1));
38122         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38123         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38124         RawInvoice_free(this_obj_conv);
38125 }
38126
38127 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1get_1data(JNIEnv *env, jclass clz, int64_t this_ptr) {
38128         LDKRawInvoice this_ptr_conv;
38129         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38130         this_ptr_conv.is_owned = false;
38131         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38132         LDKRawDataPart ret_var = RawInvoice_get_data(&this_ptr_conv);
38133         uint64_t ret_ref = 0;
38134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38137         ret_ref = (uint64_t)ret_var.inner;
38138         if (ret_var.is_owned) {
38139                 ret_ref |= 1;
38140         }
38141         return ret_ref;
38142 }
38143
38144 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawInvoice_1set_1data(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38145         LDKRawInvoice this_ptr_conv;
38146         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38147         this_ptr_conv.is_owned = false;
38148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38149         LDKRawDataPart val_conv;
38150         val_conv.inner = (void*)(val & (~1));
38151         val_conv.is_owned = (val & 1) || (val == 0);
38152         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38153         val_conv = RawDataPart_clone(&val_conv);
38154         RawInvoice_set_data(&this_ptr_conv, val_conv);
38155 }
38156
38157 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawInvoice_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38158         LDKRawInvoice a_conv;
38159         a_conv.inner = (void*)(a & (~1));
38160         a_conv.is_owned = false;
38161         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38162         LDKRawInvoice b_conv;
38163         b_conv.inner = (void*)(b & (~1));
38164         b_conv.is_owned = false;
38165         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38166         jboolean ret_val = RawInvoice_eq(&a_conv, &b_conv);
38167         return ret_val;
38168 }
38169
38170 static inline uint64_t RawInvoice_clone_ptr(LDKRawInvoice *NONNULL_PTR arg) {
38171         LDKRawInvoice ret_var = RawInvoice_clone(arg);
38172 uint64_t ret_ref = 0;
38173 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38174 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38175 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38176 ret_ref = (uint64_t)ret_var.inner;
38177 if (ret_var.is_owned) {
38178         ret_ref |= 1;
38179 }
38180         return ret_ref;
38181 }
38182 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38183         LDKRawInvoice arg_conv;
38184         arg_conv.inner = (void*)(arg & (~1));
38185         arg_conv.is_owned = false;
38186         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38187         int64_t ret_val = RawInvoice_clone_ptr(&arg_conv);
38188         return ret_val;
38189 }
38190
38191 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38192         LDKRawInvoice orig_conv;
38193         orig_conv.inner = (void*)(orig & (~1));
38194         orig_conv.is_owned = false;
38195         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38196         LDKRawInvoice ret_var = RawInvoice_clone(&orig_conv);
38197         uint64_t ret_ref = 0;
38198         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38199         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38200         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38201         ret_ref = (uint64_t)ret_var.inner;
38202         if (ret_var.is_owned) {
38203                 ret_ref |= 1;
38204         }
38205         return ret_ref;
38206 }
38207
38208 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38209         LDKRawDataPart this_obj_conv;
38210         this_obj_conv.inner = (void*)(this_obj & (~1));
38211         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38212         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38213         RawDataPart_free(this_obj_conv);
38214 }
38215
38216 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1get_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr) {
38217         LDKRawDataPart this_ptr_conv;
38218         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38219         this_ptr_conv.is_owned = false;
38220         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38221         LDKPositiveTimestamp ret_var = RawDataPart_get_timestamp(&this_ptr_conv);
38222         uint64_t ret_ref = 0;
38223         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38224         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38225         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38226         ret_ref = (uint64_t)ret_var.inner;
38227         if (ret_var.is_owned) {
38228                 ret_ref |= 1;
38229         }
38230         return ret_ref;
38231 }
38232
38233 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RawDataPart_1set_1timestamp(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38234         LDKRawDataPart this_ptr_conv;
38235         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38236         this_ptr_conv.is_owned = false;
38237         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38238         LDKPositiveTimestamp val_conv;
38239         val_conv.inner = (void*)(val & (~1));
38240         val_conv.is_owned = (val & 1) || (val == 0);
38241         CHECK_INNER_FIELD_ACCESS_OR_NULL(val_conv);
38242         val_conv = PositiveTimestamp_clone(&val_conv);
38243         RawDataPart_set_timestamp(&this_ptr_conv, val_conv);
38244 }
38245
38246 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RawDataPart_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38247         LDKRawDataPart a_conv;
38248         a_conv.inner = (void*)(a & (~1));
38249         a_conv.is_owned = false;
38250         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38251         LDKRawDataPart b_conv;
38252         b_conv.inner = (void*)(b & (~1));
38253         b_conv.is_owned = false;
38254         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38255         jboolean ret_val = RawDataPart_eq(&a_conv, &b_conv);
38256         return ret_val;
38257 }
38258
38259 static inline uint64_t RawDataPart_clone_ptr(LDKRawDataPart *NONNULL_PTR arg) {
38260         LDKRawDataPart ret_var = RawDataPart_clone(arg);
38261 uint64_t ret_ref = 0;
38262 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38263 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38264 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38265 ret_ref = (uint64_t)ret_var.inner;
38266 if (ret_var.is_owned) {
38267         ret_ref |= 1;
38268 }
38269         return ret_ref;
38270 }
38271 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38272         LDKRawDataPart arg_conv;
38273         arg_conv.inner = (void*)(arg & (~1));
38274         arg_conv.is_owned = false;
38275         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38276         int64_t ret_val = RawDataPart_clone_ptr(&arg_conv);
38277         return ret_val;
38278 }
38279
38280 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawDataPart_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38281         LDKRawDataPart orig_conv;
38282         orig_conv.inner = (void*)(orig & (~1));
38283         orig_conv.is_owned = false;
38284         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38285         LDKRawDataPart ret_var = RawDataPart_clone(&orig_conv);
38286         uint64_t ret_ref = 0;
38287         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38288         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38289         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38290         ret_ref = (uint64_t)ret_var.inner;
38291         if (ret_var.is_owned) {
38292                 ret_ref |= 1;
38293         }
38294         return ret_ref;
38295 }
38296
38297 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38298         LDKPositiveTimestamp this_obj_conv;
38299         this_obj_conv.inner = (void*)(this_obj & (~1));
38300         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38301         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38302         PositiveTimestamp_free(this_obj_conv);
38303 }
38304
38305 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38306         LDKPositiveTimestamp a_conv;
38307         a_conv.inner = (void*)(a & (~1));
38308         a_conv.is_owned = false;
38309         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38310         LDKPositiveTimestamp b_conv;
38311         b_conv.inner = (void*)(b & (~1));
38312         b_conv.is_owned = false;
38313         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38314         jboolean ret_val = PositiveTimestamp_eq(&a_conv, &b_conv);
38315         return ret_val;
38316 }
38317
38318 static inline uint64_t PositiveTimestamp_clone_ptr(LDKPositiveTimestamp *NONNULL_PTR arg) {
38319         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(arg);
38320 uint64_t ret_ref = 0;
38321 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38322 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38323 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38324 ret_ref = (uint64_t)ret_var.inner;
38325 if (ret_var.is_owned) {
38326         ret_ref |= 1;
38327 }
38328         return ret_ref;
38329 }
38330 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38331         LDKPositiveTimestamp arg_conv;
38332         arg_conv.inner = (void*)(arg & (~1));
38333         arg_conv.is_owned = false;
38334         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38335         int64_t ret_val = PositiveTimestamp_clone_ptr(&arg_conv);
38336         return ret_val;
38337 }
38338
38339 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38340         LDKPositiveTimestamp orig_conv;
38341         orig_conv.inner = (void*)(orig & (~1));
38342         orig_conv.is_owned = false;
38343         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38344         LDKPositiveTimestamp ret_var = PositiveTimestamp_clone(&orig_conv);
38345         uint64_t ret_ref = 0;
38346         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38347         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38348         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38349         ret_ref = (uint64_t)ret_var.inner;
38350         if (ret_var.is_owned) {
38351                 ret_ref |= 1;
38352         }
38353         return ret_ref;
38354 }
38355
38356 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38357         LDKSiPrefix* orig_conv = (LDKSiPrefix*)(orig & ~1);
38358         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_clone(orig_conv));
38359         return ret_conv;
38360 }
38361
38362 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1milli(JNIEnv *env, jclass clz) {
38363         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_milli());
38364         return ret_conv;
38365 }
38366
38367 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1micro(JNIEnv *env, jclass clz) {
38368         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_micro());
38369         return ret_conv;
38370 }
38371
38372 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1nano(JNIEnv *env, jclass clz) {
38373         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_nano());
38374         return ret_conv;
38375 }
38376
38377 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SiPrefix_1pico(JNIEnv *env, jclass clz) {
38378         jclass ret_conv = LDKSiPrefix_to_java(env, SiPrefix_pico());
38379         return ret_conv;
38380 }
38381
38382 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SiPrefix_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38383         LDKSiPrefix* a_conv = (LDKSiPrefix*)(a & ~1);
38384         LDKSiPrefix* b_conv = (LDKSiPrefix*)(b & ~1);
38385         jboolean ret_val = SiPrefix_eq(a_conv, b_conv);
38386         return ret_val;
38387 }
38388
38389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1multiplier(JNIEnv *env, jclass clz, int64_t this_arg) {
38390         LDKSiPrefix* this_arg_conv = (LDKSiPrefix*)(this_arg & ~1);
38391         int64_t ret_val = SiPrefix_multiplier(this_arg_conv);
38392         return ret_val;
38393 }
38394
38395 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38396         LDKCurrency* orig_conv = (LDKCurrency*)(orig & ~1);
38397         jclass ret_conv = LDKCurrency_to_java(env, Currency_clone(orig_conv));
38398         return ret_conv;
38399 }
38400
38401 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin(JNIEnv *env, jclass clz) {
38402         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin());
38403         return ret_conv;
38404 }
38405
38406 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1bitcoin_1testnet(JNIEnv *env, jclass clz) {
38407         jclass ret_conv = LDKCurrency_to_java(env, Currency_bitcoin_testnet());
38408         return ret_conv;
38409 }
38410
38411 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1regtest(JNIEnv *env, jclass clz) {
38412         jclass ret_conv = LDKCurrency_to_java(env, Currency_regtest());
38413         return ret_conv;
38414 }
38415
38416 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1simnet(JNIEnv *env, jclass clz) {
38417         jclass ret_conv = LDKCurrency_to_java(env, Currency_simnet());
38418         return ret_conv;
38419 }
38420
38421 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Currency_1signet(JNIEnv *env, jclass clz) {
38422         jclass ret_conv = LDKCurrency_to_java(env, Currency_signet());
38423         return ret_conv;
38424 }
38425
38426 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Currency_1hash(JNIEnv *env, jclass clz, int64_t o) {
38427         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
38428         int64_t ret_val = Currency_hash(o_conv);
38429         return ret_val;
38430 }
38431
38432 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Currency_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38433         LDKCurrency* a_conv = (LDKCurrency*)(a & ~1);
38434         LDKCurrency* b_conv = (LDKCurrency*)(b & ~1);
38435         jboolean ret_val = Currency_eq(a_conv, b_conv);
38436         return ret_val;
38437 }
38438
38439 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Sha256_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38440         LDKSha256 this_obj_conv;
38441         this_obj_conv.inner = (void*)(this_obj & (~1));
38442         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38443         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38444         Sha256_free(this_obj_conv);
38445 }
38446
38447 static inline uint64_t Sha256_clone_ptr(LDKSha256 *NONNULL_PTR arg) {
38448         LDKSha256 ret_var = Sha256_clone(arg);
38449 uint64_t ret_ref = 0;
38450 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38451 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38452 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38453 ret_ref = (uint64_t)ret_var.inner;
38454 if (ret_var.is_owned) {
38455         ret_ref |= 1;
38456 }
38457         return ret_ref;
38458 }
38459 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38460         LDKSha256 arg_conv;
38461         arg_conv.inner = (void*)(arg & (~1));
38462         arg_conv.is_owned = false;
38463         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38464         int64_t ret_val = Sha256_clone_ptr(&arg_conv);
38465         return ret_val;
38466 }
38467
38468 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38469         LDKSha256 orig_conv;
38470         orig_conv.inner = (void*)(orig & (~1));
38471         orig_conv.is_owned = false;
38472         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38473         LDKSha256 ret_var = Sha256_clone(&orig_conv);
38474         uint64_t ret_ref = 0;
38475         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38476         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38477         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38478         ret_ref = (uint64_t)ret_var.inner;
38479         if (ret_var.is_owned) {
38480                 ret_ref |= 1;
38481         }
38482         return ret_ref;
38483 }
38484
38485 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Sha256_1hash(JNIEnv *env, jclass clz, int64_t o) {
38486         LDKSha256 o_conv;
38487         o_conv.inner = (void*)(o & (~1));
38488         o_conv.is_owned = false;
38489         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38490         int64_t ret_val = Sha256_hash(&o_conv);
38491         return ret_val;
38492 }
38493
38494 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Sha256_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38495         LDKSha256 a_conv;
38496         a_conv.inner = (void*)(a & (~1));
38497         a_conv.is_owned = false;
38498         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38499         LDKSha256 b_conv;
38500         b_conv.inner = (void*)(b & (~1));
38501         b_conv.is_owned = false;
38502         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38503         jboolean ret_val = Sha256_eq(&a_conv, &b_conv);
38504         return ret_val;
38505 }
38506
38507 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Description_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38508         LDKDescription this_obj_conv;
38509         this_obj_conv.inner = (void*)(this_obj & (~1));
38510         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38511         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38512         Description_free(this_obj_conv);
38513 }
38514
38515 static inline uint64_t Description_clone_ptr(LDKDescription *NONNULL_PTR arg) {
38516         LDKDescription ret_var = Description_clone(arg);
38517 uint64_t ret_ref = 0;
38518 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38519 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38520 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38521 ret_ref = (uint64_t)ret_var.inner;
38522 if (ret_var.is_owned) {
38523         ret_ref |= 1;
38524 }
38525         return ret_ref;
38526 }
38527 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38528         LDKDescription arg_conv;
38529         arg_conv.inner = (void*)(arg & (~1));
38530         arg_conv.is_owned = false;
38531         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38532         int64_t ret_val = Description_clone_ptr(&arg_conv);
38533         return ret_val;
38534 }
38535
38536 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38537         LDKDescription orig_conv;
38538         orig_conv.inner = (void*)(orig & (~1));
38539         orig_conv.is_owned = false;
38540         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38541         LDKDescription ret_var = Description_clone(&orig_conv);
38542         uint64_t ret_ref = 0;
38543         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38544         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38545         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38546         ret_ref = (uint64_t)ret_var.inner;
38547         if (ret_var.is_owned) {
38548                 ret_ref |= 1;
38549         }
38550         return ret_ref;
38551 }
38552
38553 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1hash(JNIEnv *env, jclass clz, int64_t o) {
38554         LDKDescription o_conv;
38555         o_conv.inner = (void*)(o & (~1));
38556         o_conv.is_owned = false;
38557         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38558         int64_t ret_val = Description_hash(&o_conv);
38559         return ret_val;
38560 }
38561
38562 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Description_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38563         LDKDescription a_conv;
38564         a_conv.inner = (void*)(a & (~1));
38565         a_conv.is_owned = false;
38566         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38567         LDKDescription b_conv;
38568         b_conv.inner = (void*)(b & (~1));
38569         b_conv.is_owned = false;
38570         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38571         jboolean ret_val = Description_eq(&a_conv, &b_conv);
38572         return ret_val;
38573 }
38574
38575 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38576         LDKPayeePubKey this_obj_conv;
38577         this_obj_conv.inner = (void*)(this_obj & (~1));
38578         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38579         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38580         PayeePubKey_free(this_obj_conv);
38581 }
38582
38583 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
38584         LDKPayeePubKey this_ptr_conv;
38585         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38586         this_ptr_conv.is_owned = false;
38587         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38588         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
38589         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, PayeePubKey_get_a(&this_ptr_conv).compressed_form);
38590         return ret_arr;
38591 }
38592
38593 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int8_tArray val) {
38594         LDKPayeePubKey this_ptr_conv;
38595         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38596         this_ptr_conv.is_owned = false;
38597         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38598         LDKPublicKey val_ref;
38599         CHECK((*env)->GetArrayLength(env, val) == 33);
38600         (*env)->GetByteArrayRegion(env, val, 0, 33, val_ref.compressed_form);
38601         PayeePubKey_set_a(&this_ptr_conv, val_ref);
38602 }
38603
38604 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1new(JNIEnv *env, jclass clz, int8_tArray a_arg) {
38605         LDKPublicKey a_arg_ref;
38606         CHECK((*env)->GetArrayLength(env, a_arg) == 33);
38607         (*env)->GetByteArrayRegion(env, a_arg, 0, 33, a_arg_ref.compressed_form);
38608         LDKPayeePubKey ret_var = PayeePubKey_new(a_arg_ref);
38609         uint64_t ret_ref = 0;
38610         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38611         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38612         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38613         ret_ref = (uint64_t)ret_var.inner;
38614         if (ret_var.is_owned) {
38615                 ret_ref |= 1;
38616         }
38617         return ret_ref;
38618 }
38619
38620 static inline uint64_t PayeePubKey_clone_ptr(LDKPayeePubKey *NONNULL_PTR arg) {
38621         LDKPayeePubKey ret_var = PayeePubKey_clone(arg);
38622 uint64_t ret_ref = 0;
38623 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38624 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38625 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38626 ret_ref = (uint64_t)ret_var.inner;
38627 if (ret_var.is_owned) {
38628         ret_ref |= 1;
38629 }
38630         return ret_ref;
38631 }
38632 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38633         LDKPayeePubKey arg_conv;
38634         arg_conv.inner = (void*)(arg & (~1));
38635         arg_conv.is_owned = false;
38636         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38637         int64_t ret_val = PayeePubKey_clone_ptr(&arg_conv);
38638         return ret_val;
38639 }
38640
38641 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38642         LDKPayeePubKey orig_conv;
38643         orig_conv.inner = (void*)(orig & (~1));
38644         orig_conv.is_owned = false;
38645         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38646         LDKPayeePubKey ret_var = PayeePubKey_clone(&orig_conv);
38647         uint64_t ret_ref = 0;
38648         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38649         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38650         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38651         ret_ref = (uint64_t)ret_var.inner;
38652         if (ret_var.is_owned) {
38653                 ret_ref |= 1;
38654         }
38655         return ret_ref;
38656 }
38657
38658 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1hash(JNIEnv *env, jclass clz, int64_t o) {
38659         LDKPayeePubKey o_conv;
38660         o_conv.inner = (void*)(o & (~1));
38661         o_conv.is_owned = false;
38662         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38663         int64_t ret_val = PayeePubKey_hash(&o_conv);
38664         return ret_val;
38665 }
38666
38667 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PayeePubKey_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38668         LDKPayeePubKey a_conv;
38669         a_conv.inner = (void*)(a & (~1));
38670         a_conv.is_owned = false;
38671         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38672         LDKPayeePubKey b_conv;
38673         b_conv.inner = (void*)(b & (~1));
38674         b_conv.is_owned = false;
38675         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38676         jboolean ret_val = PayeePubKey_eq(&a_conv, &b_conv);
38677         return ret_val;
38678 }
38679
38680 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38681         LDKExpiryTime this_obj_conv;
38682         this_obj_conv.inner = (void*)(this_obj & (~1));
38683         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38684         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38685         ExpiryTime_free(this_obj_conv);
38686 }
38687
38688 static inline uint64_t ExpiryTime_clone_ptr(LDKExpiryTime *NONNULL_PTR arg) {
38689         LDKExpiryTime ret_var = ExpiryTime_clone(arg);
38690 uint64_t ret_ref = 0;
38691 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38692 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38693 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38694 ret_ref = (uint64_t)ret_var.inner;
38695 if (ret_var.is_owned) {
38696         ret_ref |= 1;
38697 }
38698         return ret_ref;
38699 }
38700 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38701         LDKExpiryTime arg_conv;
38702         arg_conv.inner = (void*)(arg & (~1));
38703         arg_conv.is_owned = false;
38704         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38705         int64_t ret_val = ExpiryTime_clone_ptr(&arg_conv);
38706         return ret_val;
38707 }
38708
38709 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38710         LDKExpiryTime orig_conv;
38711         orig_conv.inner = (void*)(orig & (~1));
38712         orig_conv.is_owned = false;
38713         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38714         LDKExpiryTime ret_var = ExpiryTime_clone(&orig_conv);
38715         uint64_t ret_ref = 0;
38716         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38717         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38718         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38719         ret_ref = (uint64_t)ret_var.inner;
38720         if (ret_var.is_owned) {
38721                 ret_ref |= 1;
38722         }
38723         return ret_ref;
38724 }
38725
38726 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1hash(JNIEnv *env, jclass clz, int64_t o) {
38727         LDKExpiryTime o_conv;
38728         o_conv.inner = (void*)(o & (~1));
38729         o_conv.is_owned = false;
38730         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38731         int64_t ret_val = ExpiryTime_hash(&o_conv);
38732         return ret_val;
38733 }
38734
38735 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38736         LDKExpiryTime a_conv;
38737         a_conv.inner = (void*)(a & (~1));
38738         a_conv.is_owned = false;
38739         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38740         LDKExpiryTime b_conv;
38741         b_conv.inner = (void*)(b & (~1));
38742         b_conv.is_owned = false;
38743         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38744         jboolean ret_val = ExpiryTime_eq(&a_conv, &b_conv);
38745         return ret_val;
38746 }
38747
38748 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38749         LDKMinFinalCltvExpiry this_obj_conv;
38750         this_obj_conv.inner = (void*)(this_obj & (~1));
38751         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38752         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38753         MinFinalCltvExpiry_free(this_obj_conv);
38754 }
38755
38756 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
38757         LDKMinFinalCltvExpiry this_ptr_conv;
38758         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38759         this_ptr_conv.is_owned = false;
38760         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38761         int64_t ret_val = MinFinalCltvExpiry_get_a(&this_ptr_conv);
38762         return ret_val;
38763 }
38764
38765 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
38766         LDKMinFinalCltvExpiry this_ptr_conv;
38767         this_ptr_conv.inner = (void*)(this_ptr & (~1));
38768         this_ptr_conv.is_owned = false;
38769         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
38770         MinFinalCltvExpiry_set_a(&this_ptr_conv, val);
38771 }
38772
38773 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
38774         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_new(a_arg);
38775         uint64_t ret_ref = 0;
38776         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38777         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38778         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38779         ret_ref = (uint64_t)ret_var.inner;
38780         if (ret_var.is_owned) {
38781                 ret_ref |= 1;
38782         }
38783         return ret_ref;
38784 }
38785
38786 static inline uint64_t MinFinalCltvExpiry_clone_ptr(LDKMinFinalCltvExpiry *NONNULL_PTR arg) {
38787         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(arg);
38788 uint64_t ret_ref = 0;
38789 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38790 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38791 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38792 ret_ref = (uint64_t)ret_var.inner;
38793 if (ret_var.is_owned) {
38794         ret_ref |= 1;
38795 }
38796         return ret_ref;
38797 }
38798 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38799         LDKMinFinalCltvExpiry arg_conv;
38800         arg_conv.inner = (void*)(arg & (~1));
38801         arg_conv.is_owned = false;
38802         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38803         int64_t ret_val = MinFinalCltvExpiry_clone_ptr(&arg_conv);
38804         return ret_val;
38805 }
38806
38807 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38808         LDKMinFinalCltvExpiry orig_conv;
38809         orig_conv.inner = (void*)(orig & (~1));
38810         orig_conv.is_owned = false;
38811         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38812         LDKMinFinalCltvExpiry ret_var = MinFinalCltvExpiry_clone(&orig_conv);
38813         uint64_t ret_ref = 0;
38814         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38815         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38816         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38817         ret_ref = (uint64_t)ret_var.inner;
38818         if (ret_var.is_owned) {
38819                 ret_ref |= 1;
38820         }
38821         return ret_ref;
38822 }
38823
38824 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1hash(JNIEnv *env, jclass clz, int64_t o) {
38825         LDKMinFinalCltvExpiry o_conv;
38826         o_conv.inner = (void*)(o & (~1));
38827         o_conv.is_owned = false;
38828         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
38829         int64_t ret_val = MinFinalCltvExpiry_hash(&o_conv);
38830         return ret_val;
38831 }
38832
38833 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_MinFinalCltvExpiry_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38834         LDKMinFinalCltvExpiry a_conv;
38835         a_conv.inner = (void*)(a & (~1));
38836         a_conv.is_owned = false;
38837         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38838         LDKMinFinalCltvExpiry b_conv;
38839         b_conv.inner = (void*)(b & (~1));
38840         b_conv.is_owned = false;
38841         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38842         jboolean ret_val = MinFinalCltvExpiry_eq(&a_conv, &b_conv);
38843         return ret_val;
38844 }
38845
38846 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Fallback_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
38847         if ((this_ptr & 1) != 0) return;
38848         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
38849         CHECK_ACCESS(this_ptr_ptr);
38850         LDKFallback this_ptr_conv = *(LDKFallback*)(this_ptr_ptr);
38851         FREE((void*)this_ptr);
38852         Fallback_free(this_ptr_conv);
38853 }
38854
38855 static inline uint64_t Fallback_clone_ptr(LDKFallback *NONNULL_PTR arg) {
38856         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38857         *ret_copy = Fallback_clone(arg);
38858 uint64_t ret_ref = (uint64_t)ret_copy;
38859         return ret_ref;
38860 }
38861 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38862         LDKFallback* arg_conv = (LDKFallback*)arg;
38863         int64_t ret_val = Fallback_clone_ptr(arg_conv);
38864         return ret_val;
38865 }
38866
38867 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38868         LDKFallback* orig_conv = (LDKFallback*)orig;
38869         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38870         *ret_copy = Fallback_clone(orig_conv);
38871         uint64_t ret_ref = (uint64_t)ret_copy;
38872         return ret_ref;
38873 }
38874
38875 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1seg_1wit_1program(JNIEnv *env, jclass clz, int8_t version, int8_tArray program) {
38876         
38877         LDKCVec_u8Z program_ref;
38878         program_ref.datalen = (*env)->GetArrayLength(env, program);
38879         program_ref.data = MALLOC(program_ref.datalen, "LDKCVec_u8Z Bytes");
38880         (*env)->GetByteArrayRegion(env, program, 0, program_ref.datalen, program_ref.data);
38881         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38882         *ret_copy = Fallback_seg_wit_program((LDKu5){ ._0 = version }, program_ref);
38883         uint64_t ret_ref = (uint64_t)ret_copy;
38884         return ret_ref;
38885 }
38886
38887 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1pub_1key_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
38888         LDKTwentyBytes a_ref;
38889         CHECK((*env)->GetArrayLength(env, a) == 20);
38890         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
38891         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38892         *ret_copy = Fallback_pub_key_hash(a_ref);
38893         uint64_t ret_ref = (uint64_t)ret_copy;
38894         return ret_ref;
38895 }
38896
38897 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1script_1hash(JNIEnv *env, jclass clz, int8_tArray a) {
38898         LDKTwentyBytes a_ref;
38899         CHECK((*env)->GetArrayLength(env, a) == 20);
38900         (*env)->GetByteArrayRegion(env, a, 0, 20, a_ref.data);
38901         LDKFallback *ret_copy = MALLOC(sizeof(LDKFallback), "LDKFallback");
38902         *ret_copy = Fallback_script_hash(a_ref);
38903         uint64_t ret_ref = (uint64_t)ret_copy;
38904         return ret_ref;
38905 }
38906
38907 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Fallback_1hash(JNIEnv *env, jclass clz, int64_t o) {
38908         LDKFallback* o_conv = (LDKFallback*)o;
38909         int64_t ret_val = Fallback_hash(o_conv);
38910         return ret_val;
38911 }
38912
38913 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Fallback_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38914         LDKFallback* a_conv = (LDKFallback*)a;
38915         LDKFallback* b_conv = (LDKFallback*)b;
38916         jboolean ret_val = Fallback_eq(a_conv, b_conv);
38917         return ret_val;
38918 }
38919
38920 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38921         LDKInvoiceSignature this_obj_conv;
38922         this_obj_conv.inner = (void*)(this_obj & (~1));
38923         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38924         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38925         InvoiceSignature_free(this_obj_conv);
38926 }
38927
38928 static inline uint64_t InvoiceSignature_clone_ptr(LDKInvoiceSignature *NONNULL_PTR arg) {
38929         LDKInvoiceSignature ret_var = InvoiceSignature_clone(arg);
38930 uint64_t ret_ref = 0;
38931 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38932 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38933 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38934 ret_ref = (uint64_t)ret_var.inner;
38935 if (ret_var.is_owned) {
38936         ret_ref |= 1;
38937 }
38938         return ret_ref;
38939 }
38940 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
38941         LDKInvoiceSignature arg_conv;
38942         arg_conv.inner = (void*)(arg & (~1));
38943         arg_conv.is_owned = false;
38944         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
38945         int64_t ret_val = InvoiceSignature_clone_ptr(&arg_conv);
38946         return ret_val;
38947 }
38948
38949 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1clone(JNIEnv *env, jclass clz, int64_t orig) {
38950         LDKInvoiceSignature orig_conv;
38951         orig_conv.inner = (void*)(orig & (~1));
38952         orig_conv.is_owned = false;
38953         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
38954         LDKInvoiceSignature ret_var = InvoiceSignature_clone(&orig_conv);
38955         uint64_t ret_ref = 0;
38956         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38957         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38958         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38959         ret_ref = (uint64_t)ret_var.inner;
38960         if (ret_var.is_owned) {
38961                 ret_ref |= 1;
38962         }
38963         return ret_ref;
38964 }
38965
38966 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_InvoiceSignature_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
38967         LDKInvoiceSignature a_conv;
38968         a_conv.inner = (void*)(a & (~1));
38969         a_conv.is_owned = false;
38970         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
38971         LDKInvoiceSignature b_conv;
38972         b_conv.inner = (void*)(b & (~1));
38973         b_conv.is_owned = false;
38974         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
38975         jboolean ret_val = InvoiceSignature_eq(&a_conv, &b_conv);
38976         return ret_val;
38977 }
38978
38979 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
38980         LDKPrivateRoute this_obj_conv;
38981         this_obj_conv.inner = (void*)(this_obj & (~1));
38982         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
38983         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
38984         PrivateRoute_free(this_obj_conv);
38985 }
38986
38987 static inline uint64_t PrivateRoute_clone_ptr(LDKPrivateRoute *NONNULL_PTR arg) {
38988         LDKPrivateRoute ret_var = PrivateRoute_clone(arg);
38989 uint64_t ret_ref = 0;
38990 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
38991 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
38992 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
38993 ret_ref = (uint64_t)ret_var.inner;
38994 if (ret_var.is_owned) {
38995         ret_ref |= 1;
38996 }
38997         return ret_ref;
38998 }
38999 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39000         LDKPrivateRoute arg_conv;
39001         arg_conv.inner = (void*)(arg & (~1));
39002         arg_conv.is_owned = false;
39003         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39004         int64_t ret_val = PrivateRoute_clone_ptr(&arg_conv);
39005         return ret_val;
39006 }
39007
39008 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39009         LDKPrivateRoute orig_conv;
39010         orig_conv.inner = (void*)(orig & (~1));
39011         orig_conv.is_owned = false;
39012         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39013         LDKPrivateRoute ret_var = PrivateRoute_clone(&orig_conv);
39014         uint64_t ret_ref = 0;
39015         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39016         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39017         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39018         ret_ref = (uint64_t)ret_var.inner;
39019         if (ret_var.is_owned) {
39020                 ret_ref |= 1;
39021         }
39022         return ret_ref;
39023 }
39024
39025 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1hash(JNIEnv *env, jclass clz, int64_t o) {
39026         LDKPrivateRoute o_conv;
39027         o_conv.inner = (void*)(o & (~1));
39028         o_conv.is_owned = false;
39029         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39030         int64_t ret_val = PrivateRoute_hash(&o_conv);
39031         return ret_val;
39032 }
39033
39034 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39035         LDKPrivateRoute a_conv;
39036         a_conv.inner = (void*)(a & (~1));
39037         a_conv.is_owned = false;
39038         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39039         LDKPrivateRoute b_conv;
39040         b_conv.inner = (void*)(b & (~1));
39041         b_conv.is_owned = false;
39042         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39043         jboolean ret_val = PrivateRoute_eq(&a_conv, &b_conv);
39044         return ret_val;
39045 }
39046
39047 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1into_1parts(JNIEnv *env, jclass clz, int64_t this_arg) {
39048         LDKSignedRawInvoice this_arg_conv;
39049         this_arg_conv.inner = (void*)(this_arg & (~1));
39050         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39051         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39052         this_arg_conv = SignedRawInvoice_clone(&this_arg_conv);
39053         LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ* ret_conv = MALLOC(sizeof(LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ), "LDKC3Tuple_RawInvoice_u832InvoiceSignatureZ");
39054         *ret_conv = SignedRawInvoice_into_parts(this_arg_conv);
39055         return ((uint64_t)ret_conv);
39056 }
39057
39058 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1raw_1invoice(JNIEnv *env, jclass clz, int64_t this_arg) {
39059         LDKSignedRawInvoice this_arg_conv;
39060         this_arg_conv.inner = (void*)(this_arg & (~1));
39061         this_arg_conv.is_owned = false;
39062         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39063         LDKRawInvoice ret_var = SignedRawInvoice_raw_invoice(&this_arg_conv);
39064         uint64_t ret_ref = 0;
39065         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39066         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39067         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39068         ret_ref = (uint64_t)ret_var.inner;
39069         if (ret_var.is_owned) {
39070                 ret_ref |= 1;
39071         }
39072         return ret_ref;
39073 }
39074
39075 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39076         LDKSignedRawInvoice this_arg_conv;
39077         this_arg_conv.inner = (void*)(this_arg & (~1));
39078         this_arg_conv.is_owned = false;
39079         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39080         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39081         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *SignedRawInvoice_hash(&this_arg_conv));
39082         return ret_arr;
39083 }
39084
39085 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
39086         LDKSignedRawInvoice this_arg_conv;
39087         this_arg_conv.inner = (void*)(this_arg & (~1));
39088         this_arg_conv.is_owned = false;
39089         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39090         LDKInvoiceSignature ret_var = SignedRawInvoice_signature(&this_arg_conv);
39091         uint64_t ret_ref = 0;
39092         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39093         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39094         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39095         ret_ref = (uint64_t)ret_var.inner;
39096         if (ret_var.is_owned) {
39097                 ret_ref |= 1;
39098         }
39099         return ret_ref;
39100 }
39101
39102 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
39103         LDKSignedRawInvoice this_arg_conv;
39104         this_arg_conv.inner = (void*)(this_arg & (~1));
39105         this_arg_conv.is_owned = false;
39106         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39107         LDKCResult_PayeePubKeyErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PayeePubKeyErrorZ), "LDKCResult_PayeePubKeyErrorZ");
39108         *ret_conv = SignedRawInvoice_recover_payee_pub_key(&this_arg_conv);
39109         return (uint64_t)ret_conv;
39110 }
39111
39112 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
39113         LDKSignedRawInvoice this_arg_conv;
39114         this_arg_conv.inner = (void*)(this_arg & (~1));
39115         this_arg_conv.is_owned = false;
39116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39117         jboolean ret_val = SignedRawInvoice_check_signature(&this_arg_conv);
39118         return ret_val;
39119 }
39120
39121 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39122         LDKRawInvoice this_arg_conv;
39123         this_arg_conv.inner = (void*)(this_arg & (~1));
39124         this_arg_conv.is_owned = false;
39125         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39126         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39127         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_hash(&this_arg_conv).data);
39128         return ret_arr;
39129 }
39130
39131 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39132         LDKRawInvoice this_arg_conv;
39133         this_arg_conv.inner = (void*)(this_arg & (~1));
39134         this_arg_conv.is_owned = false;
39135         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39136         LDKSha256 ret_var = RawInvoice_payment_hash(&this_arg_conv);
39137         uint64_t ret_ref = 0;
39138         if ((uint64_t)ret_var.inner > 4096) {
39139                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39140                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39141         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39142                 ret_ref = (uint64_t)ret_var.inner;
39143                 if (ret_var.is_owned) {
39144                         ret_ref |= 1;
39145                 }
39146         }
39147         return ret_ref;
39148 }
39149
39150 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description(JNIEnv *env, jclass clz, int64_t this_arg) {
39151         LDKRawInvoice this_arg_conv;
39152         this_arg_conv.inner = (void*)(this_arg & (~1));
39153         this_arg_conv.is_owned = false;
39154         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39155         LDKDescription ret_var = RawInvoice_description(&this_arg_conv);
39156         uint64_t ret_ref = 0;
39157         if ((uint64_t)ret_var.inner > 4096) {
39158                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39159                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39160         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39161                 ret_ref = (uint64_t)ret_var.inner;
39162                 if (ret_var.is_owned) {
39163                         ret_ref |= 1;
39164                 }
39165         }
39166         return ret_ref;
39167 }
39168
39169 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
39170         LDKRawInvoice this_arg_conv;
39171         this_arg_conv.inner = (void*)(this_arg & (~1));
39172         this_arg_conv.is_owned = false;
39173         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39174         LDKPayeePubKey ret_var = RawInvoice_payee_pub_key(&this_arg_conv);
39175         uint64_t ret_ref = 0;
39176         if ((uint64_t)ret_var.inner > 4096) {
39177                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39178                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39179         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39180                 ret_ref = (uint64_t)ret_var.inner;
39181                 if (ret_var.is_owned) {
39182                         ret_ref |= 1;
39183                 }
39184         }
39185         return ret_ref;
39186 }
39187
39188 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1description_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39189         LDKRawInvoice this_arg_conv;
39190         this_arg_conv.inner = (void*)(this_arg & (~1));
39191         this_arg_conv.is_owned = false;
39192         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39193         LDKSha256 ret_var = RawInvoice_description_hash(&this_arg_conv);
39194         uint64_t ret_ref = 0;
39195         if ((uint64_t)ret_var.inner > 4096) {
39196                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39197                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39198         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39199                 ret_ref = (uint64_t)ret_var.inner;
39200                 if (ret_var.is_owned) {
39201                         ret_ref |= 1;
39202                 }
39203         }
39204         return ret_ref;
39205 }
39206
39207 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
39208         LDKRawInvoice this_arg_conv;
39209         this_arg_conv.inner = (void*)(this_arg & (~1));
39210         this_arg_conv.is_owned = false;
39211         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39212         LDKExpiryTime ret_var = RawInvoice_expiry_time(&this_arg_conv);
39213         uint64_t ret_ref = 0;
39214         if ((uint64_t)ret_var.inner > 4096) {
39215                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39216                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39217         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39218                 ret_ref = (uint64_t)ret_var.inner;
39219                 if (ret_var.is_owned) {
39220                         ret_ref |= 1;
39221                 }
39222         }
39223         return ret_ref;
39224 }
39225
39226 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
39227         LDKRawInvoice this_arg_conv;
39228         this_arg_conv.inner = (void*)(this_arg & (~1));
39229         this_arg_conv.is_owned = false;
39230         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39231         LDKMinFinalCltvExpiry ret_var = RawInvoice_min_final_cltv_expiry(&this_arg_conv);
39232         uint64_t ret_ref = 0;
39233         if ((uint64_t)ret_var.inner > 4096) {
39234                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39235                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39236         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39237                 ret_ref = (uint64_t)ret_var.inner;
39238                 if (ret_var.is_owned) {
39239                         ret_ref |= 1;
39240                 }
39241         }
39242         return ret_ref;
39243 }
39244
39245 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
39246         LDKRawInvoice this_arg_conv;
39247         this_arg_conv.inner = (void*)(this_arg & (~1));
39248         this_arg_conv.is_owned = false;
39249         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39250         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39251         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, RawInvoice_payment_secret(&this_arg_conv).data);
39252         return ret_arr;
39253 }
39254
39255 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
39256         LDKRawInvoice this_arg_conv;
39257         this_arg_conv.inner = (void*)(this_arg & (~1));
39258         this_arg_conv.is_owned = false;
39259         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39260         LDKInvoiceFeatures ret_var = RawInvoice_features(&this_arg_conv);
39261         uint64_t ret_ref = 0;
39262         if ((uint64_t)ret_var.inner > 4096) {
39263                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39264                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39265         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39266                 ret_ref = (uint64_t)ret_var.inner;
39267                 if (ret_var.is_owned) {
39268                         ret_ref |= 1;
39269                 }
39270         }
39271         return ret_ref;
39272 }
39273
39274 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_RawInvoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
39275         LDKRawInvoice this_arg_conv;
39276         this_arg_conv.inner = (void*)(this_arg & (~1));
39277         this_arg_conv.is_owned = false;
39278         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39279         LDKCVec_PrivateRouteZ ret_var = RawInvoice_private_routes(&this_arg_conv);
39280         int64_tArray ret_arr = NULL;
39281         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39282         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39283         for (size_t o = 0; o < ret_var.datalen; o++) {
39284                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
39285                 uint64_t ret_conv_14_ref = 0;
39286                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39287                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39288                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
39289                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
39290                 if (ret_conv_14_var.is_owned) {
39291                         ret_conv_14_ref |= 1;
39292                 }
39293                 ret_arr_ptr[o] = ret_conv_14_ref;
39294         }
39295         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39296         FREE(ret_var.data);
39297         return ret_arr;
39298 }
39299
39300 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RawInvoice_1amount_1pico_1btc(JNIEnv *env, jclass clz, int64_t this_arg) {
39301         LDKRawInvoice this_arg_conv;
39302         this_arg_conv.inner = (void*)(this_arg & (~1));
39303         this_arg_conv.is_owned = false;
39304         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39305         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39306         *ret_copy = RawInvoice_amount_pico_btc(&this_arg_conv);
39307         uint64_t ret_ref = (uint64_t)ret_copy;
39308         return ret_ref;
39309 }
39310
39311 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_RawInvoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
39312         LDKRawInvoice this_arg_conv;
39313         this_arg_conv.inner = (void*)(this_arg & (~1));
39314         this_arg_conv.is_owned = false;
39315         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39316         jclass ret_conv = LDKCurrency_to_java(env, RawInvoice_currency(&this_arg_conv));
39317         return ret_conv;
39318 }
39319
39320 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t unix_seconds) {
39321         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
39322         *ret_conv = PositiveTimestamp_from_unix_timestamp(unix_seconds);
39323         return (uint64_t)ret_conv;
39324 }
39325
39326 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1from_1system_1time(JNIEnv *env, jclass clz, int64_t time) {
39327         LDKCResult_PositiveTimestampCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PositiveTimestampCreationErrorZ), "LDKCResult_PositiveTimestampCreationErrorZ");
39328         *ret_conv = PositiveTimestamp_from_system_time(time);
39329         return (uint64_t)ret_conv;
39330 }
39331
39332 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1unix_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
39333         LDKPositiveTimestamp this_arg_conv;
39334         this_arg_conv.inner = (void*)(this_arg & (~1));
39335         this_arg_conv.is_owned = false;
39336         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39337         int64_t ret_val = PositiveTimestamp_as_unix_timestamp(&this_arg_conv);
39338         return ret_val;
39339 }
39340
39341 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PositiveTimestamp_1as_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
39342         LDKPositiveTimestamp this_arg_conv;
39343         this_arg_conv.inner = (void*)(this_arg & (~1));
39344         this_arg_conv.is_owned = false;
39345         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39346         int64_t ret_val = PositiveTimestamp_as_time(&this_arg_conv);
39347         return ret_val;
39348 }
39349
39350 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1into_1signed_1raw(JNIEnv *env, jclass clz, int64_t this_arg) {
39351         LDKInvoice this_arg_conv;
39352         this_arg_conv.inner = (void*)(this_arg & (~1));
39353         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39354         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39355         this_arg_conv = Invoice_clone(&this_arg_conv);
39356         LDKSignedRawInvoice ret_var = Invoice_into_signed_raw(this_arg_conv);
39357         uint64_t ret_ref = 0;
39358         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39359         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39360         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39361         ret_ref = (uint64_t)ret_var.inner;
39362         if (ret_var.is_owned) {
39363                 ret_ref |= 1;
39364         }
39365         return ret_ref;
39366 }
39367
39368 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1check_1signature(JNIEnv *env, jclass clz, int64_t this_arg) {
39369         LDKInvoice this_arg_conv;
39370         this_arg_conv.inner = (void*)(this_arg & (~1));
39371         this_arg_conv.is_owned = false;
39372         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39373         LDKCResult_NoneSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_NoneSemanticErrorZ), "LDKCResult_NoneSemanticErrorZ");
39374         *ret_conv = Invoice_check_signature(&this_arg_conv);
39375         return (uint64_t)ret_conv;
39376 }
39377
39378 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1signed(JNIEnv *env, jclass clz, int64_t signed_invoice) {
39379         LDKSignedRawInvoice signed_invoice_conv;
39380         signed_invoice_conv.inner = (void*)(signed_invoice & (~1));
39381         signed_invoice_conv.is_owned = (signed_invoice & 1) || (signed_invoice == 0);
39382         CHECK_INNER_FIELD_ACCESS_OR_NULL(signed_invoice_conv);
39383         signed_invoice_conv = SignedRawInvoice_clone(&signed_invoice_conv);
39384         LDKCResult_InvoiceSemanticErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSemanticErrorZ), "LDKCResult_InvoiceSemanticErrorZ");
39385         *ret_conv = Invoice_from_signed(signed_invoice_conv);
39386         return (uint64_t)ret_conv;
39387 }
39388
39389 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1timestamp(JNIEnv *env, jclass clz, int64_t this_arg) {
39390         LDKInvoice this_arg_conv;
39391         this_arg_conv.inner = (void*)(this_arg & (~1));
39392         this_arg_conv.is_owned = false;
39393         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39394         int64_t ret_val = Invoice_timestamp(&this_arg_conv);
39395         return ret_val;
39396 }
39397
39398 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1hash(JNIEnv *env, jclass clz, int64_t this_arg) {
39399         LDKInvoice this_arg_conv;
39400         this_arg_conv.inner = (void*)(this_arg & (~1));
39401         this_arg_conv.is_owned = false;
39402         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39403         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39404         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_hash(&this_arg_conv));
39405         return ret_arr;
39406 }
39407
39408 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
39409         LDKInvoice this_arg_conv;
39410         this_arg_conv.inner = (void*)(this_arg & (~1));
39411         this_arg_conv.is_owned = false;
39412         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39413         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39414         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_payee_pub_key(&this_arg_conv).compressed_form);
39415         return ret_arr;
39416 }
39417
39418 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1payment_1secret(JNIEnv *env, jclass clz, int64_t this_arg) {
39419         LDKInvoice this_arg_conv;
39420         this_arg_conv.inner = (void*)(this_arg & (~1));
39421         this_arg_conv.is_owned = false;
39422         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39423         int8_tArray ret_arr = (*env)->NewByteArray(env, 32);
39424         (*env)->SetByteArrayRegion(env, ret_arr, 0, 32, *Invoice_payment_secret(&this_arg_conv));
39425         return ret_arr;
39426 }
39427
39428 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1features(JNIEnv *env, jclass clz, int64_t this_arg) {
39429         LDKInvoice this_arg_conv;
39430         this_arg_conv.inner = (void*)(this_arg & (~1));
39431         this_arg_conv.is_owned = false;
39432         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39433         LDKInvoiceFeatures ret_var = Invoice_features(&this_arg_conv);
39434         uint64_t ret_ref = 0;
39435         if ((uint64_t)ret_var.inner > 4096) {
39436                 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39437                 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39438         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39439                 ret_ref = (uint64_t)ret_var.inner;
39440                 if (ret_var.is_owned) {
39441                         ret_ref |= 1;
39442                 }
39443         }
39444         return ret_ref;
39445 }
39446
39447 JNIEXPORT int8_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1recover_1payee_1pub_1key(JNIEnv *env, jclass clz, int64_t this_arg) {
39448         LDKInvoice this_arg_conv;
39449         this_arg_conv.inner = (void*)(this_arg & (~1));
39450         this_arg_conv.is_owned = false;
39451         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39452         int8_tArray ret_arr = (*env)->NewByteArray(env, 33);
39453         (*env)->SetByteArrayRegion(env, ret_arr, 0, 33, Invoice_recover_payee_pub_key(&this_arg_conv).compressed_form);
39454         return ret_arr;
39455 }
39456
39457 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1expiry_1time(JNIEnv *env, jclass clz, int64_t this_arg) {
39458         LDKInvoice this_arg_conv;
39459         this_arg_conv.inner = (void*)(this_arg & (~1));
39460         this_arg_conv.is_owned = false;
39461         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39462         int64_t ret_val = Invoice_expiry_time(&this_arg_conv);
39463         return ret_val;
39464 }
39465
39466 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_Invoice_1is_1expired(JNIEnv *env, jclass clz, int64_t this_arg) {
39467         LDKInvoice this_arg_conv;
39468         this_arg_conv.inner = (void*)(this_arg & (~1));
39469         this_arg_conv.is_owned = false;
39470         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39471         jboolean ret_val = Invoice_is_expired(&this_arg_conv);
39472         return ret_val;
39473 }
39474
39475 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1min_1final_1cltv_1expiry(JNIEnv *env, jclass clz, int64_t this_arg) {
39476         LDKInvoice this_arg_conv;
39477         this_arg_conv.inner = (void*)(this_arg & (~1));
39478         this_arg_conv.is_owned = false;
39479         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39480         int64_t ret_val = Invoice_min_final_cltv_expiry(&this_arg_conv);
39481         return ret_val;
39482 }
39483
39484 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1private_1routes(JNIEnv *env, jclass clz, int64_t this_arg) {
39485         LDKInvoice this_arg_conv;
39486         this_arg_conv.inner = (void*)(this_arg & (~1));
39487         this_arg_conv.is_owned = false;
39488         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39489         LDKCVec_PrivateRouteZ ret_var = Invoice_private_routes(&this_arg_conv);
39490         int64_tArray ret_arr = NULL;
39491         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39492         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39493         for (size_t o = 0; o < ret_var.datalen; o++) {
39494                 LDKPrivateRoute ret_conv_14_var = ret_var.data[o];
39495                 uint64_t ret_conv_14_ref = 0;
39496                 CHECK((((uint64_t)ret_conv_14_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39497                 CHECK((((uint64_t)&ret_conv_14_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39498                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_14_var);
39499                 ret_conv_14_ref = (uint64_t)ret_conv_14_var.inner;
39500                 if (ret_conv_14_var.is_owned) {
39501                         ret_conv_14_ref |= 1;
39502                 }
39503                 ret_arr_ptr[o] = ret_conv_14_ref;
39504         }
39505         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39506         FREE(ret_var.data);
39507         return ret_arr;
39508 }
39509
39510 JNIEXPORT int64_tArray JNICALL Java_org_ldk_impl_bindings_Invoice_1route_1hints(JNIEnv *env, jclass clz, int64_t this_arg) {
39511         LDKInvoice this_arg_conv;
39512         this_arg_conv.inner = (void*)(this_arg & (~1));
39513         this_arg_conv.is_owned = false;
39514         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39515         LDKCVec_RouteHintZ ret_var = Invoice_route_hints(&this_arg_conv);
39516         int64_tArray ret_arr = NULL;
39517         ret_arr = (*env)->NewLongArray(env, ret_var.datalen);
39518         int64_t *ret_arr_ptr = (*env)->GetPrimitiveArrayCritical(env, ret_arr, NULL);
39519         for (size_t l = 0; l < ret_var.datalen; l++) {
39520                 LDKRouteHint ret_conv_11_var = ret_var.data[l];
39521                 uint64_t ret_conv_11_ref = 0;
39522                 CHECK((((uint64_t)ret_conv_11_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39523                 CHECK((((uint64_t)&ret_conv_11_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39524                 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_conv_11_var);
39525                 ret_conv_11_ref = (uint64_t)ret_conv_11_var.inner;
39526                 if (ret_conv_11_var.is_owned) {
39527                         ret_conv_11_ref |= 1;
39528                 }
39529                 ret_arr_ptr[l] = ret_conv_11_ref;
39530         }
39531         (*env)->ReleasePrimitiveArrayCritical(env, ret_arr, ret_arr_ptr, 0);
39532         FREE(ret_var.data);
39533         return ret_arr;
39534 }
39535
39536 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_Invoice_1currency(JNIEnv *env, jclass clz, int64_t this_arg) {
39537         LDKInvoice this_arg_conv;
39538         this_arg_conv.inner = (void*)(this_arg & (~1));
39539         this_arg_conv.is_owned = false;
39540         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39541         jclass ret_conv = LDKCurrency_to_java(env, Invoice_currency(&this_arg_conv));
39542         return ret_conv;
39543 }
39544
39545 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1amount_1milli_1satoshis(JNIEnv *env, jclass clz, int64_t this_arg) {
39546         LDKInvoice this_arg_conv;
39547         this_arg_conv.inner = (void*)(this_arg & (~1));
39548         this_arg_conv.is_owned = false;
39549         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39550         LDKCOption_u64Z *ret_copy = MALLOC(sizeof(LDKCOption_u64Z), "LDKCOption_u64Z");
39551         *ret_copy = Invoice_amount_milli_satoshis(&this_arg_conv);
39552         uint64_t ret_ref = (uint64_t)ret_copy;
39553         return ret_ref;
39554 }
39555
39556 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Description_1new(JNIEnv *env, jclass clz, jstring description) {
39557         LDKStr description_conv = java_to_owned_str(env, description);
39558         LDKCResult_DescriptionCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_DescriptionCreationErrorZ), "LDKCResult_DescriptionCreationErrorZ");
39559         *ret_conv = Description_new(description_conv);
39560         return (uint64_t)ret_conv;
39561 }
39562
39563 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Description_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
39564         LDKDescription this_arg_conv;
39565         this_arg_conv.inner = (void*)(this_arg & (~1));
39566         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39567         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39568         this_arg_conv = Description_clone(&this_arg_conv);
39569         LDKStr ret_str = Description_into_inner(this_arg_conv);
39570         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39571         Str_free(ret_str);
39572         return ret_conv;
39573 }
39574
39575 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1seconds(JNIEnv *env, jclass clz, int64_t seconds) {
39576         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
39577         *ret_conv = ExpiryTime_from_seconds(seconds);
39578         return (uint64_t)ret_conv;
39579 }
39580
39581 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1from_1duration(JNIEnv *env, jclass clz, int64_t duration) {
39582         LDKCResult_ExpiryTimeCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_ExpiryTimeCreationErrorZ), "LDKCResult_ExpiryTimeCreationErrorZ");
39583         *ret_conv = ExpiryTime_from_duration(duration);
39584         return (uint64_t)ret_conv;
39585 }
39586
39587 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1seconds(JNIEnv *env, jclass clz, int64_t this_arg) {
39588         LDKExpiryTime this_arg_conv;
39589         this_arg_conv.inner = (void*)(this_arg & (~1));
39590         this_arg_conv.is_owned = false;
39591         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39592         int64_t ret_val = ExpiryTime_as_seconds(&this_arg_conv);
39593         return ret_val;
39594 }
39595
39596 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ExpiryTime_1as_1duration(JNIEnv *env, jclass clz, int64_t this_arg) {
39597         LDKExpiryTime this_arg_conv;
39598         this_arg_conv.inner = (void*)(this_arg & (~1));
39599         this_arg_conv.is_owned = false;
39600         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39601         int64_t ret_val = ExpiryTime_as_duration(&this_arg_conv);
39602         return ret_val;
39603 }
39604
39605 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1new(JNIEnv *env, jclass clz, int64_t hops) {
39606         LDKRouteHint hops_conv;
39607         hops_conv.inner = (void*)(hops & (~1));
39608         hops_conv.is_owned = (hops & 1) || (hops == 0);
39609         CHECK_INNER_FIELD_ACCESS_OR_NULL(hops_conv);
39610         hops_conv = RouteHint_clone(&hops_conv);
39611         LDKCResult_PrivateRouteCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PrivateRouteCreationErrorZ), "LDKCResult_PrivateRouteCreationErrorZ");
39612         *ret_conv = PrivateRoute_new(hops_conv);
39613         return (uint64_t)ret_conv;
39614 }
39615
39616 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PrivateRoute_1into_1inner(JNIEnv *env, jclass clz, int64_t this_arg) {
39617         LDKPrivateRoute this_arg_conv;
39618         this_arg_conv.inner = (void*)(this_arg & (~1));
39619         this_arg_conv.is_owned = (this_arg & 1) || (this_arg == 0);
39620         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
39621         this_arg_conv = PrivateRoute_clone(&this_arg_conv);
39622         LDKRouteHint ret_var = PrivateRoute_into_inner(this_arg_conv);
39623         uint64_t ret_ref = 0;
39624         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39625         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39626         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39627         ret_ref = (uint64_t)ret_var.inner;
39628         if (ret_var.is_owned) {
39629                 ret_ref |= 1;
39630         }
39631         return ret_ref;
39632 }
39633
39634 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39635         LDKCreationError* orig_conv = (LDKCreationError*)(orig & ~1);
39636         jclass ret_conv = LDKCreationError_to_java(env, CreationError_clone(orig_conv));
39637         return ret_conv;
39638 }
39639
39640 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1description_1too_1long(JNIEnv *env, jclass clz) {
39641         jclass ret_conv = LDKCreationError_to_java(env, CreationError_description_too_long());
39642         return ret_conv;
39643 }
39644
39645 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1route_1too_1long(JNIEnv *env, jclass clz) {
39646         jclass ret_conv = LDKCreationError_to_java(env, CreationError_route_too_long());
39647         return ret_conv;
39648 }
39649
39650 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1timestamp_1out_1of_1bounds(JNIEnv *env, jclass clz) {
39651         jclass ret_conv = LDKCreationError_to_java(env, CreationError_timestamp_out_of_bounds());
39652         return ret_conv;
39653 }
39654
39655 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_CreationError_1expiry_1time_1out_1of_1bounds(JNIEnv *env, jclass clz) {
39656         jclass ret_conv = LDKCreationError_to_java(env, CreationError_expiry_time_out_of_bounds());
39657         return ret_conv;
39658 }
39659
39660 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_CreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39661         LDKCreationError* a_conv = (LDKCreationError*)(a & ~1);
39662         LDKCreationError* b_conv = (LDKCreationError*)(b & ~1);
39663         jboolean ret_val = CreationError_eq(a_conv, b_conv);
39664         return ret_val;
39665 }
39666
39667 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_CreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
39668         LDKCreationError* o_conv = (LDKCreationError*)(o & ~1);
39669         LDKStr ret_str = CreationError_to_str(o_conv);
39670         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39671         Str_free(ret_str);
39672         return ret_conv;
39673 }
39674
39675 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39676         LDKSemanticError* orig_conv = (LDKSemanticError*)(orig & ~1);
39677         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_clone(orig_conv));
39678         return ret_conv;
39679 }
39680
39681 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1hash(JNIEnv *env, jclass clz) {
39682         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_hash());
39683         return ret_conv;
39684 }
39685
39686 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1hashes(JNIEnv *env, jclass clz) {
39687         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_hashes());
39688         return ret_conv;
39689 }
39690
39691 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1description(JNIEnv *env, jclass clz) {
39692         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_description());
39693         return ret_conv;
39694 }
39695
39696 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1descriptions(JNIEnv *env, jclass clz) {
39697         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_descriptions());
39698         return ret_conv;
39699 }
39700
39701 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1no_1payment_1secret(JNIEnv *env, jclass clz) {
39702         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_no_payment_secret());
39703         return ret_conv;
39704 }
39705
39706 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1multiple_1payment_1secrets(JNIEnv *env, jclass clz) {
39707         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_multiple_payment_secrets());
39708         return ret_conv;
39709 }
39710
39711 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1features(JNIEnv *env, jclass clz) {
39712         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_features());
39713         return ret_conv;
39714 }
39715
39716 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1recovery_1id(JNIEnv *env, jclass clz) {
39717         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_recovery_id());
39718         return ret_conv;
39719 }
39720
39721 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1invalid_1signature(JNIEnv *env, jclass clz) {
39722         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_invalid_signature());
39723         return ret_conv;
39724 }
39725
39726 JNIEXPORT jclass JNICALL Java_org_ldk_impl_bindings_SemanticError_1imprecise_1amount(JNIEnv *env, jclass clz) {
39727         jclass ret_conv = LDKSemanticError_to_java(env, SemanticError_imprecise_amount());
39728         return ret_conv;
39729 }
39730
39731 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SemanticError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39732         LDKSemanticError* a_conv = (LDKSemanticError*)(a & ~1);
39733         LDKSemanticError* b_conv = (LDKSemanticError*)(b & ~1);
39734         jboolean ret_val = SemanticError_eq(a_conv, b_conv);
39735         return ret_val;
39736 }
39737
39738 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SemanticError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
39739         LDKSemanticError* o_conv = (LDKSemanticError*)(o & ~1);
39740         LDKStr ret_str = SemanticError_to_str(o_conv);
39741         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39742         Str_free(ret_str);
39743         return ret_conv;
39744 }
39745
39746 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39747         if ((this_ptr & 1) != 0) return;
39748         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39749         CHECK_ACCESS(this_ptr_ptr);
39750         LDKSignOrCreationError this_ptr_conv = *(LDKSignOrCreationError*)(this_ptr_ptr);
39751         FREE((void*)this_ptr);
39752         SignOrCreationError_free(this_ptr_conv);
39753 }
39754
39755 static inline uint64_t SignOrCreationError_clone_ptr(LDKSignOrCreationError *NONNULL_PTR arg) {
39756         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
39757         *ret_copy = SignOrCreationError_clone(arg);
39758 uint64_t ret_ref = (uint64_t)ret_copy;
39759         return ret_ref;
39760 }
39761 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39762         LDKSignOrCreationError* arg_conv = (LDKSignOrCreationError*)arg;
39763         int64_t ret_val = SignOrCreationError_clone_ptr(arg_conv);
39764         return ret_val;
39765 }
39766
39767 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39768         LDKSignOrCreationError* orig_conv = (LDKSignOrCreationError*)orig;
39769         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
39770         *ret_copy = SignOrCreationError_clone(orig_conv);
39771         uint64_t ret_ref = (uint64_t)ret_copy;
39772         return ret_ref;
39773 }
39774
39775 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1sign_1error(JNIEnv *env, jclass clz) {
39776         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
39777         *ret_copy = SignOrCreationError_sign_error();
39778         uint64_t ret_ref = (uint64_t)ret_copy;
39779         return ret_ref;
39780 }
39781
39782 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1creation_1error(JNIEnv *env, jclass clz, jclass a) {
39783         LDKCreationError a_conv = LDKCreationError_from_java(env, a);
39784         LDKSignOrCreationError *ret_copy = MALLOC(sizeof(LDKSignOrCreationError), "LDKSignOrCreationError");
39785         *ret_copy = SignOrCreationError_creation_error(a_conv);
39786         uint64_t ret_ref = (uint64_t)ret_copy;
39787         return ret_ref;
39788 }
39789
39790 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39791         LDKSignOrCreationError* a_conv = (LDKSignOrCreationError*)a;
39792         LDKSignOrCreationError* b_conv = (LDKSignOrCreationError*)b;
39793         jboolean ret_val = SignOrCreationError_eq(a_conv, b_conv);
39794         return ret_val;
39795 }
39796
39797 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignOrCreationError_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
39798         LDKSignOrCreationError* o_conv = (LDKSignOrCreationError*)o;
39799         LDKStr ret_str = SignOrCreationError_to_str(o_conv);
39800         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
39801         Str_free(ret_str);
39802         return ret_conv;
39803 }
39804
39805 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39806         LDKInvoicePayer this_obj_conv;
39807         this_obj_conv.inner = (void*)(this_obj & (~1));
39808         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39809         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39810         InvoicePayer_free(this_obj_conv);
39811 }
39812
39813 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Payer_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39814         if ((this_ptr & 1) != 0) return;
39815         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39816         CHECK_ACCESS(this_ptr_ptr);
39817         LDKPayer this_ptr_conv = *(LDKPayer*)(this_ptr_ptr);
39818         FREE((void*)this_ptr);
39819         Payer_free(this_ptr_conv);
39820 }
39821
39822 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_Router_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39823         if ((this_ptr & 1) != 0) return;
39824         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39825         CHECK_ACCESS(this_ptr_ptr);
39826         LDKRouter this_ptr_conv = *(LDKRouter*)(this_ptr_ptr);
39827         FREE((void*)this_ptr);
39828         Router_free(this_ptr_conv);
39829 }
39830
39831 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
39832         LDKRetryAttempts this_obj_conv;
39833         this_obj_conv.inner = (void*)(this_obj & (~1));
39834         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
39835         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
39836         RetryAttempts_free(this_obj_conv);
39837 }
39838
39839 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1get_1a(JNIEnv *env, jclass clz, int64_t this_ptr) {
39840         LDKRetryAttempts this_ptr_conv;
39841         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39842         this_ptr_conv.is_owned = false;
39843         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39844         int64_t ret_val = RetryAttempts_get_a(&this_ptr_conv);
39845         return ret_val;
39846 }
39847
39848 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1set_1a(JNIEnv *env, jclass clz, int64_t this_ptr, int64_t val) {
39849         LDKRetryAttempts this_ptr_conv;
39850         this_ptr_conv.inner = (void*)(this_ptr & (~1));
39851         this_ptr_conv.is_owned = false;
39852         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_ptr_conv);
39853         RetryAttempts_set_a(&this_ptr_conv, val);
39854 }
39855
39856 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1new(JNIEnv *env, jclass clz, int64_t a_arg) {
39857         LDKRetryAttempts ret_var = RetryAttempts_new(a_arg);
39858         uint64_t ret_ref = 0;
39859         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39860         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39861         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39862         ret_ref = (uint64_t)ret_var.inner;
39863         if (ret_var.is_owned) {
39864                 ret_ref |= 1;
39865         }
39866         return ret_ref;
39867 }
39868
39869 static inline uint64_t RetryAttempts_clone_ptr(LDKRetryAttempts *NONNULL_PTR arg) {
39870         LDKRetryAttempts ret_var = RetryAttempts_clone(arg);
39871 uint64_t ret_ref = 0;
39872 CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39873 CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39874 CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39875 ret_ref = (uint64_t)ret_var.inner;
39876 if (ret_var.is_owned) {
39877         ret_ref |= 1;
39878 }
39879         return ret_ref;
39880 }
39881 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39882         LDKRetryAttempts arg_conv;
39883         arg_conv.inner = (void*)(arg & (~1));
39884         arg_conv.is_owned = false;
39885         CHECK_INNER_FIELD_ACCESS_OR_NULL(arg_conv);
39886         int64_t ret_val = RetryAttempts_clone_ptr(&arg_conv);
39887         return ret_val;
39888 }
39889
39890 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39891         LDKRetryAttempts orig_conv;
39892         orig_conv.inner = (void*)(orig & (~1));
39893         orig_conv.is_owned = false;
39894         CHECK_INNER_FIELD_ACCESS_OR_NULL(orig_conv);
39895         LDKRetryAttempts ret_var = RetryAttempts_clone(&orig_conv);
39896         uint64_t ret_ref = 0;
39897         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
39898         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
39899         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
39900         ret_ref = (uint64_t)ret_var.inner;
39901         if (ret_var.is_owned) {
39902                 ret_ref |= 1;
39903         }
39904         return ret_ref;
39905 }
39906
39907 JNIEXPORT jboolean JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1eq(JNIEnv *env, jclass clz, int64_t a, int64_t b) {
39908         LDKRetryAttempts a_conv;
39909         a_conv.inner = (void*)(a & (~1));
39910         a_conv.is_owned = false;
39911         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39912         LDKRetryAttempts b_conv;
39913         b_conv.inner = (void*)(b & (~1));
39914         b_conv.is_owned = false;
39915         CHECK_INNER_FIELD_ACCESS_OR_NULL(b_conv);
39916         jboolean ret_val = RetryAttempts_eq(&a_conv, &b_conv);
39917         return ret_val;
39918 }
39919
39920 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_RetryAttempts_1hash(JNIEnv *env, jclass clz, int64_t o) {
39921         LDKRetryAttempts o_conv;
39922         o_conv.inner = (void*)(o & (~1));
39923         o_conv.is_owned = false;
39924         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
39925         int64_t ret_val = RetryAttempts_hash(&o_conv);
39926         return ret_val;
39927 }
39928
39929 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_PaymentError_1free(JNIEnv *env, jclass clz, int64_t this_ptr) {
39930         if ((this_ptr & 1) != 0) return;
39931         void* this_ptr_ptr = (void*)(((uint64_t)this_ptr) & ~1);
39932         CHECK_ACCESS(this_ptr_ptr);
39933         LDKPaymentError this_ptr_conv = *(LDKPaymentError*)(this_ptr_ptr);
39934         FREE((void*)this_ptr);
39935         PaymentError_free(this_ptr_conv);
39936 }
39937
39938 static inline uint64_t PaymentError_clone_ptr(LDKPaymentError *NONNULL_PTR arg) {
39939         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39940         *ret_copy = PaymentError_clone(arg);
39941 uint64_t ret_ref = (uint64_t)ret_copy;
39942         return ret_ref;
39943 }
39944 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone_1ptr(JNIEnv *env, jclass clz, int64_t arg) {
39945         LDKPaymentError* arg_conv = (LDKPaymentError*)arg;
39946         int64_t ret_val = PaymentError_clone_ptr(arg_conv);
39947         return ret_val;
39948 }
39949
39950 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1clone(JNIEnv *env, jclass clz, int64_t orig) {
39951         LDKPaymentError* orig_conv = (LDKPaymentError*)orig;
39952         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39953         *ret_copy = PaymentError_clone(orig_conv);
39954         uint64_t ret_ref = (uint64_t)ret_copy;
39955         return ret_ref;
39956 }
39957
39958 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1invoice(JNIEnv *env, jclass clz, jstring a) {
39959         LDKStr a_conv = java_to_owned_str(env, a);
39960         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39961         *ret_copy = PaymentError_invoice(a_conv);
39962         uint64_t ret_ref = (uint64_t)ret_copy;
39963         return ret_ref;
39964 }
39965
39966 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1routing(JNIEnv *env, jclass clz, int64_t a) {
39967         LDKLightningError a_conv;
39968         a_conv.inner = (void*)(a & (~1));
39969         a_conv.is_owned = (a & 1) || (a == 0);
39970         CHECK_INNER_FIELD_ACCESS_OR_NULL(a_conv);
39971         a_conv = LightningError_clone(&a_conv);
39972         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39973         *ret_copy = PaymentError_routing(a_conv);
39974         uint64_t ret_ref = (uint64_t)ret_copy;
39975         return ret_ref;
39976 }
39977
39978 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_PaymentError_1sending(JNIEnv *env, jclass clz, int64_t a) {
39979         void* a_ptr = (void*)(((uint64_t)a) & ~1);
39980         CHECK_ACCESS(a_ptr);
39981         LDKPaymentSendFailure a_conv = *(LDKPaymentSendFailure*)(a_ptr);
39982         a_conv = PaymentSendFailure_clone((LDKPaymentSendFailure*)(((uint64_t)a) & ~1));
39983         LDKPaymentError *ret_copy = MALLOC(sizeof(LDKPaymentError), "LDKPaymentError");
39984         *ret_copy = PaymentError_sending(a_conv);
39985         uint64_t ret_ref = (uint64_t)ret_copy;
39986         return ret_ref;
39987 }
39988
39989 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) {
39990         void* payer_ptr = (void*)(((uint64_t)payer) & ~1);
39991         CHECK_ACCESS(payer_ptr);
39992         LDKPayer payer_conv = *(LDKPayer*)(payer_ptr);
39993         if (payer_conv.free == LDKPayer_JCalls_free) {
39994                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
39995                 LDKPayer_JCalls_cloned(&payer_conv);
39996         }
39997         void* router_ptr = (void*)(((uint64_t)router) & ~1);
39998         CHECK_ACCESS(router_ptr);
39999         LDKRouter router_conv = *(LDKRouter*)(router_ptr);
40000         if (router_conv.free == LDKRouter_JCalls_free) {
40001                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40002                 LDKRouter_JCalls_cloned(&router_conv);
40003         }
40004         LDKLockableScore scorer_conv;
40005         scorer_conv.inner = (void*)(scorer & (~1));
40006         scorer_conv.is_owned = false;
40007         CHECK_INNER_FIELD_ACCESS_OR_NULL(scorer_conv);
40008         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
40009         CHECK_ACCESS(logger_ptr);
40010         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40011         if (logger_conv.free == LDKLogger_JCalls_free) {
40012                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40013                 LDKLogger_JCalls_cloned(&logger_conv);
40014         }
40015         void* event_handler_ptr = (void*)(((uint64_t)event_handler) & ~1);
40016         CHECK_ACCESS(event_handler_ptr);
40017         LDKEventHandler event_handler_conv = *(LDKEventHandler*)(event_handler_ptr);
40018         if (event_handler_conv.free == LDKEventHandler_JCalls_free) {
40019                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40020                 LDKEventHandler_JCalls_cloned(&event_handler_conv);
40021         }
40022         LDKRetryAttempts retry_attempts_conv;
40023         retry_attempts_conv.inner = (void*)(retry_attempts & (~1));
40024         retry_attempts_conv.is_owned = (retry_attempts & 1) || (retry_attempts == 0);
40025         CHECK_INNER_FIELD_ACCESS_OR_NULL(retry_attempts_conv);
40026         retry_attempts_conv = RetryAttempts_clone(&retry_attempts_conv);
40027         LDKInvoicePayer ret_var = InvoicePayer_new(payer_conv, router_conv, &scorer_conv, logger_conv, event_handler_conv, retry_attempts_conv);
40028         uint64_t ret_ref = 0;
40029         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40030         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40031         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40032         ret_ref = (uint64_t)ret_var.inner;
40033         if (ret_var.is_owned) {
40034                 ret_ref |= 1;
40035         }
40036         return ret_ref;
40037 }
40038
40039 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1pay_1invoice(JNIEnv *env, jclass clz, int64_t this_arg, int64_t invoice) {
40040         LDKInvoicePayer this_arg_conv;
40041         this_arg_conv.inner = (void*)(this_arg & (~1));
40042         this_arg_conv.is_owned = false;
40043         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40044         LDKInvoice invoice_conv;
40045         invoice_conv.inner = (void*)(invoice & (~1));
40046         invoice_conv.is_owned = false;
40047         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
40048         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40049         *ret_conv = InvoicePayer_pay_invoice(&this_arg_conv, &invoice_conv);
40050         return (uint64_t)ret_conv;
40051 }
40052
40053 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) {
40054         LDKInvoicePayer this_arg_conv;
40055         this_arg_conv.inner = (void*)(this_arg & (~1));
40056         this_arg_conv.is_owned = false;
40057         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40058         LDKInvoice invoice_conv;
40059         invoice_conv.inner = (void*)(invoice & (~1));
40060         invoice_conv.is_owned = false;
40061         CHECK_INNER_FIELD_ACCESS_OR_NULL(invoice_conv);
40062         LDKCResult_PaymentIdPaymentErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_PaymentIdPaymentErrorZ), "LDKCResult_PaymentIdPaymentErrorZ");
40063         *ret_conv = InvoicePayer_pay_zero_value_invoice(&this_arg_conv, &invoice_conv, amount_msats);
40064         return (uint64_t)ret_conv;
40065 }
40066
40067 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1remove_1cached_1payment(JNIEnv *env, jclass clz, int64_t this_arg, int8_tArray payment_hash) {
40068         LDKInvoicePayer this_arg_conv;
40069         this_arg_conv.inner = (void*)(this_arg & (~1));
40070         this_arg_conv.is_owned = false;
40071         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40072         unsigned char payment_hash_arr[32];
40073         CHECK((*env)->GetArrayLength(env, payment_hash) == 32);
40074         (*env)->GetByteArrayRegion(env, payment_hash, 0, 32, payment_hash_arr);
40075         unsigned char (*payment_hash_ref)[32] = &payment_hash_arr;
40076         InvoicePayer_remove_cached_payment(&this_arg_conv, payment_hash_ref);
40077 }
40078
40079 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_InvoicePayer_1as_1EventHandler(JNIEnv *env, jclass clz, int64_t this_arg) {
40080         LDKInvoicePayer this_arg_conv;
40081         this_arg_conv.inner = (void*)(this_arg & (~1));
40082         this_arg_conv.is_owned = false;
40083         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40084         LDKEventHandler* ret_ret = MALLOC(sizeof(LDKEventHandler), "LDKEventHandler");
40085         *ret_ret = InvoicePayer_as_EventHandler(&this_arg_conv);
40086         return (uint64_t)ret_ret;
40087 }
40088
40089 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) {
40090         LDKChannelManager channelmanager_conv;
40091         channelmanager_conv.inner = (void*)(channelmanager & (~1));
40092         channelmanager_conv.is_owned = false;
40093         CHECK_INNER_FIELD_ACCESS_OR_NULL(channelmanager_conv);
40094         void* keys_manager_ptr = (void*)(((uint64_t)keys_manager) & ~1);
40095         CHECK_ACCESS(keys_manager_ptr);
40096         LDKKeysInterface keys_manager_conv = *(LDKKeysInterface*)(keys_manager_ptr);
40097         if (keys_manager_conv.free == LDKKeysInterface_JCalls_free) {
40098                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40099                 LDKKeysInterface_JCalls_cloned(&keys_manager_conv);
40100         }
40101         LDKCurrency network_conv = LDKCurrency_from_java(env, network);
40102         void* amt_msat_ptr = (void*)(((uint64_t)amt_msat) & ~1);
40103         CHECK_ACCESS(amt_msat_ptr);
40104         LDKCOption_u64Z amt_msat_conv = *(LDKCOption_u64Z*)(amt_msat_ptr);
40105         amt_msat_conv = COption_u64Z_clone((LDKCOption_u64Z*)(((uint64_t)amt_msat) & ~1));
40106         LDKStr description_conv = java_to_owned_str(env, description);
40107         LDKCResult_InvoiceSignOrCreationErrorZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceSignOrCreationErrorZ), "LDKCResult_InvoiceSignOrCreationErrorZ");
40108         *ret_conv = create_invoice_from_channelmanager(&channelmanager_conv, keys_manager_conv, network_conv, amt_msat_conv, description_conv);
40109         return (uint64_t)ret_conv;
40110 }
40111
40112 JNIEXPORT void JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1free(JNIEnv *env, jclass clz, int64_t this_obj) {
40113         LDKDefaultRouter this_obj_conv;
40114         this_obj_conv.inner = (void*)(this_obj & (~1));
40115         this_obj_conv.is_owned = (this_obj & 1) || (this_obj == 0);
40116         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_obj_conv);
40117         DefaultRouter_free(this_obj_conv);
40118 }
40119
40120 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1new(JNIEnv *env, jclass clz, int64_t network_graph, int64_t logger) {
40121         LDKNetworkGraph network_graph_conv;
40122         network_graph_conv.inner = (void*)(network_graph & (~1));
40123         network_graph_conv.is_owned = false;
40124         CHECK_INNER_FIELD_ACCESS_OR_NULL(network_graph_conv);
40125         void* logger_ptr = (void*)(((uint64_t)logger) & ~1);
40126         CHECK_ACCESS(logger_ptr);
40127         LDKLogger logger_conv = *(LDKLogger*)(logger_ptr);
40128         if (logger_conv.free == LDKLogger_JCalls_free) {
40129                 // If this_arg is a JCalls struct, then we need to increment the refcnt in it.
40130                 LDKLogger_JCalls_cloned(&logger_conv);
40131         }
40132         LDKDefaultRouter ret_var = DefaultRouter_new(&network_graph_conv, logger_conv);
40133         uint64_t ret_ref = 0;
40134         CHECK((((uint64_t)ret_var.inner) & 1) == 0); // We rely on a free low bit, malloc guarantees this.
40135         CHECK((((uint64_t)&ret_var) & 1) == 0); // We rely on a free low bit, pointer alignment guarantees this.
40136         CHECK_INNER_FIELD_ACCESS_OR_NULL(ret_var);
40137         ret_ref = (uint64_t)ret_var.inner;
40138         if (ret_var.is_owned) {
40139                 ret_ref |= 1;
40140         }
40141         return ret_ref;
40142 }
40143
40144 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_DefaultRouter_1as_1Router(JNIEnv *env, jclass clz, int64_t this_arg) {
40145         LDKDefaultRouter this_arg_conv;
40146         this_arg_conv.inner = (void*)(this_arg & (~1));
40147         this_arg_conv.is_owned = false;
40148         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40149         LDKRouter* ret_ret = MALLOC(sizeof(LDKRouter), "LDKRouter");
40150         *ret_ret = DefaultRouter_as_Router(&this_arg_conv);
40151         return (uint64_t)ret_ret;
40152 }
40153
40154 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_ChannelManager_1as_1Payer(JNIEnv *env, jclass clz, int64_t this_arg) {
40155         LDKChannelManager this_arg_conv;
40156         this_arg_conv.inner = (void*)(this_arg & (~1));
40157         this_arg_conv.is_owned = false;
40158         CHECK_INNER_FIELD_ACCESS_OR_NULL(this_arg_conv);
40159         LDKPayer* ret_ret = MALLOC(sizeof(LDKPayer), "LDKPayer");
40160         *ret_ret = ChannelManager_as_Payer(&this_arg_conv);
40161         return (uint64_t)ret_ret;
40162 }
40163
40164 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SiPrefix_1from_1str(JNIEnv *env, jclass clz, jstring s) {
40165         LDKStr s_conv = java_to_owned_str(env, s);
40166         LDKCResult_SiPrefixNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SiPrefixNoneZ), "LDKCResult_SiPrefixNoneZ");
40167         *ret_conv = SiPrefix_from_str(s_conv);
40168         return (uint64_t)ret_conv;
40169 }
40170
40171 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_Invoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
40172         LDKStr s_conv = java_to_owned_str(env, s);
40173         LDKCResult_InvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_InvoiceNoneZ), "LDKCResult_InvoiceNoneZ");
40174         *ret_conv = Invoice_from_str(s_conv);
40175         return (uint64_t)ret_conv;
40176 }
40177
40178 JNIEXPORT int64_t JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1from_1str(JNIEnv *env, jclass clz, jstring s) {
40179         LDKStr s_conv = java_to_owned_str(env, s);
40180         LDKCResult_SignedRawInvoiceNoneZ* ret_conv = MALLOC(sizeof(LDKCResult_SignedRawInvoiceNoneZ), "LDKCResult_SignedRawInvoiceNoneZ");
40181         *ret_conv = SignedRawInvoice_from_str(s_conv);
40182         return (uint64_t)ret_conv;
40183 }
40184
40185 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Invoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40186         LDKInvoice o_conv;
40187         o_conv.inner = (void*)(o & (~1));
40188         o_conv.is_owned = false;
40189         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40190         LDKStr ret_str = Invoice_to_str(&o_conv);
40191         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40192         Str_free(ret_str);
40193         return ret_conv;
40194 }
40195
40196 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SignedRawInvoice_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40197         LDKSignedRawInvoice o_conv;
40198         o_conv.inner = (void*)(o & (~1));
40199         o_conv.is_owned = false;
40200         CHECK_INNER_FIELD_ACCESS_OR_NULL(o_conv);
40201         LDKStr ret_str = SignedRawInvoice_to_str(&o_conv);
40202         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40203         Str_free(ret_str);
40204         return ret_conv;
40205 }
40206
40207 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_Currency_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40208         LDKCurrency* o_conv = (LDKCurrency*)(o & ~1);
40209         LDKStr ret_str = Currency_to_str(o_conv);
40210         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40211         Str_free(ret_str);
40212         return ret_conv;
40213 }
40214
40215 JNIEXPORT jstring JNICALL Java_org_ldk_impl_bindings_SiPrefix_1to_1str(JNIEnv *env, jclass clz, int64_t o) {
40216         LDKSiPrefix* o_conv = (LDKSiPrefix*)(o & ~1);
40217         LDKStr ret_str = SiPrefix_to_str(o_conv);
40218         jstring ret_conv = str_ref_to_java(env, ret_str.chars, ret_str.len);
40219         Str_free(ret_str);
40220         return ret_conv;
40221 }
40222